Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push 2023 10 17 #585

Merged
merged 46 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9550c4a
pcm-accel: return value 0 to avoid the confuse to user if overflow ha…
oldwhite81 Aug 4, 2023
ff011f7
add UNC_P_FREQ_MAX_LIMIT_THERMAL_CYCLES test
rdementi Aug 4, 2023
6f04f38
add pcu in GenuineIntel-6-55-4.json
rdementi Aug 4, 2023
c3effcf
add pcu in GenuineIntel-6-55-{7,B}.json
rdementi Aug 4, 2023
7b1a9c1
add MMIOEventPosition
rdementi Sep 12, 2023
9e6ab55
add more MMIO reg functions
rdementi Sep 13, 2023
2c7adc4
populate MMIORegisterLocations
rdementi Sep 13, 2023
b1ed562
add readMMIORegisters
rdementi Sep 13, 2023
3ef800d
pcm-raw: add support of mmio register reads
rdementi Sep 13, 2023
878b6b1
document MMIO register access
rdementi Sep 14, 2023
7cabffa
Merge remote-tracking branch 'opcm-github/master'
rdementi Sep 14, 2023
76eb36d
pcm-raw: add support of opc field for BDX
rdementi Sep 18, 2023
4ef5465
pcm-raw: add support of state field for BDX
rdementi Sep 18, 2023
0aa31fd
pcm-raw: add support of nc and isoc field for BDX
rdementi Sep 18, 2023
018fc00
pcm-raw: added invert and anythread modifiers
rdementi Sep 18, 2023
8e3c66d
pcm-raw: support ha pmu
rdementi Sep 18, 2023
00c6490
pcm-raw: allow imc fixed event name change
rdementi Sep 18, 2023
38d5044
pcm-raw: remove the max number of event restrictions for register events
rdementi Sep 19, 2023
1b9d411
implement PCM_NO_MAIN_EXCEPTION_HANDLER variable
rdementi Sep 19, 2023
594ee51
document PCM_NO_MAIN_EXCEPTION_HANDLER
rdementi Sep 19, 2023
6613d57
add PCU PMU declaration for BDX
rdementi Sep 20, 2023
c583d33
throw exception with a message in pcihandle class
rdementi Sep 20, 2023
2aa2784
catch exception in getMaxNumOfCBoxes to allow the fall-back perf API …
rdementi Sep 20, 2023
fb6b386
Merge remote-tracking branch 'opcm-github/master'
rdementi Sep 25, 2023
73bb96e
Enable pcm-iio for SPR MCC
antonovalexnn Sep 27, 2023
efc21e0
extend max pcu number
rdementi Sep 26, 2023
cd07494
print additional uncore PMU unit information
rdementi Sep 27, 2023
0819793
refactor IIO PMU init
rdementi Sep 27, 2023
56a4ba6
factor out bit insert function
rdementi Oct 4, 2023
389f46f
refactor uncore pmu discovery
rdementi Oct 4, 2023
4d9249f
refactor DVSEC processing
rdementi Oct 4, 2023
0bf18dd
implement and use mmio_memcpy
rdementi Oct 5, 2023
982fb7a
implement pcm-tpmi utility
rdementi Oct 5, 2023
e702516
address a clang scan warning
rdementi Oct 5, 2023
f03b827
add documentation link for tpmi
rdementi Oct 5, 2023
341c7fb
Merge remote-tracking branch 'opcm-github/master'
rdementi Oct 5, 2023
09b1d44
add bit operations to other register tools
rdementi Oct 6, 2023
fd4c478
add PCM_SET_DLL_DIR
rdementi Oct 15, 2023
15a9a4e
load winring0 dll from the windows system directory
rdementi Oct 15, 2023
7c63719
call PCM_SET_DLL_DIR in pcm-service
rdementi Oct 15, 2023
54bb537
add restrictDriverAccessNative
rdementi Oct 15, 2023
4b3d570
drop restrictDriverAccessCls
rdementi Oct 15, 2023
444854d
drop restrictDriverAccess in CMakeList
rdementi Oct 15, 2023
f8c18e9
don't compile with MSVC DLLs
rdementi Oct 16, 2023
7995daf
be less verbose
rdementi Oct 16, 2023
ab09473
update windows-related documentation
rdementi Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Graphical front ends:
- **pcm-sensor** : front-end for KDE KSysGuard
- **pcm-service** : front-end for Windows perfmon

