Skip to content

Commit

Permalink
PerfCounters: Add support for AMD Family 15h Model 2 (Piledriver)
Browse files Browse the repository at this point in the history
Extends existing Family 15h Model 30 (Steamroller) support for
Piledriver. Piledriver supports PMCx0C4 (Retired Taken Branch
Instructions) and PMCx0C6 (Retired Far Control Transfer), just
like Model 30h. [1]

Note that PMCx0C4 counts all control flow changes, including
exceptions and interrupts. AFAICT on 15h, there is no PMC for
just retired conditional branches.

[1]: https://www.amd.com/system/files/TechDocs/42301_15h_Mod_00h-0Fh_BKDG.pdf

Tested:
1) counters-test:
   vsrinivas@ubuntu:~/tmp/rr/src/counters-test$ cc -O2 counters.c
   vsrinivas@ubuntu:~/tmp/rr/src/counters-test$ sudo ./a.out
   Ticks mismatch; got 1003, expected 1002
   Aborted

   Varying the number of volatile matches, we always see one more
   tick than expected, which I think is a RET instruction.

2) ctest:
97% tests passed, 45 tests failed out of 1425

Total Test time (real) = 3092.96 sec

The following tests FAILED:
         53 - x86/chew_cpu_cpuid-no-syscallbuf (Failed)
        110 - detach_state (Failed)
        162 - x86/fault_in_code_page (Failed)
        558 - x86/rdtsc_flags (Failed)
        724 - sioc (Failed)
        725 - sioc-no-syscallbuf (Failed)
        842 - vsyscall (Failed)
        843 - vsyscall-no-syscallbuf (Failed)
        844 - vsyscall_timeslice (Failed)
        845 - vsyscall_timeslice-no-syscallbuf (Failed)
        846 - x86/x87env (Failed)
        847 - x86/x87env-no-syscallbuf (Failed)
        888 - async_signal_syscalls (Failed)
        890 - async_signal_syscalls2 (Failed)
        910 - x86/blocked_sigsegv (Failed)
        916 - breakpoint_overlap (Failed)
        924 - checkpoint_dying_threads (Failed)
        932 - clone_interruption (Failed)
        938 - conditional_breakpoint_offload (Failed)
        939 - conditional_breakpoint_offload-no-syscallbuf (Failed)
        951 - daemon_read-no-syscallbuf (Failed)
        962 - dlopen (Failed)
        980 - exit_race (Failed)
        981 - exit_race-no-syscallbuf (Failed)
        984 - x86/explicit_checkpoints (Failed)
        1072 - x86/rdtsc_loop (Failed)
        1080 - reverse_continue_breakpoint (Failed)
        1081 - reverse_continue_breakpoint-no-syscallbuf (Failed)
        1089 - reverse_step_long-no-syscallbuf (Failed)
        1092 - reverse_step_threads_break (Failed)
        1100 - rseq_syscallbuf (Failed)
        1130 - strict_priorities (Failed)
        1131 - strict_priorities-no-syscallbuf (Failed)
        1150 - x86/syscallbuf_rdtsc_page (Failed)
        1174 - thread_open_race (Failed)
        1206 - watchpoint_at_sched (Failed)
        1208 - watchpoint_before_signal (Failed)
        1209 - watchpoint_before_signal-no-syscallbuf (Failed)
        1218 - async_signal_syscalls_100 (Failed)
        1219 - async_signal_syscalls_100-no-syscallbuf (Failed)
        1320 - record_replay (Failed)
        1321 - record_replay-no-syscallbuf (Failed)
        1354 - reverse_watchpoint_syscall (Failed)
        1418 - vsyscall_singlestep (Failed)
        1419 - vsyscall_singlestep-no-syscallbuf (Failed)
  • Loading branch information
