Skip to content

Commit 19b7e61

Browse files
authored
Merge pull request #429 from opcm/push-2022-08-23
Push 2022 08 23
2 parents 6d115ca + c5f21f9 commit 19b7e61

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Current Build Status
1717
- Linux and OSX: [![Build Status](https://travis-ci.com/opcm/pcm.svg?branch=master)](https://travis-ci.com/opcm/pcm)
1818
- Windows: [![Build status](https://ci.appveyor.com/api/projects/status/github/opcm/pcm?branch=master&svg=true)](https://ci.appveyor.com/project/opcm/pcm)
1919
- FreeBSD: [![Build Status](https://api.cirrus-ci.com/github/opcm/pcm.svg)](https://cirrus-ci.com/github/opcm/pcm)
20-
- Docker Hub: [![Build status](https://img.shields.io/docker/cloud/build/opcm/pcm.svg)](doc/DOCKER_README.md) [![pulls](https://img.shields.io/docker/pulls/opcm/pcm.svg)](doc/DOCKER_README.md)
20+
- Docker Hub: [![Build status](https://img.shields.io/docker/cloud/build/opcm/pcm.svg)](doc/DOCKER_README.md)
2121

2222
--------------------------------------------------------------------------------
2323
PCM Tools

doc/PCM-EXPORTER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Processor Counter Monitor (PCM) Prometheus exporter [![Build Status](https://travis-ci.com/opcm/pcm.svg?branch=master)](https://travis-ci.com/opcm/pcm) [![pulls](https://img.shields.io/docker/pulls/opcm/pcm.svg)](DOCKER_README.md)
1+
# Processor Counter Monitor (PCM) Prometheus exporter [![Build Status](https://travis-ci.com/opcm/pcm.svg?branch=master)](https://travis-ci.com/opcm/pcm)
22

33

44
pcm-sensor-server is a collector exposing Intel processor metrics over http in JSON or Prometheus (exporter text based) format. Also [available as a docker container](DOCKER_README.md).

src/cpucounters.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,7 +3180,7 @@ PCM::ErrorCode PCM::programCoreCounters(const int i /* core */,
31803180
}
31813181
}
31823182

3183-
if (programPerfEvent(e, PERF_GEN_EVENT_0_POS + j, std::string("generic event #") + std::to_string(i)) == false)
3183+
if (programPerfEvent(e, PERF_GEN_EVENT_0_POS + j, std::string("generic event #") + std::to_string(j) + std::string(" on core #") + std::to_string(i)) == false)
31843184
{
31853185
return PCM::UnknownError;
31863186
}
@@ -3265,10 +3265,11 @@ PCM::ErrorCode PCM::programCoreCounters(const int i /* core */,
32653265
}
32663266
}
32673267
EventSelectRegister reg;
3268-
setEvent(reg, eventSel, umask);
3268+
reg.fields.event_select = eventSel;
3269+
reg.fields.umask = umask;
32693270
perf_event_attr e = PCM_init_perf_event_attr();
32703271
e.type = PERF_TYPE_RAW;
3271-
e.config = (1ULL << 63ULL) + reg.value;
3272+
e.config = reg.value;
32723273
// std::cerr << "Programming perf event " << std::hex << e.config << "\n";
32733274
if (programPerfEvent(e, event.second, std::string("event ") + event.first + " " + eventDesc) == false)
32743275
{
@@ -4289,6 +4290,7 @@ void PCM::readPerfData(uint32 core, std::vector<uint64> & outData)
42894290
}
42904291
uint64 data[1 + PERF_MAX_COUNTERS];
42914292
const int32 bytes2read = sizeof(uint64) * (1 + num_counters);
4293+
assert(num_counters <= PERF_MAX_COUNTERS);
42924294
int result = ::read(perfEventHandle[core][leader], data, bytes2read);
42934295
// data layout: nr counters; counter 0, counter 1, counter 2,...
42944296
if (result != bytes2read)
@@ -4301,7 +4303,17 @@ void PCM::readPerfData(uint32 core, std::vector<uint64> & outData)
43014303
std::cerr << "Number of counters read from perf is wrong. Elements read: " << data[0] << "\n";
43024304
}
43034305
else
4304-
{ // copy all counters, they start from position 1 in data
4306+
{
4307+
/*
4308+
if (core == 0)
4309+
{
4310+
std::unique_lock<std::mutex> _(instanceCreationMutex);
4311+
std::cerr << "DEBUG: perf raw: " << std::dec;
4312+
for (uint32 p=0; p < (1 + num_counters) ; ++p) std::cerr << data[p] << " ";
4313+
std::cerr << "\n";
4314+
}
4315+
*/
4316+
// copy all counters, they start from position 1 in data
43054317
std::copy((data + 1), (data + 1) + data[0], outData.begin());
43064318
}
43074319
};
@@ -4386,7 +4398,7 @@ void BasicCounterState::readAndAggregate(std::shared_ptr<SafeMsrHandle> msr)
43864398
cBackendBoundSlots = perfData[m->perfTopDownPos[PCM::PERF_TOPDOWN_BACKEND_POS]];
43874399
cRetiringSlots = perfData[m->perfTopDownPos[PCM::PERF_TOPDOWN_RETIRING_POS]];
43884400
cAllSlotsRaw = perfData[m->perfTopDownPos[PCM::PERF_TOPDOWN_SLOTS_POS]];
4389-
// if (core_id == 0) std::cout << "DEBUG: "<< cAllSlotsRaw << " " << cFrontendBoundSlots << " " << cBadSpeculationSlots << " " << cBackendBoundSlots << " " << cRetiringSlots << std::endl;
4401+
// if (core_id == 0) std::cout << "DEBUG: All: "<< cAllSlotsRaw << " FE: " << cFrontendBoundSlots << " BAD-SP: " << cBadSpeculationSlots << " BE: " << cBackendBoundSlots << " RET: " << cRetiringSlots << std::endl;
43904402
}
43914403
}
43924404
else

src/cpucounters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ class PCM_API PCM
870870
PERF_TOPDOWN_RETIRING_POS = PERF_TOPDOWN_SLOTS_POS + 4
871871
};
872872

873-
std::unordered_map<int, int> perfTopDownPos;
873+
std::array<int, (PERF_TOPDOWN_RETIRING_POS + 1)> perfTopDownPos;
874874

875875
enum {
876876
PERF_GROUP_LEADER_COUNTER = PERF_INST_RETIRED_POS,

src/pcm.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@ void print_output(PCM * m,
439439
if (m->dramEnergyMetricsAvailable())
440440
cout << " DIMM energy |";
441441
if (m->LLCReadMissLatencyMetricsAvailable())
442-
cout << " LLCRDMISSLAT (ns)";
442+
cout << " LLCRDMISSLAT (ns)|";
443443
if (m->uncoreFrequencyMetricAvailable())
444-
cout << " UncFREQ (Ghz)";
444+
cout << " UncFREQ (Ghz)|";
445445
cout << "\n";
446446
cout << longDiv;
447447
for (uint32 i = 0; i < m->getNumSockets(); ++i)
@@ -463,20 +463,20 @@ void print_output(PCM * m,
463463
cout << " " << setw(5) << getIARequestBytesFromMC(sktstate1[i], sktstate2[i]) / double(1e9);
464464
cout << " " << setw(5) << getGTRequestBytesFromMC(sktstate1[i], sktstate2[i]) / double(1e9);
465465
}
466-
cout << " ";
467466
if(m->packageEnergyMetricsAvailable()) {
468-
cout << setw(6) << getConsumedJoules(sktstate1[i], sktstate2[i]);
467+
cout << " ";
468+
cout << setw(6) << getConsumedJoules(sktstate1[i], sktstate2[i]);
469469
}
470-
cout << " ";
471470
if(m->dramEnergyMetricsAvailable()) {
472-
cout << setw(6) << getDRAMConsumedJoules(sktstate1[i], sktstate2[i]);
471+
cout << " ";
472+
cout << setw(6) << getDRAMConsumedJoules(sktstate1[i], sktstate2[i]);
473473
}
474-
cout << " ";
475474
if (m->LLCReadMissLatencyMetricsAvailable()) {
476-
cout << setw(6) << getLLCReadMissLatency(sktstate1[i], sktstate2[i]);
475+
cout << " ";
476+
cout << setw(6) << getLLCReadMissLatency(sktstate1[i], sktstate2[i]);
477477
}
478-
cout << " ";
479478
if (m->uncoreFrequencyMetricAvailable()) {
479+
cout << " ";
480480
cout << setw(4) << getAverageUncoreFrequencyGhz(sktstate1[i], sktstate2[i]);
481481
}
482482
cout << "\n";
@@ -494,20 +494,20 @@ void print_output(PCM * m,
494494
" " << setw(5) << getBytesWrittenToPMM(sstate1, sstate2) / double(1e9);
495495
if (m->memoryIOTrafficMetricAvailable())
496496
cout << " " << setw(5) << getIORequestBytesFromMC(sstate1, sstate2) / double(1e9);
497-
cout << " ";
498497
if (m->packageEnergyMetricsAvailable()) {
498+
cout << " ";
499499
cout << setw(6) << getConsumedJoules(sstate1, sstate2);
500500
}
501-
cout << " ";
502501
if (m->dramEnergyMetricsAvailable()) {
502+
cout << " ";
503503
cout << setw(6) << getDRAMConsumedJoules(sstate1, sstate2);
504504
}
505-
cout << " ";
506505
if (m->LLCReadMissLatencyMetricsAvailable()) {
506+
cout << " ";
507507
cout << setw(6) << getLLCReadMissLatency(sstate1, sstate2);
508508
}
509-
cout << " ";
510509
if (m->uncoreFrequencyMetricAvailable()) {
510+
cout << " ";
511511
cout << setw(4) << getAverageUncoreFrequencyGhz(sstate1, sstate2);
512512
}
513513
cout << "\n";

0 commit comments

Comments
 (0)