Skip to content

Commit aaf2488

Browse files
huangruiIngo Molnar
authored and
Ingo Molnar
committed
perf/x86/msr: Add AMD IRPERF (Instructions Retired) performance counter
AMD Zeppelin (Family 17h, Model 00h) introduces an instructions retired performance counter which is indicated by CPUID.8000_0008H:EBX[1]. A dedicated Instructions Retired MSR register (MSR 0xC000_000E9) increments once for every instruction retired. Signed-off-by: Huang Rui <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Aravind Gopalakrishnan <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Fengguang Wu <[email protected]> Cc: Jacob Shin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Robert Richter <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Suravee Suthikulpanit <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 8a22426 commit aaf2488

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

arch/x86/events/msr.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ enum perf_msr_id {
77
PERF_MSR_PPERF = 3,
88
PERF_MSR_SMI = 4,
99
PERF_MSR_PTSC = 5,
10+
PERF_MSR_IRPERF = 6,
1011

1112
PERF_MSR_EVENT_MAX,
1213
};
@@ -21,6 +22,11 @@ static bool test_ptsc(int idx)
2122
return boot_cpu_has(X86_FEATURE_PTSC);
2223
}
2324

25+
static bool test_irperf(int idx)
26+
{
27+
return boot_cpu_has(X86_FEATURE_IRPERF);
28+
}
29+
2430
static bool test_intel(int idx)
2531
{
2632
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
@@ -75,20 +81,22 @@ struct perf_msr {
7581
bool (*test)(int idx);
7682
};
7783

78-
PMU_EVENT_ATTR_STRING(tsc, evattr_tsc, "event=0x00");
79-
PMU_EVENT_ATTR_STRING(aperf, evattr_aperf, "event=0x01");
80-
PMU_EVENT_ATTR_STRING(mperf, evattr_mperf, "event=0x02");
81-
PMU_EVENT_ATTR_STRING(pperf, evattr_pperf, "event=0x03");
82-
PMU_EVENT_ATTR_STRING(smi, evattr_smi, "event=0x04");
83-
PMU_EVENT_ATTR_STRING(ptsc, evattr_ptsc, "event=0x05");
84+
PMU_EVENT_ATTR_STRING(tsc, evattr_tsc, "event=0x00");
85+
PMU_EVENT_ATTR_STRING(aperf, evattr_aperf, "event=0x01");
86+
PMU_EVENT_ATTR_STRING(mperf, evattr_mperf, "event=0x02");
87+
PMU_EVENT_ATTR_STRING(pperf, evattr_pperf, "event=0x03");
88+
PMU_EVENT_ATTR_STRING(smi, evattr_smi, "event=0x04");
89+
PMU_EVENT_ATTR_STRING(ptsc, evattr_ptsc, "event=0x05");
90+
PMU_EVENT_ATTR_STRING(irperf, evattr_irperf, "event=0x06");
8491

8592
static struct perf_msr msr[] = {
86-
[PERF_MSR_TSC] = { 0, &evattr_tsc, NULL, },
87-
[PERF_MSR_APERF] = { MSR_IA32_APERF, &evattr_aperf, test_aperfmperf, },
88-
[PERF_MSR_MPERF] = { MSR_IA32_MPERF, &evattr_mperf, test_aperfmperf, },
89-
[PERF_MSR_PPERF] = { MSR_PPERF, &evattr_pperf, test_intel, },
90-
[PERF_MSR_SMI] = { MSR_SMI_COUNT, &evattr_smi, test_intel, },
93+
[PERF_MSR_TSC] = { 0, &evattr_tsc, NULL, },
94+
[PERF_MSR_APERF] = { MSR_IA32_APERF, &evattr_aperf, test_aperfmperf, },
95+
[PERF_MSR_MPERF] = { MSR_IA32_MPERF, &evattr_mperf, test_aperfmperf, },
96+
[PERF_MSR_PPERF] = { MSR_PPERF, &evattr_pperf, test_intel, },
97+
[PERF_MSR_SMI] = { MSR_SMI_COUNT, &evattr_smi, test_intel, },
9198
[PERF_MSR_PTSC] = { MSR_F15H_PTSC, &evattr_ptsc, test_ptsc, },
99+
[PERF_MSR_IRPERF] = { MSR_F17H_IRPERF, &evattr_irperf, test_irperf, },
92100
};
93101

94102
static struct attribute *events_attrs[PERF_MSR_EVENT_MAX + 1] = {

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251

252252
/* AMD-defined CPU features, CPUID level 0x80000008 (ebx), word 13 */
253253
#define X86_FEATURE_CLZERO (13*32+0) /* CLZERO instruction */
254+
#define X86_FEATURE_IRPERF (13*32+1) /* Instructions Retired Count */
254255

255256
/* Thermal and Power Management Leaf, CPUID level 0x00000006 (eax), word 14 */
256257
#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */

arch/x86/include/asm/msr-index.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@
313313
#define MSR_AMD64_IBSOPDATA4 0xc001103d
314314
#define MSR_AMD64_IBS_REG_COUNT_MAX 8 /* includes MSR_AMD64_IBSBRTARGET */
315315

316+
/* Fam 17h MSRs */
317+
#define MSR_F17H_IRPERF 0xc00000e9
318+
316319
/* Fam 16h MSRs */
317320
#define MSR_F16H_L2I_PERF_CTL 0xc0010230
318321
#define MSR_F16H_L2I_PERF_CTR 0xc0010231

0 commit comments

Comments
 (0)