vsrinivas committed Nov 22, 2022
1 parent f03d1c3 commit 10119d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/PerfCounters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ enum CpuMicroarch {
IntelAlderlake,
LastIntel = IntelAlderlake,
FirstAMD,
AMDF15R30 = FirstAMD,
AMDF15 = FirstAMD,
AMDZen,
LastAMD = AMDZen,
FirstARM,
Expand Down Expand Up @@ -171,7 +171,7 @@ static const PmuConfig pmu_configs[] = {
{ IntelWestmere, "Intel Westmere", 0x5101c4, 0, 0, 100, PMU_TICKS_RCB },
{ IntelPenryn, "Intel Penryn", 0, 0, 0, 100, 0 },
{ IntelMerom, "Intel Merom", 0, 0, 0, 100, 0 },
{ AMDF15R30, "AMD Family 15h Revision 30h", 0xc4, 0xc6, 0, 250, PMU_TICKS_TAKEN_BRANCHES },
{ AMDF15, "AMD Family 15h", 0xc4, 0xc6, 0, 250, PMU_TICKS_TAKEN_BRANCHES },
// 0xd1 == RETIRED_CONDITIONAL_BRANCH_INSTRUCTIONS - Number of retired conditional branch instructions
// 0x2c == INTERRUPT_TAKEN - Counts the number of interrupts taken
// Both counters are available on Zen, Zen+ and Zen2.
Expand Down
7 changes: 4 additions & 3 deletions src/PerfCounters_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ static CpuMicroarch compute_cpu_microarch() {
case 0x90670:
case 0x906a0:
return IntelAlderlake;
case 0x30f00:
return AMDF15R30;
case 0xf20: // Piledriver
case 0x30f00: // Steamroller
return AMDF15;
case 0x00f10: // Naples, Whitehaven, Summit Ridge, Snowy Owl (Zen), Milan (Zen 3) (UNTESTED)
case 0x10f10: // Raven Ridge, Great Horned Owl (Zen) (UNTESTED)
case 0x10f80: // Banded Kestrel (Zen), Picasso (Zen+) (UNTESTED)
Expand All @@ -97,7 +98,7 @@ static CpuMicroarch compute_cpu_microarch() {
if (ext_family == 8 || ext_family == 0xa) {
return AMDZen;
} else if (ext_family == 3) {
return AMDF15R30;
return AMDF15;
}
break;
case 0x20f10: // Vermeer (Zen 3)
Expand Down
11 changes: 6 additions & 5 deletions src/counters-test/counters.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef enum {
IntelAlderlake,
LastIntel = IntelAlderlake,
FirstAMD,
AMDF15R30 = FirstAMD,
AMDF15 = FirstAMD,
AMDZen,
LastAMD = AMDZen,
FirstARM,
Expand Down Expand Up @@ -126,7 +126,7 @@ static const PmuConfig pmu_configs[] = {
{ IntelWestmere, "Intel Westmere", 0x5101c4, 0, 0x50011d, 0, 100, PMU_TICKS_RCB },
{ IntelPenryn, "Intel Penryn", 0, 0, 0, 0, 100, 0 },
{ IntelMerom, "Intel Merom", 0, 0, 0, 0, 100, 0 },
{ AMDF15R30, "AMD Family 15h Revision 30h", 0xc4, 0xc6, 0, 0, 250, PMU_TICKS_TAKEN_BRANCHES },
{ AMDF15, "AMD Family 15h", 0xc4, 0xc6, 0, 0, 250, PMU_TICKS_TAKEN_BRANCHES },
// 0xd1 == RETIRED_CONDITIONAL_BRANCH_INSTRUCTIONS - Number of retired conditional branch instructions
// 0x2c == INTERRUPT_TAKEN - Counts the number of interrupts taken
// Both counters are available on Zen, Zen+ and Zen2.
Expand Down Expand Up @@ -258,8 +258,9 @@ static CpuMicroarch compute_cpu_microarch(void) {
return IntelCometlake;
case 0x90670:
return IntelAlderlake;
case 0x30f00:
return AMDF15R30;
case 0xf20: // Piledriver
case 0x30f00: // Steamroller
return AMDF15;
case 0x00f10: // Naples, Whitehaven, Summit Ridge, Snowy Owl (Zen), Milan (Zen 3) (UNTESTED)
case 0x10f10: // Raven Ridge, Great Horned Owl (Zen) (UNTESTED)
case 0x10f80: // Banded Kestrel (Zen), Picasso (Zen+) (UNTESTED)
Expand All @@ -272,7 +273,7 @@ static CpuMicroarch compute_cpu_microarch(void) {
if (ext_family == 8 || ext_family == 0xa) {
return AMDZen;
} else if (ext_family == 3) {
return AMDF15R30;
return AMDF15;
}
break;
case 0x20f10: // Vermeer (Zen 3)
Expand Down

0 comments on commit 10119d8

Please sign in to comment.