There are also utilities for reading/writing model specific registers (**pcm-msr**), PCI configuration registers (**pcm-pcicfg**) and memory mapped registers (**pcm-mmio**) supported on Linux, Windows, Mac OS X and FreeBSD.
There are also utilities for reading/writing model specific registers (**pcm-msr**), PCI configuration registers (**pcm-pcicfg**), memory mapped registers (**pcm-mmio**) and TPMI registers (**pcm-tpmi**) supported on Linux, Windows, Mac OS X and FreeBSD.

And finally a daemon that stores core, memory and QPI counters in shared memory that can be be accessed by non-root users.

Expand Down Expand Up @@ -87,7 +87,7 @@ Debug is default on Windows. Specify config to build Release:
```
cmake --build . --config Release
```
On Windows and MacOs additional drivers are required. Please find instructions here: [WINDOWS_HOWTO.md](doc/WINDOWS_HOWTO.md) and [MAC_HOWTO.txt](doc/MAC_HOWTO.txt).
On Windows and MacOs additional drivers and steps are required. Please find instructions here: [WINDOWS_HOWTO.md](doc/WINDOWS_HOWTO.md) and [MAC_HOWTO.txt](doc/MAC_HOWTO.txt).

FreeBSD/DragonFlyBSD-specific details can be found in [FREEBSD_HOWTO.txt](doc/FREEBSD_HOWTO.txt)

