Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf, x86: Share IBS macros between perf and oprofile

Moving IBS macros from oprofile to <asm/perf_event.h> to make it
available to perf. No additional changes.

Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1316597423-25723-2-git-send-email-robert.richter@amd.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Robert Richter and committed by
Ingo Molnar
ee5789db efc3aac5

+40 -39
+35 -3
arch/x86/include/asm/perf_event.h
··· 46 46 #define AMD64_RAW_EVENT_MASK \ 47 47 (X86_RAW_EVENT_MASK | \ 48 48 AMD64_EVENTSEL_EVENT) 49 + #define AMD64_NUM_COUNTERS 4 50 + #define AMD64_NUM_COUNTERS_F15H 6 51 + #define AMD64_NUM_COUNTERS_MAX AMD64_NUM_COUNTERS_F15H 49 52 50 - #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c 53 + #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c 51 54 #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) 52 - #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX 0 55 + #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX 0 53 56 #define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT \ 54 57 (1 << (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX)) 55 58 56 - #define ARCH_PERFMON_BRANCH_MISSES_RETIRED 6 59 + #define ARCH_PERFMON_BRANCH_MISSES_RETIRED 6 57 60 58 61 /* 59 62 * Intel "Architectural Performance Monitoring" CPUID ··· 115 112 * to indicate other overflow conditions in the PERF_GLOBAL_STATUS msr. 116 113 */ 117 114 #define X86_PMC_IDX_FIXED_BTS (X86_PMC_IDX_FIXED + 16) 115 + 116 + /* 117 + * IBS cpuid feature detection 118 + */ 119 + 120 + #define IBS_CPUID_FEATURES 0x8000001b 121 + 122 + /* 123 + * Same bit mask as for IBS cpuid feature flags (Fn8000_001B_EAX), but 124 + * bit 0 is used to indicate the existence of IBS. 125 + */ 126 + #define IBS_CAPS_AVAIL (1U<<0) 127 + #define IBS_CAPS_FETCHSAM (1U<<1) 128 + #define IBS_CAPS_OPSAM (1U<<2) 129 + #define IBS_CAPS_RDWROPCNT (1U<<3) 130 + #define IBS_CAPS_OPCNT (1U<<4) 131 + #define IBS_CAPS_BRNTRGT (1U<<5) 132 + #define IBS_CAPS_OPCNTEXT (1U<<6) 133 + 134 + #define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \ 135 + | IBS_CAPS_FETCHSAM \ 136 + | IBS_CAPS_OPSAM) 137 + 138 + /* 139 + * IBS APIC setup 140 + */ 141 + #define IBSCTL 0x1cc 142 + #define IBSCTL_LVT_OFFSET_VALID (1ULL<<8) 143 + #define IBSCTL_LVT_OFFSET_MASK 0x0F 118 144 119 145 /* IbsFetchCtl bits/masks */ 120 146 #define IBS_FETCH_RAND_EN (1ULL<<57)
+2 -2
arch/x86/kernel/cpu/perf_event_amd.c
··· 411 411 .perfctr = MSR_K7_PERFCTR0, 412 412 .event_map = amd_pmu_event_map, 413 413 .max_events = ARRAY_SIZE(amd_perfmon_event_map), 414 - .num_counters = 4, 414 + .num_counters = AMD64_NUM_COUNTERS, 415 415 .cntval_bits = 48, 416 416 .cntval_mask = (1ULL << 48) - 1, 417 417 .apic = 1, ··· 575 575 .perfctr = MSR_F15H_PERF_CTR, 576 576 .event_map = amd_pmu_event_map, 577 577 .max_events = ARRAY_SIZE(amd_perfmon_event_map), 578 - .num_counters = 6, 578 + .num_counters = AMD64_NUM_COUNTERS_F15H, 579 579 .cntval_bits = 48, 580 580 .cntval_mask = (1ULL << 48) - 1, 581 581 .apic = 1,
+3 -34
arch/x86/oprofile/op_model_amd.c
··· 29 29 #include "op_x86_model.h" 30 30 #include "op_counter.h" 31 31 32 - #define NUM_COUNTERS 4 33 - #define NUM_COUNTERS_F15H 6 34 32 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX 35 33 #define NUM_VIRT_COUNTERS 32 36 34 #else ··· 66 68 67 69 static struct ibs_config ibs_config; 68 70 static struct ibs_state ibs_state; 69 - 70 - /* 71 - * IBS cpuid feature detection 72 - */ 73 - 74 - #define IBS_CPUID_FEATURES 0x8000001b 75 - 76 - /* 77 - * Same bit mask as for IBS cpuid feature flags (Fn8000_001B_EAX), but 78 - * bit 0 is used to indicate the existence of IBS. 79 - */ 80 - #define IBS_CAPS_AVAIL (1U<<0) 81 - #define IBS_CAPS_FETCHSAM (1U<<1) 82 - #define IBS_CAPS_OPSAM (1U<<2) 83 - #define IBS_CAPS_RDWROPCNT (1U<<3) 84 - #define IBS_CAPS_OPCNT (1U<<4) 85 - #define IBS_CAPS_BRNTRGT (1U<<5) 86 - #define IBS_CAPS_OPCNTEXT (1U<<6) 87 - 88 - #define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \ 89 - | IBS_CAPS_FETCHSAM \ 90 - | IBS_CAPS_OPSAM) 91 - 92 - /* 93 - * IBS APIC setup 94 - */ 95 - #define IBSCTL 0x1cc 96 - #define IBSCTL_LVT_OFFSET_VALID (1ULL<<8) 97 - #define IBSCTL_LVT_OFFSET_MASK 0x0F 98 71 99 72 /* 100 73 * IBS randomization macros ··· 408 439 goto fail; 409 440 } 410 441 /* both registers must be reserved */ 411 - if (num_counters == NUM_COUNTERS_F15H) { 442 + if (num_counters == AMD64_NUM_COUNTERS_F15H) { 412 443 msrs->counters[i].addr = MSR_F15H_PERF_CTR + (i << 1); 413 444 msrs->controls[i].addr = MSR_F15H_PERF_CTL + (i << 1); 414 445 } else { ··· 710 741 ops->create_files = setup_ibs_files; 711 742 712 743 if (boot_cpu_data.x86 == 0x15) { 713 - num_counters = NUM_COUNTERS_F15H; 744 + num_counters = AMD64_NUM_COUNTERS_F15H; 714 745 } else { 715 - num_counters = NUM_COUNTERS; 746 + num_counters = AMD64_NUM_COUNTERS; 716 747 } 717 748 718 749 op_amd_spec.num_counters = num_counters;