Skip to content

Commit

Permalink
tools/power turbostat: Add tcore clock PMT type
Browse files Browse the repository at this point in the history
Some PMT counters, for example module c1e residency on Intel Clearwater
Forest, are reported using tcore clock type.

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Patryk Wlazlyn authored and lenb committed Jan 27, 2025
1 parent a80e534 commit 1a202af
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,8 @@ static struct msr_counter_arch_info msr_counter_arch_infos[] = {
#define PMT_MTL_DC6_GUID 0x1a067102
#define PMT_MTL_DC6_SEQ 0

unsigned long long tcore_clock_freq_hz = 800000000;

#define PMT_COUNTER_NAME_SIZE_BYTES 16
#define PMT_COUNTER_TYPE_NAME_SIZE_BYTES 32

Expand All @@ -1560,6 +1562,7 @@ struct pmt_mmio {
enum pmt_datatype {
PMT_TYPE_RAW,
PMT_TYPE_XTAL_TIME,
PMT_TYPE_TCORE_CLOCK,
};

struct pmt_domain_info {
Expand Down Expand Up @@ -2474,6 +2477,7 @@ void print_header(char *delim)
break;

case PMT_TYPE_XTAL_TIME:
case PMT_TYPE_TCORE_CLOCK:
outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), ppmt->name);
break;
}
Expand Down Expand Up @@ -2548,6 +2552,7 @@ void print_header(char *delim)
break;

case PMT_TYPE_XTAL_TIME:
case PMT_TYPE_TCORE_CLOCK:
outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), ppmt->name);
break;
}
Expand Down Expand Up @@ -2679,6 +2684,7 @@ void print_header(char *delim)
break;

case PMT_TYPE_XTAL_TIME:
case PMT_TYPE_TCORE_CLOCK:
outp += sprintf(outp, "%s%s", (printed++ ? delim : ""), ppmt->name);
break;
}
Expand Down Expand Up @@ -2997,7 +3003,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data

for (i = 0, ppmt = sys.pmt_tp; ppmt; i++, ppmt = ppmt->next) {
const unsigned long value_raw = t->pmt_counter[i];
const double value_converted = 100.0 * value_raw / crystal_hz / interval_float;
double value_converted;
switch (ppmt->type) {
case PMT_TYPE_RAW:
if (pmt_counter_get_width(ppmt) <= 32)
Expand All @@ -3009,8 +3015,13 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
break;

case PMT_TYPE_XTAL_TIME:
value_converted = 100.0 * value_raw / crystal_hz / interval_float;
outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted);
break;

case PMT_TYPE_TCORE_CLOCK:
value_converted = 100.0 * value_raw / tcore_clock_freq_hz / interval_float;
outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted);
}
}

Expand Down Expand Up @@ -3077,7 +3088,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data

for (i = 0, ppmt = sys.pmt_cp; ppmt; i++, ppmt = ppmt->next) {
const unsigned long value_raw = c->pmt_counter[i];
const double value_converted = 100.0 * value_raw / crystal_hz / interval_float;
double value_converted;
switch (ppmt->type) {
case PMT_TYPE_RAW:
if (pmt_counter_get_width(ppmt) <= 32)
Expand All @@ -3089,8 +3100,13 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
break;

case PMT_TYPE_XTAL_TIME:
value_converted = 100.0 * value_raw / crystal_hz / interval_float;
outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted);
break;

case PMT_TYPE_TCORE_CLOCK:
value_converted = 100.0 * value_raw / tcore_clock_freq_hz / interval_float;
outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted);
}
}

Expand Down Expand Up @@ -3275,7 +3291,7 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data

for (i = 0, ppmt = sys.pmt_pp; ppmt; i++, ppmt = ppmt->next) {
const unsigned long value_raw = p->pmt_counter[i];
const double value_converted = 100.0 * value_raw / crystal_hz / interval_float;
double value_converted;
switch (ppmt->type) {
case PMT_TYPE_RAW:
if (pmt_counter_get_width(ppmt) <= 32)
Expand All @@ -3287,8 +3303,13 @@ int format_counters(struct thread_data *t, struct core_data *c, struct pkg_data
break;

case PMT_TYPE_XTAL_TIME:
value_converted = 100.0 * value_raw / crystal_hz / interval_float;
outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted);
break;

case PMT_TYPE_TCORE_CLOCK:
value_converted = 100.0 * value_raw / tcore_clock_freq_hz / interval_float;
outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""), value_converted);
}
}

Expand Down Expand Up @@ -10016,6 +10037,11 @@ void parse_add_command_pmt(char *add_command)
has_type = true;
}

if (strcmp("tcore_clock", type_name) == 0) {
type = PMT_TYPE_TCORE_CLOCK;
has_type = true;
}

if (!has_type) {
printf("%s: invalid %s: %s\n", __func__, "type", type_name);
exit(1);
Expand Down

0 comments on commit 1a202af

Please sign in to comment.