Skip to content

Commit 089134c

Browse files
Patryk Wlazlynlenb
authored andcommitted
tools/power turbostat: Extend PMT identification with a sequence number
When platforms expose multiple PMT aggregators with the same GUID, the only way to identify them and map to specific domain is by reading them in an order they were exposed via PCIe. Intel PMT kernel driver does keep the same order and numbers the telemetry directories accordingly. Use GUID and sequence number (order) to uniquely identify PMT aggregators. Signed-off-by: Patryk Wlazlyn <[email protected]> Signed-off-by: Len Brown <[email protected]>
1 parent 34537dd commit 089134c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,7 @@ static struct msr_counter_arch_info msr_counter_arch_infos[] = {
15361536
#define PMT_COUNTER_MTL_DC6_LSB 0
15371537
#define PMT_COUNTER_MTL_DC6_MSB 63
15381538
#define PMT_MTL_DC6_GUID 0x1a067102
1539+
#define PMT_MTL_DC6_SEQ 0
15391540

15401541
#define PMT_COUNTER_NAME_SIZE_BYTES 16
15411542
#define PMT_COUNTER_TYPE_NAME_SIZE_BYTES 32
@@ -9083,14 +9084,19 @@ void *pmt_get_counter_pointer(struct pmt_mmio *pmmio, unsigned long counter_offs
90839084
return ret;
90849085
}
90859086

9086-
struct pmt_mmio *pmt_add_guid(unsigned int guid)
9087+
struct pmt_mmio *pmt_add_guid(unsigned int guid, unsigned int seq)
90879088
{
90889089
struct pmt_mmio *ret;
90899090

90909091
ret = pmt_mmio_find(guid);
90919092
if (!ret)
90929093
ret = pmt_mmio_open(guid);
90939094

9095+
while (ret && seq) {
9096+
ret = ret->next;
9097+
--seq;
9098+
}
9099+
90949100
return ret;
90959101
}
90969102

@@ -9137,7 +9143,7 @@ void pmt_counter_add_domain(struct pmt_counter *pcounter, unsigned long *pmmio,
91379143
pcounter->domains[domain_id].pcounter = pmmio;
91389144
}
91399145

9140-
int pmt_add_counter(unsigned int guid, const char *name, enum pmt_datatype type,
9146+
int pmt_add_counter(unsigned int guid, unsigned int seq, const char *name, enum pmt_datatype type,
91419147
unsigned int lsb, unsigned int msb, unsigned int offset, enum counter_scope scope,
91429148
enum counter_format format, unsigned int domain_id, enum pmt_open_mode mode)
91439149
{
@@ -9157,10 +9163,10 @@ int pmt_add_counter(unsigned int guid, const char *name, enum pmt_datatype type,
91579163
exit(1);
91589164
}
91599165

9160-
mmio = pmt_add_guid(guid);
9166+
mmio = pmt_add_guid(guid, seq);
91619167
if (!mmio) {
91629168
if (mode != PMT_OPEN_TRY) {
9163-
fprintf(stderr, "%s: failed to map PMT MMIO for guid %x\n", __func__, guid);
9169+
fprintf(stderr, "%s: failed to map PMT MMIO for guid %x, seq %u\n", __func__, guid, seq);
91649170
exit(1);
91659171
}
91669172

@@ -9216,9 +9222,9 @@ int pmt_add_counter(unsigned int guid, const char *name, enum pmt_datatype type,
92169222
void pmt_init(void)
92179223
{
92189224
if (BIC_IS_ENABLED(BIC_Diec6)) {
9219-
pmt_add_counter(PMT_MTL_DC6_GUID, "Die%c6", PMT_TYPE_XTAL_TIME, PMT_COUNTER_MTL_DC6_LSB,
9220-
PMT_COUNTER_MTL_DC6_MSB, PMT_COUNTER_MTL_DC6_OFFSET, SCOPE_PACKAGE, FORMAT_DELTA,
9221-
0, PMT_OPEN_TRY);
9225+
pmt_add_counter(PMT_MTL_DC6_GUID, PMT_MTL_DC6_SEQ, "Die%c6", PMT_TYPE_XTAL_TIME,
9226+
PMT_COUNTER_MTL_DC6_LSB, PMT_COUNTER_MTL_DC6_MSB, PMT_COUNTER_MTL_DC6_OFFSET,
9227+
SCOPE_PACKAGE, FORMAT_DELTA, 0, PMT_OPEN_TRY);
92229228
}
92239229
}
92249230

@@ -9699,6 +9705,7 @@ void parse_add_command_pmt(char *add_command)
96999705
unsigned int lsb;
97009706
unsigned int msb;
97019707
unsigned int guid;
9708+
unsigned int seq = 0; /* By default, pick first file in a sequence with a given GUID. */
97029709
unsigned int domain_id;
97039710
enum counter_scope scope = 0;
97049711
enum pmt_datatype type = PMT_TYPE_RAW;
@@ -9778,6 +9785,10 @@ void parse_add_command_pmt(char *add_command)
97789785
goto next;
97799786
}
97809787

9788+
if (sscanf(add_command, "seq=%x", &seq) == 1) {
9789+
goto next;
9790+
}
9791+
97819792
next:
97829793
add_command = strchr(add_command, ',');
97839794
if (add_command) {
@@ -9864,7 +9875,7 @@ void parse_add_command_pmt(char *add_command)
98649875
exit(1);
98659876
}
98669877

9867-
pmt_add_counter(guid, name, type, lsb, msb, offset, scope, format, domain_id, PMT_OPEN_REQUIRED);
9878+
pmt_add_counter(guid, seq, name, type, lsb, msb, offset, scope, format, domain_id, PMT_OPEN_REQUIRED);
98689879
}
98699880

98709881
void parse_add_command(char *add_command)

0 commit comments

Comments
 (0)