Expand All @@ -103,7 +103,7 @@ Downloading Pre-Compiled PCM Tools
* RHEL8.5 or later: `sudo dnf install pcm`
* Fedora: `sudo yum install pcm`
* RPMs and DEBs with the *latest* PCM version for RHEL/SLE/Ubuntu/Debian/openSUSE/etc distributions (binary and source) are available [here](https://software.opensuse.org/download/package?package=pcm&project=home%3Aopcm)
- Windows: download PCM binaries as [appveyor build service](https://ci.appveyor.com/project/opcm/pcm/history) artifacts and required Visual C++ Redistributable from [www.microsoft.com](https://www.microsoft.com/en-us/download/details.aspx?id=48145). Additional drivers are needed, see [WINDOWS_HOWTO.md](doc/WINDOWS_HOWTO.md).
- Windows: download PCM binaries as [appveyor build service](https://ci.appveyor.com/project/opcm/pcm/history) artifacts and required Visual C++ Redistributable from [www.microsoft.com](https://www.microsoft.com/en-us/download/details.aspx?id=48145). Additional steps and drivers are required, see [WINDOWS_HOWTO.md](doc/WINDOWS_HOWTO.md).
- Docker: see [instructions on how to use pcm-sensor-server pre-compiled container from docker hub](doc/DOCKER_README.md).

--------------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions doc/WINDOWS_HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ _For support of systems with more than _**_64_**_ logical cores you need to comp
```
alternatively you can perform `cmake -B build`, open *PCM.sln* form *build* folder in and build required project in Visual Studio.
.exe and .dll files will be located in *build\bin\Release* folder
3. Copy the msr.sys driver and pcm.exe into a single directory
3. As Administrator create PCM directory in Windows "Program Files" directory (e.g. `C:\Program Files (x86)\PCM\`)
4. As Administrator copy the msr.sys driver and pcm.exe into the PCM directory
5. Run pcm.exe utility from the PCM directory as Administrator

4. Run pcm.exe utility from this directory

For Windows 7 and Windows Server 2008 R2 the PCM utilities need to be run as administrator:
For Windows 7+ and Windows Server 2008+ R2 the PCM utilities need to be run as administrator:

Alternatively you can achieve the same using the “Properties” Windows menu of the executable (“Privilege level” setting in the “Compatibility” tab): Right mouse click -> Properties -> Compatibility -> Privilege level -> Set “Run this program as an administrator”.

Expand All @@ -35,7 +35,7 @@ If you are getting the error `Starting MSR service failed with error 3 The syste

4. Build 'PCM-Service.exe' using Microsoft Visual Studio or cmake

5. Copy PCM-Service.exe, PCM-Service.exe.config, and pcm-lib.dll files into a single directory
5. Copy PCM-Service.exe, PCM-Service.exe.config, and pcm-lib.dll files into the PCM sub-directory in Windows "Program Files" directory (see above)

The config file enables support for legacy security policy. Without this configuration switch, you will get an exception like this:

Expand Down
22 changes: 11 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


# All pcm-* executables
set(PROJECT_NAMES pcm pcm-numa pcm-latency pcm-power pcm-msr pcm-memory pcm-tsx pcm-pcie pcm-core pcm-iio pcm-lspci pcm-pcicfg pcm-mmio pcm-raw pcm-accel)
set(PROJECT_NAMES pcm pcm-numa pcm-latency pcm-power pcm-msr pcm-memory pcm-tsx pcm-pcie pcm-core pcm-iio pcm-lspci pcm-pcicfg pcm-mmio pcm-tpmi pcm-raw pcm-accel)

file(GLOB COMMON_SOURCES msr.cpp cpucounters.cpp pci.cpp mmio.cpp bw.cpp utils.cpp topology.cpp debug.cpp threadpool.cpp uncore_pmu_discovery.cpp)

Expand Down Expand Up @@ -54,26 +54,22 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /wd4251 /wd4273 /EHa /Zi")
add_definitions(/W3)

# https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html
# windows/restrictDriverAccess.cpp is building separately
add_library(restrictDriverAccess OBJECT windows/restrictDriverAccess.cpp)
set_target_properties(restrictDriverAccess PROPERTIES COMMON_LANGUAGE_RUNTIME "")
target_compile_definitions(restrictDriverAccess PRIVATE _CONSOLE _UNICODE UNICODE)

# Rest of windows/* files + restrictDriverAccess.cpp -> PCM_STATIC
# windows/* files -> PCM_STATIC
file(GLOB WINDOWS_SOURCES winpmem/winpmem.cpp windows/stdafx.cpp freegetopt/getopt.cpp)
add_library(PCM_STATIC STATIC $<TARGET_OBJECTS:restrictDriverAccess> ${COMMON_SOURCES} ${WINDOWS_SOURCES})
add_library(PCM_STATIC STATIC ${COMMON_SOURCES} ${WINDOWS_SOURCES})
target_compile_definitions(PCM_STATIC PRIVATE UNICODE _UNICODE _CONSOLE)
target_compile_options(PCM_STATIC PRIVATE "/MT$<$<CONFIG:Debug>:d>")

# Graphical perfmon front-end: pcm-lib, pcm-service
# Files: COMMON_FILES() + pcm-lib.cpp winpmem\winpmem.cpp dllmain.cpp
file(GLOB PCM_LIB_SOURCES winpmem/winpmem.cpp dllmain.cpp pcm-lib.cpp )
add_library(pcm-lib SHARED $<TARGET_OBJECTS:restrictDriverAccess> ${COMMON_SOURCES} ${PCM_LIB_SOURCES})
add_library(pcm-lib SHARED ${COMMON_SOURCES} ${PCM_LIB_SOURCES})
target_compile_definitions(pcm-lib PRIVATE _WINDOWS _USRDLL PCM_EXPORTS _WINDLL _UNICODE UNICODE)
target_compile_options(pcm-lib PRIVATE "/MT$<$<CONFIG:Debug>:d>")

# Pcm-service files: PCM_SHARED + AssemblyInfo.cpp PCMInstaller.cpp PCMService.cpp
file(GLOB PCM_SERVICE_SOURCES windows/PCMInstaller.cpp windows/PCMService.cpp windows/AssemblyInfo.cpp winddows/utils.cpp)
add_executable(pcm-service $<TARGET_OBJECTS:restrictDriverAccess> ${PCM_SERVICE_SOURCES})
add_executable(pcm-service ${PCM_SERVICE_SOURCES})
target_compile_definitions(pcm-service PRIVATE _UNICODE UNICODE _CONSOLE)
set_target_properties(pcm-service PROPERTIES LINK_FLAGS "/INCREMENTAL:NO" COMMON_LANGUAGE_RUNTIME "")
set_property(TARGET pcm-service PROPERTY VS_DOTNET_REFERENCES "System;System.Configuration.Install;System.Data;System.Management;System.ServiceProcess;System.Xml")
Expand Down Expand Up @@ -134,6 +130,10 @@ foreach(PROJECT_NAME ${PROJECT_NAMES})

add_executable(${PROJECT_NAME} ${PROJECT_FILE})

if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE "/MT$<$<CONFIG:Debug>:d>")
endif(MSVC)

# specific file for pcm-raw project
if(${PROJECT_NAME} STREQUAL pcm-raw)
set(LIBS ${LIBS} PCM_SIMDJSON)
Expand Down
97 changes: 64 additions & 33 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ int convertUnknownToInt(size_t size, char* value);

#ifdef _MSC_VER

void PCM_API restrictDriverAccess(LPCTSTR path)
{
restrictDriverAccessNative(path);
}

HMODULE hOpenLibSys = NULL;

#ifndef NO_WINRING
Expand Down Expand Up @@ -1984,6 +1989,19 @@ void PCM::initUncoreObjects()
{
initUncorePMUsDirect();
}

std::cerr << "Info: " << uboxPMUs.size() << " UBOX units detected.\n";
for (uint32 s = 0; s < (uint32)num_sockets; ++s)
{
std::cerr << "Socket " << s << ":" <<
" " << ((s < pcuPMUs.size()) ? pcuPMUs[s].size() : 0) << " PCU units detected."
" " << ((s < iioPMUs.size()) ? iioPMUs[s].size() : 0) << " IIO units detected."
" " << ((s < irpPMUs.size()) ? irpPMUs[s].size() : 0) << " IRP units detected."
" " << ((s < cboPMUs.size()) ? cboPMUs[s].size() : 0) << " CHA/CBO units detected."
" " << ((s < mdfPMUs.size()) ? mdfPMUs[s].size() : 0) << " MDF units detected."
" " << ((s < cxlPMUs.size()) ? cxlPMUs[s].size() : 0) << " CXL units detected."
"\n";
}
}

void PCM::globalFreezeUncoreCounters()
Expand Down Expand Up @@ -2026,6 +2044,7 @@ void PCM::globalFreezeUncoreCountersInternal(const unsigned long long int freeze

void PCM::initUncorePMUsDirect()
{
pcuPMUs.resize(num_sockets);
for (uint32 s = 0; s < (uint32)num_sockets; ++s)
{
auto & handle = MSR[socketRefCore[s]];
Expand Down Expand Up @@ -2121,7 +2140,7 @@ void PCM::initUncorePMUsDirect()
{
case IVYTOWN:
case JAKETOWN:
pcuPMUs.push_back(
pcuPMUs[s].push_back(
UncorePMU(
std::make_shared<MSRRegister>(handle, JKTIVT_PCU_MSR_PMON_BOX_CTL_ADDR),
std::make_shared<MSRRegister>(handle, JKTIVT_PCU_MSR_PMON_CTL0_ADDR),
Expand All @@ -2144,7 +2163,7 @@ void PCM::initUncorePMUsDirect()
case HASWELLX:
case SKX:
case ICX:
pcuPMUs.push_back(
pcuPMUs[s].push_back(
UncorePMU(
std::make_shared<MSRRegister>(handle, HSX_PCU_MSR_PMON_BOX_CTL_ADDR),
std::make_shared<MSRRegister>(handle, HSX_PCU_MSR_PMON_CTL0_ADDR),
Expand All @@ -2162,13 +2181,14 @@ void PCM::initUncorePMUsDirect()
);
break;
case SPR:
addPMUsFromDiscovery(pcuPMUs, SPR_PCU_BOX_TYPE, 0xE);
if (pcuPMUs.empty())
addPMUsFromDiscovery(pcuPMUs[s], SPR_PCU_BOX_TYPE, 0xE);
if (pcuPMUs[s].empty())
{
std::cerr << "ERROR: PCU PMU not found\n";
}
break;
}
assert(pcuPMUs[s].size() <= ServerUncoreCounterState::maxPUnits);

// add MDF PMUs
switch (cpu_model)
Expand All @@ -2185,9 +2205,10 @@ void PCM::initUncorePMUsDirect()
}

// init IIO addresses
if (getCPUModel() == PCM::SKX)
iioPMUs.resize(num_sockets);
switch (getCPUModel())
{
iioPMUs.resize(num_sockets);
case PCM::SKX:
for (uint32 s = 0; s < (uint32)num_sockets; ++s)
{
auto & handle = MSR[socketRefCore[s]];
Expand All @@ -2206,10 +2227,8 @@ void PCM::initUncorePMUsDirect()
);
}
}
}
else if (getCPUModel() == PCM::ICX)
{
iioPMUs.resize(num_sockets);
break;
case PCM::ICX:
for (uint32 s = 0; s < (uint32)num_sockets; ++s)
{
auto & handle = MSR[socketRefCore[s]];
Expand All @@ -2228,10 +2247,8 @@ void PCM::initUncorePMUsDirect()
);
}
}
}
else if (getCPUModel() == PCM::SNOWRIDGE)
{
iioPMUs.resize(num_sockets);
break;
case PCM::SNOWRIDGE:
for (uint32 s = 0; s < (uint32)num_sockets; ++s)
{
auto & handle = MSR[socketRefCore[s]];
Expand All @@ -2250,11 +2267,8 @@ void PCM::initUncorePMUsDirect()
);
}
}
}

if (getCPUModel() == PCM::SPR)
{
iioPMUs.resize(num_sockets);
break;
case PCM::SPR:
for (uint32 s = 0; s < (uint32)num_sockets; ++s)
{
auto & handle = MSR[socketRefCore[s]];
Expand All @@ -2273,9 +2287,9 @@ void PCM::initUncorePMUsDirect()
);
}
}
break;
}


