Skip to content

Commit e7d7717

Browse files
committed
add PCM_DEBUG_PMU_DISCOVERY capability
Change-Id: Ifce75a0aa806f6ebc1f40cf7cf45485c31115951
1 parent 1a7ecfb commit e7d7717

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/uncore_pmu_discovery.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ UncorePMUDiscovery::UncorePMUDiscovery()
1515
{
1616
return;
1717
}
18-
auto processTables = [this](const uint64 bar, const VSEC & vsec)
18+
const auto debug = (safe_getenv("PCM_DEBUG_PMU_DISCOVERY") == std::string("1"));
19+
20+
auto processTables = [this, &debug](const uint64 bar, const VSEC & vsec)
1921
{
2022
try {
23+
DBG(2, "Uncore discovery detection. Reading from bar 0x", std::hex, bar, std::dec);
2124
constexpr size_t UncoreDiscoverySize = 3UL;
2225
union UncoreGlobalDiscovery {
2326
GlobalPMU pmu;
@@ -26,6 +29,12 @@ UncorePMUDiscovery::UncorePMUDiscovery()
2629
UncoreGlobalDiscovery global;
2730
mmio_memcpy(global.table, bar, UncoreDiscoverySize * sizeof(uint64), true);
2831
globalPMUs.push_back(global.pmu);
32+
if (debug)
33+
{
34+
std::cerr << "Read global.pmu from 0x" << std::hex << bar << std::dec << "\n";
35+
global.pmu.print();
36+
std::cout.flush();
37+
}
2938
union UncoreUnitDiscovery {
3039
BoxPMU pmu;
3140
uint64 table[UncoreDiscoverySize];
@@ -36,8 +45,18 @@ UncorePMUDiscovery::UncorePMUDiscovery()
3645
for (size_t u = 0; u < global.pmu.maxUnits; ++u)
3746
{
3847
mmio_memcpy(unit.table, bar + (u + 1) * step, UncoreDiscoverySize * sizeof(uint64), true);
48+
if (debug)
49+
{
50+
std::cerr << "Read unit.pmu " << u << " from 0x" << std::hex << (bar + (u + 1) * step) << std::dec << "\n";
51+
unit.pmu.print();
52+
std::cout.flush();
53+
}
3954
if (unit.table[0] == 0 && unit.table[1] == 0)
4055
{
56+
if (debug)
57+
{
58+
std::cerr << "Invalid entry\n";
59+
}
4160
// invalid entry
4261
continue;
4362
}

0 commit comments

Comments
 (0)