From 2abab1427e04cb5fb1f4021f4e5be52ebadc556d Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Mon, 17 Jul 2023 15:27:17 +0200 Subject: [PATCH 1/4] return the correct size Change-Id: Ide1a6941b498dde9e916c82aaf026cd8932c1cde --- src/WinMSRDriver/msrmain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WinMSRDriver/msrmain.c b/src/WinMSRDriver/msrmain.c index e92d6312..9e3d1c2b 100644 --- a/src/WinMSRDriver/msrmain.c +++ b/src/WinMSRDriver/msrmain.c @@ -281,7 +281,7 @@ NTSTATUS deviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) status = STATUS_INVALID_PARAMETER; break; } - Irp->IoStatus.Information = sizeof(ULONG64); // result size + Irp->IoStatus.Information = size; // result size break; default: From 6c5d143faa3cac1a09ae4b4d3de327aa136b47bf Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Tue, 25 Jul 2023 07:53:35 +0200 Subject: [PATCH 2/4] add M3UPI PMU for SPR Change-Id: Ib793b3575b00e765054d7c7ffb4fa4740412558b --- src/cpucounters.cpp | 15 +++++++++++---- src/types.h | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index 76d5a535..850ef297 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -6911,6 +6911,11 @@ void ServerUncorePMUs::initRegisterLocations(const PCM * pcm) PCM_PCICFG_QPI_INIT(2, SPR); PCM_PCICFG_QPI_INIT(3, SPR); + PCM_PCICFG_M3UPI_INIT(0, SPR); + PCM_PCICFG_M3UPI_INIT(1, SPR); + PCM_PCICFG_M3UPI_INIT(2, SPR); + PCM_PCICFG_M3UPI_INIT(3, SPR); + PCM_PCICFG_M2M_INIT(0, SERVER) PCM_PCICFG_M2M_INIT(1, SERVER) PCM_PCICFG_M2M_INIT(2, SERVER) @@ -7303,8 +7308,10 @@ void ServerUncorePMUs::initDirect(uint32 socket_, const PCM * pcm) } for (auto& handle : m3upiHandles) { - if (cpu_model == PCM::ICX) + switch (cpu_model) { + case PCM::ICX: + case PCM::SPR: m3upiPMUs.push_back( UncorePMU( std::make_shared(handle, ICX_M3UPI_PCI_PMON_BOX_CTL_ADDR), @@ -7318,9 +7325,9 @@ void ServerUncorePMUs::initDirect(uint32 socket_, const PCM * pcm) std::make_shared(handle, ICX_M3UPI_PCI_PMON_CTR3_ADDR) ) ); - } - else - { + break; + + default: m3upiPMUs.push_back( UncorePMU( std::make_shared(handle, M3UPI_PCI_PMON_BOX_CTL_ADDR), diff --git a/src/types.h b/src/types.h index f23a3b21..c19921c9 100644 --- a/src/types.h +++ b/src/types.h @@ -778,6 +778,15 @@ constexpr auto ICX_M3UPI_PORT0_REGISTER_FUNC_ADDR = (1); constexpr auto ICX_M3UPI_PORT1_REGISTER_FUNC_ADDR = (1); constexpr auto ICX_M3UPI_PORT2_REGISTER_FUNC_ADDR = (1); +constexpr auto SPR_M3UPI_PORT0_REGISTER_DEV_ADDR = 5; +constexpr auto SPR_M3UPI_PORT1_REGISTER_DEV_ADDR = 6; +constexpr auto SPR_M3UPI_PORT2_REGISTER_DEV_ADDR = 7; +constexpr auto SPR_M3UPI_PORT3_REGISTER_DEV_ADDR = 8; +constexpr auto SPR_M3UPI_PORT0_REGISTER_FUNC_ADDR = 1; +constexpr auto SPR_M3UPI_PORT1_REGISTER_FUNC_ADDR = 1; +constexpr auto SPR_M3UPI_PORT2_REGISTER_FUNC_ADDR = 1; +constexpr auto SPR_M3UPI_PORT3_REGISTER_FUNC_ADDR = 1; + #define SKX_M2M_0_REGISTER_DEV_ADDR (8) #define SKX_M2M_0_REGISTER_FUNC_ADDR (0) #define SKX_M2M_1_REGISTER_DEV_ADDR (9) From 5ae0dfd6b1a62c5bf3398464e989af4315476f2d Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Fri, 28 Jul 2023 09:22:39 +0200 Subject: [PATCH 3/4] add script for filtering data in csv Change-Id: Ibb3dcec0e8fc3bdc83b3d2f0b35b6e884a2b08e2 --- scripts/filter.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 scripts/filter.sh diff --git a/scripts/filter.sh b/scripts/filter.sh new file mode 100644 index 00000000..4a521758 --- /dev/null +++ b/scripts/filter.sh @@ -0,0 +1,4 @@ + + +cat $1| rs -c, -C, -T | grep "$2" | rs -c, -C, -T > $3 + From 1c892cc3e463b7bc7f9db97e3db4525220711b6e Mon Sep 17 00:00:00 2001 From: QiongwenXu Date: Tue, 25 Jul 2023 17:07:20 -0700 Subject: [PATCH 4/4] Add instructions for compiling windows driver --- doc/WINDOWS_HOWTO.md | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/doc/WINDOWS_HOWTO.md b/doc/WINDOWS_HOWTO.md index 05bd91b4..83fe9fd5 100644 --- a/doc/WINDOWS_HOWTO.md +++ b/doc/WINDOWS_HOWTO.md @@ -2,9 +2,9 @@ _For support of systems with more than _**_64_**_ logical cores you need to compile all binaries below in “_**_x64_**_” platform mode (not the default “_**_Win32_**_” mode)._ -Command-line utility: +## Command-line utility -1. Compile the windows MSR driver (msr.sys) with Windows DDK Kit (see the sources in the WinMSRDriver directory). For Windows 7 and later versions you have to sign the msr.sys driver additionally ([http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx](http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx)). To enable loading test signed drivers on the system: in administrator cmd console run `bcdedit /set testsigning on` and reboot). +1. Follow [Compile the windows MSR driver](#compile-the-windows-msr-driver) to compile the windows MSR driver (msr.sys). For Windows 7 and later versions you have to sign the msr.sys driver additionally ([http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx](http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx)). To enable loading test signed drivers on the system: in administrator cmd console run `bcdedit /set testsigning on` and reboot. 2. Build the *pcm.exe* utility: ``` @@ -25,9 +25,9 @@ Alternatively you can achieve the same using the “Properties” Windows menu o If you are getting the error `Starting MSR service failed with error 3 The system cannot find the path specified.` try to uninstall the driver by running `pcm --uninstallDriver` and optionally reboot the system. -Graphical Perfmon front end: +## Graphical Perfmon front end -1. Compile the windows MSR driver (msr.sys) with Windows DDK Kit (see the sources in the WinMSRDriver directory). For Windows 7 and later versions you have to sign the msr.sys driver additionally ([http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx](http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx)). +1. Follow [Compile the windows MSR driver](#compile-the-windows-msr-driver) to compile the windows MSR driver (msr.sys). For Windows 7 and later versions you have to sign the msr.sys driver additionally ([http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx](http://msdn.microsoft.com/en-us/library/ms537361(VS.85).aspx)). 2. Copy msr.sys into the c:\windows\system32 directory @@ -53,7 +53,25 @@ If you do not want or cannot compile the msr.sys driver you might use a third-pa 2. Copy WinRing0.dll, WinRing0.sys, WinRing0x64.dll, WinRing0x64.sys files from there into the PCM.exe binary location, into the PCM-Service.exe location and into c:\windows\system32 3. Run the PCM.exe tool and/or go to step 6 (perfmon utility). -Known limitations: +## Compile the windows MSR driver + +1. Download Visual Studio ([Visual Studio download](https://visualstudio.microsoft.com/downloads/)). +When you install Visual Studio, also install related packages: + - under `Workloads`, select `Desktop development with C++` +(select `C++ CMake tools for Windows` in this workload) and `.NET desktop development`. + - under `Individual components`, search `Libs for Spectre` and select `MSVC v143 - VS +2022 C++ x64/x86 Spectre-mitigated libs(Latest)`. + +2. Download and install SDK ([windows-sdk](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/)) + +3. Download and install WDK ([windows-wdk](https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk)). Please select `Install Windows Driver Kit Visual Studio extension` when you install WDK. + +4. Open **a terminal in Visual Studio**, then go to `src\WinMSRDriver`, and run the following command to compile the driver. Then you will see `MSR.sys` in `src\WinMSRDriver\x64\Release`. + ``` + MSBuild.exe MSR.vcxproj -property:Configuration=Release -property:Platform=x64 + ``` + +## Known limitations Running PCM.exe under Cygwin shell is possible, but due to incompatibilities of signals/events handling between Windows and Cygwin, the PCM may not cleanup PMU configuration after Ctrl+C or Ctrl+Break pressed. The subsequent run of PCM will require to do PMU configuration reset, so adding -r command line option to PCM will be required.