//init the IDX accelerator
auto createIDXPMU = [](const size_t addr, const size_t mapSize, const size_t numaNode, const size_t socketId) -> IDX_PMU
{
Expand Down Expand Up @@ -2562,9 +2576,10 @@ void PCM::initUncorePMUsPerf()
irpPMUs.resize(num_sockets);
cboPMUs.resize(num_sockets);
mdfPMUs.resize(num_sockets);
pcuPMUs.resize(num_sockets);
for (uint32 s = 0; s < (uint32)num_sockets; ++s)
{
populatePerfPMUs(s, enumeratePerfPMUs("pcu", 100), pcuPMUs, false, true);
populatePerfPMUs(s, enumeratePerfPMUs("pcu", 100), pcuPMUs[s], false, true);
populatePerfPMUs(s, enumeratePerfPMUs("ubox", 100), uboxPMUs, true);
populatePerfPMUs(s, enumeratePerfPMUs("cbox", 100), cboPMUs[s], false, true, true);
populatePerfPMUs(s, enumeratePerfPMUs("cha", 200), cboPMUs[s], false, true, true);
Expand Down Expand Up @@ -4673,9 +4688,12 @@ void PCM::cleanupUncorePMUs(const bool silent)
pmu.cleanup();
}
}
for (auto & pmu : pcuPMUs)
for (auto& spcuPMUs : pcuPMUs)
{
pmu.cleanup();
for (auto& pmu : spcuPMUs)
{
pmu.cleanup();
}
}
for (auto& sPMUs : cxlPMUs)
{
Expand Down Expand Up @@ -5418,14 +5436,17 @@ void PCM::programPCU(uint32* PCUCntConf, const uint64 filter)
uint32 refCore = socketRefCore[i];
TemporalThreadAffinity tempThreadAffinity(refCore); // speedup trick for Linux

pcuPMUs[i].initFreeze(UNC_PMON_UNIT_CTL_FRZ_EN);

if (pcuPMUs[i].filter[0].get())
for (auto& pmu : pcuPMUs[i])
{
*pcuPMUs[i].filter[0] = filter;
}
pmu.initFreeze(UNC_PMON_UNIT_CTL_FRZ_EN);

program(pcuPMUs[i], &PCUCntConf[0], &PCUCntConf[4], UNC_PMON_UNIT_CTL_FRZ_EN);
if (pmu.filter[0].get())
{
*pmu.filter[0] = filter;
}

program(pmu, &PCUCntConf[0], &PCUCntConf[4], UNC_PMON_UNIT_CTL_FRZ_EN);
}
}
}

