// SPDX-License-Identifier: GPL-2.0 /* * local apic based NMI watchdog for various CPUs. * * This file also handles reservation of performance counters for coordination * with other users (like oprofile). * * Note that these events normally don't tick when the CPU idles. This means * the frequency varies with CPU load. * * Original code for K7/P6 written by Keith Owens * */ #include <linux/percpu.h> #include <linux/export.h> #include <linux/kernel.h> #include <linux/bitops.h> #include <linux/smp.h> #include <asm/nmi.h> #include <linux/kprobes.h> #include <asm/apic.h> #include <asm/perf_event.h> /* * this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's * offset from MSR_P4_BSU_ESCR0. * * It will be the max for all platforms (for now) */ #define NMI_MAX_COUNTER_BITS 66 /* * perfctr_nmi_owner tracks the ownership of the perfctr registers: * evtsel_nmi_owner tracks the ownership of the event selection * - different performance counters/ event selection may be reserved for * different subsystems this reservation system just tries to coordinate * things a little */ static DECLARE_BITMAP(perfctr_nmi_owner, NMI_MAX_COUNTER_BITS); static DECLARE_BITMAP(evntsel_nmi_owner, NMI_MAX_COUNTER_BITS); /* converts an msr to an appropriate reservation bit */
static inline unsigned int nmi_perfctr_msr_to_bit(unsigned int msr) { /* returns the bit offset of the performance counter register */ switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_AMD: if (msr >= MSR_F15H_PERF_CTR) return (msr - MSR_F15H_PERF_CTR) >> 1; return msr - MSR_K7_PERFCTR0; case X86_VENDOR_INTEL: if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) return msr - MSR_ARCH_PERFMON_PERFCTR0; switch (boot_cpu_data.x86) { case 6: return msr - MSR_P6_PERFCTR0; case 11: return msr - MSR_KNC_PERFCTR0; case 15: return msr - MSR_P4_BPU_PERFCTR0; } } return 0; }Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 74 | 76.29% | 2 | 50.00% |
Robert Richter | 15 | 15.46% | 1 | 25.00% |
Vince Weaver | 8 | 8.25% | 1 | 25.00% |
Total | 97 | 100.00% | 4 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 74 | 76.29% | 2 | 50.00% |
Robert Richter | 15 | 15.46% | 1 | 25.00% |
Vince Weaver | 8 | 8.25% | 1 | 25.00% |
Total | 97 | 100.00% | 4 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 39 | 84.78% | 1 | 50.00% |
Stéphane Eranian | 7 | 15.22% | 1 | 50.00% |
Total | 46 | 100.00% | 2 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 30 | 85.71% | 1 | 50.00% |
Stéphane Eranian | 5 | 14.29% | 1 | 50.00% |
Total | 35 | 100.00% | 2 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 39 | 84.78% | 1 | 50.00% |
Stéphane Eranian | 7 | 15.22% | 1 | 50.00% |
Total | 46 | 100.00% | 2 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 30 | 85.71% | 1 | 50.00% |
Stéphane Eranian | 5 | 14.29% | 1 | 50.00% |
Total | 35 | 100.00% | 2 | 100.00% |
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 359 | 78.04% | 2 | 18.18% |
Robert Richter | 30 | 6.52% | 1 | 9.09% |
Stéphane Eranian | 24 | 5.22% | 1 | 9.09% |
Cyrill V. Gorcunov | 24 | 5.22% | 1 | 9.09% |
Vince Weaver | 16 | 3.48% | 1 | 9.09% |
Ingo Molnar | 4 | 0.87% | 2 | 18.18% |
Greg Kroah-Hartman | 1 | 0.22% | 1 | 9.09% |
Paul Gortmaker | 1 | 0.22% | 1 | 9.09% |
Don Zickus | 1 | 0.22% | 1 | 9.09% |
Total | 460 | 100.00% | 11 | 100.00% |