Expand Down Expand Up @@ -5731,7 +5752,10 @@ void PCM::freezeServerUncoreCounters()
const auto refCore = socketRefCore[i];
TemporalThreadAffinity tempThreadAffinity(refCore); // speedup trick for Linux

pcuPMUs[i].freeze(UNC_PMON_UNIT_CTL_FRZ_EN);
for (auto& pmu : pcuPMUs[i])
{
pmu.freeze(UNC_PMON_UNIT_CTL_FRZ_EN);
}

if (IIOEventsAvailable())
{
Expand Down Expand Up @@ -5783,7 +5807,10 @@ void PCM::unfreezeServerUncoreCounters()
const auto refCore = socketRefCore[i];
TemporalThreadAffinity tempThreadAffinity(refCore); // speedup trick for Linux

pcuPMUs[i].unfreeze(UNC_PMON_UNIT_CTL_FRZ_EN);
for (auto& pmu : pcuPMUs[i])
{
pmu.unfreeze(UNC_PMON_UNIT_CTL_FRZ_EN);
}

if (IIOEventsAvailable())
{
Expand Down Expand Up @@ -6588,9 +6615,13 @@ ServerUncoreCounterState PCM::getServerUncoreCounterState(uint32 socket)
result.UBOXCounter[i] = *(uboxPMUs[socket].counterValue[i]);
result.UncClocks = getUncoreClocks(socket);
}
for (int i = 0; i < ServerUncoreCounterState::maxCounters && socket < pcuPMUs.size() && size_t(i) < pcuPMUs[socket].size(); ++i)
for (size_t u = 0; socket < pcuPMUs.size() && u < pcuPMUs[socket].size(); ++u)
{
result.PCUCounter[i] = *pcuPMUs[socket].counterValue[i];
for (int i = 0; i < ServerUncoreCounterState::maxCounters && size_t(i) < pcuPMUs[socket][u].size(); ++i)
{
assert(u < ServerUncoreCounterState::maxPUnits);
result.PCUCounter[u][i] = *pcuPMUs[socket][u].counterValue[i];
}
}
for (size_t p = 0; p < getNumCXLPorts(socket); ++p)
{
Expand Down
Loading