projects/linux·commit 2eafeb6a

Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

2eafeb6a · Linus Torvalds <[email protected]> · 2012-07-22 11:10:36 -07:00

Pull perf events changes from Ingo Molnar:

 "- kernel side:

   - Intel uncore PMU support for Nehalem and Sandy Bridge CPUs, we
     support both the events available via the MSR and via the PCI
     access space.

   - various uprobes cleanups and restructurings

   - PMU driver quirks by microcode version and required x86 microcode
     loader cleanups/robustization

   - various tracing robustness updates

   - static keys: remove obsolete static_branch()

  - tooling side:

   - GTK browser improvements

   - perf report browser: support screenshots to file

   - more automated tests

   - perf kvm improvements

   - perf bench refinements

   - build environment improvements

   - pipe mode improvements

   - libtraceevent updates, we have now hopefully merged most bits with
     the out of tree forked code base

  ... and many other goodies."

* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (138 commits)
  tracing: Check for allocation failure in __tracing_open()
  perf/x86: Fix intel_perfmon_event_mapformatting
  jump label: Remove static_branch()
  tracepoint: Use static_key_false(), since static_branch() is deprecated
  perf/x86: Uncore filter support for SandyBridge-EP
  perf/x86: Detect number of instances of uncore CBox
  perf/x86: Fix event constraint for SandyBridge-EP C-Box
  perf/x86: Use 0xff as pseudo code for fixed uncore event
  perf/x86: Save a few bytes in 'struct x86_pmu'
  perf/x86: Add a microcode revision check for SNB-PEBS
  perf/x86: Improve debug output in check_hw_exists()
  perf/x86/amd: Unify AMD's generic and family 15h pmus
  perf/x86: Move Intel specific code to intel_pmu_init()
  perf/x86: Rename Intel specific macros
  perf/x86: Fix USER/KERNEL tagging of samples
  perf tools: Split event symbols arrays to hw and sw parts
  perf tools: Split out PE_VALUE_SYM parsing token to SW and HW tokens
  perf tools: Add empty rule for new line in event syntax parsing
  perf test: Use ARRAY_SIZE in parse events tests
  tools lib traceevent: Cleanup realloc use
  ...
Commit
2eafeb6a415864bc4c59df79151cf40f6ac74b9e
Parents
16d286e6 · 6e0f17be

Merge commit. Changes below are compared with the first parent: 16d286e6.

Changes

109 files changed · +5782 −1706

FileStatusAddDelContent
arch/x86/include/asm/kvm_host.hmodified+2−2View file
arch/x86/include/asm/msr.hmodified+5−41View file
arch/x86/include/asm/paravirt.hmodified+2−39View file
arch/x86/include/asm/paravirt_types.hmodified+0−2View file
arch/x86/include/asm/perf_event.hmodified+11−11View file
arch/x86/include/asm/uprobes.hmodified+1−1View file
arch/x86/kernel/cpu/Makefilemodified+3−1View file
arch/x86/kernel/cpu/amd.cmodified+36−3View file
arch/x86/kernel/cpu/common.cmodified+1−1View file
arch/x86/kernel/cpu/perf_event.cmodified+43−68View file
arch/x86/kernel/cpu/perf_event.hmodified+23−3View file
arch/x86/kernel/cpu/perf_event_amd.cmodified+46−57View file
arch/x86/kernel/cpu/perf_event_intel.cmodified+101−21View file
arch/x86/kernel/cpu/perf_event_intel_ds.cmodified+6−6View file
arch/x86/kernel/cpu/perf_event_intel_uncore.cadded+1850−0View file
arch/x86/kernel/cpu/perf_event_intel_uncore.hadded+424−0View file
arch/x86/kernel/cpu/perf_event_p4.cmodified+8−8View file
arch/x86/kernel/cpu/perf_event_p6.cmodified+2−2View file
arch/x86/kernel/microcode_core.cmodified+50−14View file
arch/x86/kernel/paravirt.cmodified+0−2View file
arch/x86/kernel/process_64.cmodified+2−2View file
arch/x86/kernel/uprobes.cmodified+2−1View file
arch/x86/kvm/pmu.cmodified+11−11View file
arch/x86/kvm/trace.hmodified+1−11View file
arch/x86/lib/msr-reg-export.cmodified+2−2View file
arch/x86/lib/msr-reg.Smodified+5−5View file
arch/x86/oprofile/op_model_amd.cmodified+2−2View file
arch/x86/vdso/vdso32-setup.cmodified+3−3View file
arch/x86/xen/enlighten.cmodified+0−2View file
drivers/oprofile/oprofile_perf.cmodified+11−12View file
include/linux/ftrace_event.hmodified+4−1View file
include/linux/jump_label.hmodified+1−16View file
include/linux/pci_ids.hmodified+11−0View file
include/linux/perf_event.hmodified+3−0View file
include/linux/sched.hmodified+0−1View file
include/linux/tracepoint.hmodified+1−1View file
include/trace/ftrace.hmodified+1−0View file
kernel/events/core.cmodified+45−4View file
kernel/events/uprobes.cmodified+228−233View file
kernel/trace/ftrace.cmodified+2−6View file
kernel/trace/ring_buffer.cmodified+4−0View file
kernel/trace/trace.cmodified+24−9View file
kernel/trace/trace.hmodified+8−0View file
kernel/trace/trace_functions_graph.cmodified+1−1View file
kernel/trace/trace_output.cmodified+1−1View file
tools/lib/traceevent/Makefilemodified+10−4View file
tools/lib/traceevent/event-parse.cmodified+295−104View file
tools/lib/traceevent/event-parse.hmodified+7−0View file
tools/lib/traceevent/parse-filter.cmodified+57−29View file
tools/perf/Documentation/perf-bench.txtmodified+75−3View file
tools/perf/Documentation/perf-report.txtmodified+1−1View file
tools/perf/Documentation/perf-top.txtmodified+1−1View file
tools/perf/Makefilemodified+7−1View file
tools/perf/bench/mem-memcpy.cmodified+42−42View file
tools/perf/bench/mem-memset.cmodified+44−44View file
tools/perf/builtin-bench.cmodified+2−2View file
tools/perf/builtin-evlist.cmodified+1−1View file
tools/perf/builtin-kmem.cmodified+25−12View file
tools/perf/builtin-lock.cmodified+2−2View file
tools/perf/builtin-record.cmodified+2−2View file
tools/perf/builtin-report.cmodified+9−7View file
tools/perf/builtin-sched.cmodified+26−12View file
tools/perf/builtin-script.cmodified+65−41View file
tools/perf/builtin-stat.cmodified+6−6View file
tools/perf/builtin-test.cmodified+1−1View file
tools/perf/builtin-top.cmodified+6−6View file
tools/perf/config/feature-tests.makmodified+13−0View file
tools/perf/ui/browsers/annotate.cmodified+3−1View file
tools/perf/ui/browsers/hists.cmodified+199−11View file
tools/perf/ui/gtk/browser.cmodified+66−3View file
tools/perf/ui/gtk/gtk.hmodified+31−0View file
tools/perf/ui/gtk/setup.cmodified+5−0View file
tools/perf/ui/gtk/util.cadded+129−0View file
tools/perf/ui/tui/setup.cmodified+6−0View file
tools/perf/ui/tui/util.cadded+243−0View file
tools/perf/ui/util.cmodified+56−221View file
tools/perf/ui/util.hmodified+8−1View file
tools/perf/util/debug.cmodified+1−1View file
tools/perf/util/debug.hmodified+20−3View file
tools/perf/util/evlist.cmodified+2−2View file
tools/perf/util/evlist.hmodified+3−0View file
tools/perf/util/evsel.cmodified+199−28View file
tools/perf/util/evsel.hmodified+13−2View file
tools/perf/util/header.cmodified+18−15View file
tools/perf/util/hist.hmodified+1−0View file
tools/perf/util/include/linux/kernel.hmodified+10−0View file
tools/perf/util/map.hmodified+1−1View file
tools/perf/util/parse-events-test.cmodified+165−14View file
tools/perf/util/parse-events.cmodified+208−262View file
tools/perf/util/parse-events.hmodified+13−4View file
tools/perf/util/parse-events.lmodified+83−51View file
tools/perf/util/parse-events.ymodified+63−23View file
tools/perf/util/pmu.cmodified+168−1View file
tools/perf/util/pmu.hmodified+10−1View file
tools/perf/util/scripting-engines/trace-event-perl.cmodified+20−12View file
tools/perf/util/scripting-engines/trace-event-python.cmodified+16−9View file
tools/perf/util/session.cmodified+60−5View file
tools/perf/util/session.hmodified+12−2View file
tools/perf/util/sort.cmodified+49−0View file
tools/perf/util/sort.hmodified+2−0View file
tools/perf/util/string.cmodified+22−0View file
tools/perf/util/symbol.cmodified+87−7View file
tools/perf/util/symbol.hmodified+1−0View file
tools/perf/util/top.cmodified+1−1View file
tools/perf/util/trace-event-parse.cmodified+26−32View file
tools/perf/util/trace-event-read.cmodified+50−47View file
tools/perf/util/trace-event-scripting.cmodified+5−2View file
tools/perf/util/trace-event.hmodified+21−17View file
tools/perf/util/util.hmodified+2−0View file

Only the first 600 diff lines are shown. Download the complete patch.

arch/x86/include/asm/kvm_host.h

View file
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index db7c1f2..2da88c0 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -313,8 +313,8 @@ struct kvm_pmu {
u64 counter_bitmask[2];
u64 global_ctrl_mask;
u8 version;
- struct kvm_pmc gp_counters[X86_PMC_MAX_GENERIC];
- struct kvm_pmc fixed_counters[X86_PMC_MAX_FIXED];
+ struct kvm_pmc gp_counters[INTEL_PMC_MAX_GENERIC];
+ struct kvm_pmc fixed_counters[INTEL_PMC_MAX_FIXED];
struct irq_work irq_work;
u64 reprogram_pmi;
};

arch/x86/include/asm/msr.h

View file
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index 084ef95..813ed10 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h
@@ -115,8 +115,8 @@ notrace static inline int native_write_msr_safe(unsigned int msr,
extern unsigned long long native_read_tsc(void);
-extern int native_rdmsr_safe_regs(u32 regs[8]);
-extern int native_wrmsr_safe_regs(u32 regs[8]);
+extern int rdmsr_safe_regs(u32 regs[8]);
+extern int wrmsr_safe_regs(u32 regs[8]);
static __always_inline unsigned long long __native_read_tsc(void)
{
@@ -187,43 +187,6 @@ static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
return err;
}
-static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
-{
- u32 gprs[8] = { 0 };
- int err;
-
- gprs[1] = msr;
- gprs[7] = 0x9c5a203a;
-
- err = native_rdmsr_safe_regs(gprs);
-
- *p = gprs[0] | ((u64)gprs[2] << 32);
-
- return err;
-}
-
-static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
-{
- u32 gprs[8] = { 0 };
-
- gprs[0] = (u32)val;
- gprs[1] = msr;
- gprs[2] = val >> 32;
- gprs[7] = 0x9c5a203a;
-
- return native_wrmsr_safe_regs(gprs);
-}
-
-static inline int rdmsr_safe_regs(u32 regs[8])
-{
- return native_rdmsr_safe_regs(regs);
-}
-
-static inline int wrmsr_safe_regs(u32 regs[8])
-{
- return native_wrmsr_safe_regs(regs);
-}
-
#define rdtscl(low) \
((low) = (u32)__native_read_tsc())
@@ -237,6 +200,8 @@ do { \
(high) = (u32)(_l >> 32); \
} while (0)
+#define rdpmcl(counter, val) ((val) = native_read_pmc(counter))
+
#define rdtscp(low, high, aux) \
do { \
unsigned long long _val = native_read_tscp(&(aux)); \
@@ -248,8 +213,7 @@ do { \
#endif /* !CONFIG_PARAVIRT */
-
-#define checking_wrmsrl(msr, val) wrmsr_safe((msr), (u32)(val), \
+#define wrmsrl_safe(msr, val) wrmsr_safe((msr), (u32)(val), \
(u32)((val) >> 32))
#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2))

arch/x86/include/asm/paravirt.h

View file
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 6cbbabf..0b47ddb 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -128,21 +128,11 @@ static inline u64 paravirt_read_msr(unsigned msr, int *err)
return PVOP_CALL2(u64, pv_cpu_ops.read_msr, msr, err);
}
-static inline int paravirt_rdmsr_regs(u32 *regs)
-{
- return PVOP_CALL1(int, pv_cpu_ops.rdmsr_regs, regs);
-}
-
static inline int paravirt_write_msr(unsigned msr, unsigned low, unsigned high)
{
return PVOP_CALL3(int, pv_cpu_ops.write_msr, msr, low, high);
}
-static inline int paravirt_wrmsr_regs(u32 *regs)
-{
- return PVOP_CALL1(int, pv_cpu_ops.wrmsr_regs, regs);
-}
-
/* These should all do BUG_ON(_err), but our headers are too tangled. */
#define rdmsr(msr, val1, val2) \
do { \
@@ -176,9 +166,6 @@ do { \
_err; \
})
-#define rdmsr_safe_regs(regs) paravirt_rdmsr_regs(regs)
-#define wrmsr_safe_regs(regs) paravirt_wrmsr_regs(regs)
-
static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
{
int err;
@@ -186,32 +173,6 @@ static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
*p = paravirt_read_msr(msr, &err);
return err;
}
-static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
-{
- u32 gprs[8] = { 0 };
- int err;
-
- gprs[1] = msr;
- gprs[7] = 0x9c5a203a;
-
- err = paravirt_rdmsr_regs(gprs);
-
- *p = gprs[0] | ((u64)gprs[2] << 32);
-
- return err;
-}
-
-static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
-{
- u32 gprs[8] = { 0 };
-
- gprs[0] = (u32)val;
- gprs[1] = msr;
- gprs[2] = val >> 32;
- gprs[7] = 0x9c5a203a;
-
- return paravirt_wrmsr_regs(gprs);
-}
static inline u64 paravirt_read_tsc(void)
{
@@ -252,6 +213,8 @@ do { \
high = _l >> 32; \
} while (0)
+#define rdpmcl(counter, val) ((val) = paravirt_read_pmc(counter))
+
static inline unsigned long long paravirt_rdtscp(unsigned int *aux)
{
return PVOP_CALL1(u64, pv_cpu_ops.read_tscp, aux);

arch/x86/include/asm/paravirt_types.h

View file
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 8e8b9a4..8613cbb 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -153,9 +153,7 @@ struct pv_cpu_ops {
/* MSR, PMC and TSR operations.
err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */
u64 (*read_msr)(unsigned int msr, int *err);
- int (*rdmsr_regs)(u32 *regs);
int (*write_msr)(unsigned int msr, unsigned low, unsigned high);
- int (*wrmsr_regs)(u32 *regs);
u64 (*read_tsc)(void);
u64 (*read_pmc)(int counter);

arch/x86/include/asm/perf_event.h

View file
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index 588f52e..c78f14a 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -5,11 +5,10 @@
* Performance event hw details:
*/
-#define X86_PMC_MAX_GENERIC 32
-#define X86_PMC_MAX_FIXED 3
+#define INTEL_PMC_MAX_GENERIC 32
+#define INTEL_PMC_MAX_FIXED 3
+#define INTEL_PMC_IDX_FIXED 32
-#define X86_PMC_IDX_GENERIC 0
-#define X86_PMC_IDX_FIXED 32
#define X86_PMC_IDX_MAX 64
#define MSR_ARCH_PERFMON_PERFCTR0 0xc1
@@ -48,8 +47,7 @@
(X86_RAW_EVENT_MASK | \
AMD64_EVENTSEL_EVENT)
#define AMD64_NUM_COUNTERS 4
-#define AMD64_NUM_COUNTERS_F15H 6
-#define AMD64_NUM_COUNTERS_MAX AMD64_NUM_COUNTERS_F15H
+#define AMD64_NUM_COUNTERS_CORE 6
#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 0x3c
#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8)
@@ -121,16 +119,16 @@ struct x86_pmu_capability {
/* Instr_Retired.Any: */
#define MSR_ARCH_PERFMON_FIXED_CTR0 0x309
-#define X86_PMC_IDX_FIXED_INSTRUCTIONS (X86_PMC_IDX_FIXED + 0)
+#define INTEL_PMC_IDX_FIXED_INSTRUCTIONS (INTEL_PMC_IDX_FIXED + 0)
/* CPU_CLK_Unhalted.Core: */
#define MSR_ARCH_PERFMON_FIXED_CTR1 0x30a
-#define X86_PMC_IDX_FIXED_CPU_CYCLES (X86_PMC_IDX_FIXED + 1)
+#define INTEL_PMC_IDX_FIXED_CPU_CYCLES (INTEL_PMC_IDX_FIXED + 1)
/* CPU_CLK_Unhalted.Ref: */
#define MSR_ARCH_PERFMON_FIXED_CTR2 0x30b
-#define X86_PMC_IDX_FIXED_REF_CYCLES (X86_PMC_IDX_FIXED + 2)
-#define X86_PMC_MSK_FIXED_REF_CYCLES (1ULL << X86_PMC_IDX_FIXED_REF_CYCLES)
+#define INTEL_PMC_IDX_FIXED_REF_CYCLES (INTEL_PMC_IDX_FIXED + 2)
+#define INTEL_PMC_MSK_FIXED_REF_CYCLES (1ULL << INTEL_PMC_IDX_FIXED_REF_CYCLES)
/*
* We model BTS tracing as another fixed-mode PMC.
@@ -139,7 +137,7 @@ struct x86_pmu_capability {
* values are used by actual fixed events and higher values are used
* to indicate other overflow conditions in the PERF_GLOBAL_STATUS msr.
*/
-#define X86_PMC_IDX_FIXED_BTS (X86_PMC_IDX_FIXED + 16)
+#define INTEL_PMC_IDX_FIXED_BTS (INTEL_PMC_IDX_FIXED + 16)
/*
* IBS cpuid feature detection
@@ -234,6 +232,7 @@ struct perf_guest_switch_msr {
extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
extern void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap);
+extern void perf_check_microcode(void);
#else
static inline perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
{
@@ -247,6 +246,7 @@ static inline void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
}
static inline void perf_events_lapic_init(void) { }
+static inline void perf_check_microcode(void) { }
#endif
#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD)

arch/x86/include/asm/uprobes.h

View file
diff --git a/arch/x86/include/asm/uprobes.h b/arch/x86/include/asm/uprobes.h
index 1e9bed1..f3971bb 100644
--- a/arch/x86/include/asm/uprobes.h
+++ b/arch/x86/include/asm/uprobes.h
@@ -48,7 +48,7 @@ struct arch_uprobe_task {
#endif
};
-extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm);
+extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long addr);
extern int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs);
extern int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs);
extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk);

arch/x86/kernel/cpu/Makefile

View file
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 6ab6aa2..bac4c38 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -32,7 +32,9 @@ obj-$(CONFIG_PERF_EVENTS) += perf_event.o
ifdef CONFIG_PERF_EVENTS
obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd.o
-obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_p4.o perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o
+obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_p4.o
+obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o
+obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore.o
endif
obj-$(CONFIG_X86_MCE) += mcheck/

arch/x86/kernel/cpu/amd.c

View file
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 146bb62..9d92e19 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -19,6 +19,39 @@
#include "cpu.h"
+static inline int rdmsrl_amd_safe(unsigned msr, unsigned long long *p)
+{
+ struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
+ u32 gprs[8] = { 0 };
+ int err;
+
+ WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
+
+ gprs[1] = msr;
+ gprs[7] = 0x9c5a203a;
+
+ err = rdmsr_safe_regs(gprs);
+
+ *p = gprs[0] | ((u64)gprs[2] << 32);
+
+ return err;
+}
+
+static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
+{
+ struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
+ u32 gprs[8] = { 0 };
+
+ WARN_ONCE((c->x86 != 0xf), "%s should only be used on K8!\n", __func__);
+
+ gprs[0] = (u32)val;
+ gprs[1] = msr;
+ gprs[2] = val >> 32;
+ gprs[7] = 0x9c5a203a;
+
+ return wrmsr_safe_regs(gprs);
+}
+
#ifdef CONFIG_X86_32
/*
* B step AMD K6 before B 9730xxxx have hardware bugs that can cause
@@ -586,9 +619,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
!cpu_has(c, X86_FEATURE_TOPOEXT)) {
u64 val;
- if (!rdmsrl_amd_safe(0xc0011005, &val)) {
+ if (!rdmsrl_safe(0xc0011005, &val)) {
val |= 1ULL << 54;
- wrmsrl_amd_safe(0xc0011005, val);
+ wrmsrl_safe(0xc0011005, val);
rdmsrl(0xc0011005, val);
if (val & (1ULL << 54)) {
set_cpu_cap(c, X86_FEATURE_TOPOEXT);
@@ -679,7 +712,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
err = rdmsrl_safe(MSR_AMD64_MCx_MASK(4), &mask);
if (err == 0) {
mask |= (1 << 10);
- checking_wrmsrl(MSR_AMD64_MCx_MASK(4), mask);
+ wrmsrl_safe(MSR_AMD64_MCx_MASK(4), mask);
}
}

arch/x86/kernel/cpu/common.c

View file
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 6b9333b..5bbc082 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -947,7 +947,7 @@ static void __cpuinit __print_cpu_msr(void)
index_max = msr_range_array[i].max;
for (index = index_min; index < index_max; index++) {
- if (rdmsrl_amd_safe(index, &val))
+ if (rdmsrl_safe(index, &val))
continue;
printk(KERN_INFO " MSR%08x: %016llx\n", index, val);
}

arch/x86/kernel/cpu/perf_event.c

View file
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index c4706cf..29557aa 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -35,17 +35,6 @@
#include "perf_event.h"
-#if 0
-#undef wrmsrl
-#define wrmsrl(msr, val) \
-do { \
- trace_printk("wrmsrl(%lx, %lx)\n", (unsigned long)(msr),\
- (unsigned long)(val)); \
- native_write_msr((msr), (u32)((u64)(val)), \
- (u32)((u64)(val) >> 32)); \
-} while (0)
-#endif
-
struct x86_pmu x86_pmu __read_mostly;
DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = {
@@ -74,7 +63,7 @@ u64 x86_perf_event_update(struct perf_event *event)
int idx = hwc->idx;
s64 delta;
- if (idx == X86_PMC_IDX_FIXED_BTS)
+ if (idx == INTEL_PMC_IDX_FIXED_BTS)
return 0;
/*
@@ -86,7 +75,7 @@ u64 x86_perf_event_update(struct perf_event *event)
*/
again:
prev_raw_count = local64_read(&hwc->prev_count);
- rdmsrl(hwc->event_base, new_raw_count);
+ rdpmcl(hwc->event_base_rdpmc, new_raw_count);
if (local64_cmpxchg(&hwc->prev_count, prev_raw_count,
new_raw_count) != prev_raw_count)
@@ -189,7 +178,7 @@ static void release_pmc_hardware(void) {}
static bool check_hw_exists(void)
{
- u64 val, val_new = 0;
+ u64 val, val_new = ~0;
int i, reg, ret = 0;
/*
@@ -222,8 +211,9 @@ static bool check_hw_exists(void)
* that don't trap on the MSR access and always return 0s.
*/
val = 0xabcdUL;
- ret = checking_wrmsrl(x86_pmu_event_addr(0), val);
- ret |= rdmsrl_safe(x86_pmu_event_addr(0), &val_new);
+ reg = x86_pmu_event_addr(0);
+ ret = wrmsrl_safe(reg, val);
+ ret |= rdmsrl_safe(reg, &val_new);
if (ret || val != val_new)
goto msr_fail;
@@ -240,6 +230,7 @@ bios_fail:
msr_fail:
printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
+ printk(KERN_ERR "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new);
return false;
}
@@ -388,7 +379,7 @@ int x86_pmu_hw_config(struct perf_event *event)
int precise = 0;
/* Support for constant skid */
- if (x86_pmu.pebs_active) {
+ if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) {
precise++;
/* Support for IP fixup */
@@ -637,8 +628,8 @@ static bool __perf_sched_find_counter(struct perf_sched *sched)
c = sched->constraints[sched->state.event];
/* Prefer fixed purpose counters */
- if (x86_pmu.num_counters_fixed) {
- idx = X86_PMC_IDX_FIXED;
+ if (c->idxmsk64 & (~0ULL << INTEL_PMC_IDX_FIXED)) {
+ idx = INTEL_PMC_IDX_FIXED;
for_each_set_bit_from(idx, c->idxmsk, X86_PMC_IDX_MAX) {
if (!__test_and_set_bit(idx, sched->state.used))
goto done;
@@ -646,7 +637,7 @@ static bool __perf_sched_find_counter(struct perf_sched *sched)
}
/* Grab the first unused counter starting with idx */
idx = sched->state.counter;
- for_each_set_bit_from(idx, c->idxmsk, X86_PMC_IDX_FIXED) {
+ for_each_set_bit_from(idx, c->idxmsk, INTEL_PMC_IDX_FIXED) {
if (!__test_and_set_bit(idx, sched->state.used))
goto done;
}
@@ -704,8 +695,8 @@ static bool perf_sched_next_event(struct perf_sched *sched)
/*
* Assign a counter for each event.
*/
-static int perf_assign_events(struct event_constraint **constraints, int n,
- int wmin, int wmax, int *assign)
+int perf_assign_events(struct event_constraint **constraints, int n,
+ int wmin, int wmax, int *assign)
{
struct perf_sched sched;
@@ -824,15 +815,17 @@ static inline void x86_assign_hw_event(struct perf_event *event,
hwc->last_cpu = smp_processor_id();
hwc->last_tag = ++cpuc->tags[i];
- if (hwc->idx == X86_PMC_IDX_FIXED_BTS) {
+ if (hwc->idx == INTEL_PMC_IDX_FIXED_BTS) {
hwc->config_base = 0;
hwc->event_base = 0;
- } else if (hwc->idx >= X86_PMC_IDX_FIXED) {
+ } else if (hwc->idx >= INTEL_PMC_IDX_FIXED) {
hwc->config_base = MSR_ARCH_PERFMON_FIXED_CTR_CTRL;
- hwc->event_base = MSR_ARCH_PERFMON_FIXED_CTR0 + (hwc->idx - X86_PMC_IDX_FIXED);
+ hwc->event_base = MSR_ARCH_PERFMON_FIXED_CTR0 + (hwc->idx - INTEL_PMC_IDX_FIXED);
+ hwc->event_base_rdpmc = (hwc->idx - INTEL_PMC_IDX_FIXED) | 1<<30;
} else {
hwc->config_base = x86_pmu_config_addr(hwc->idx);
hwc->event_base = x86_pmu_event_addr(hwc->idx);
+ hwc->event_base_rdpmc = hwc->idx;
}
}
@@ -930,7 +923,7 @@ int x86_perf_event_set_period(struct perf_event *event)
s64 period = hwc->sample_period;
int ret = 0, idx = hwc->idx;
- if (idx == X86_PMC_IDX_FIXED_BTS)
+ if (idx == INTEL_PMC_IDX_FIXED_BTS)
return 0;
/*
@@ -1316,7 +1309,6 @@ static struct attribute_group x86_pmu_format_group = {
static int __init init_hw_perf_events(void)
{
struct x86_pmu_quirk *quirk;
- struct event_constraint *c;
int err;
pr_info("Performance Events: ");
@@ -1347,21 +1339,8 @@ static int __init init_hw_perf_events(void)
for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next)
quirk->func();
- if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) {
- WARN(1, KERN_ERR "hw perf events %d > max(%d), clipping!",
- x86_pmu.num_counters, X86_PMC_MAX_GENERIC);
- x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
- }
- x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1;
-
- if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
- WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",
- x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED);
- x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
- }
-
- x86_pmu.intel_ctrl |=
- ((1LL << x86_pmu.num_counters_fixed)-1) << X86_PMC_IDX_FIXED;
+ if (!x86_pmu.intel_ctrl)
+ x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1;
perf_events_lapic_init();
register_nmi_handler(NMI_LOCAL, perf_event_nmi_handler, 0, "PMI");
@@ -1370,22 +1349,6 @@ static int __init init_hw_perf_events(void)
__EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1,
0, x86_pmu.num_counters, 0);
- if (x86_pmu.event_constraints) {
- /*
- * event on fixed counter2 (REF_CYCLES) only works on this
- * counter, so do not extend mask to generic counters
- */
- for_each_event_constraint(c, x86_pmu.event_constraints) {
- if (c->cmask != X86_RAW_EVENT_MASK
- || c->idxmsk64 == X86_PMC_MSK_FIXED_REF_CYCLES) {
- continue;
- }
-
- c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1;
- c->weight += x86_pmu.num_counters;
- }
- }
-
x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
x86_pmu_format_group.attrs = x86_pmu.format_attrs;
@@ -1620,8 +1583,8 @@ static int x86_pmu_event_idx(struct perf_event *event)
if (!x86_pmu.attr_rdpmc)
return 0;
- if (x86_pmu.num_counters_fixed && idx >= X86_PMC_IDX_FIXED) {
- idx -= X86_PMC_IDX_FIXED;
+ if (x86_pmu.num_counters_fixed && idx >= INTEL_PMC_IDX_FIXED) {
+ idx -= INTEL_PMC_IDX_FIXED;
idx |= 1 << 30;
}
@@ -1649,7 +1612,12 @@ static ssize_t set_attr_rdpmc(struct device *cdev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- unsigned long val = simple_strtoul(buf, NULL, 0);
+ unsigned long val;
+ ssize_t ret;
+
+ ret = kstrtoul(buf, 0, &val);
+ if (ret)
+ return ret;
if (!!val != !!x86_pmu.attr_rdpmc) {
x86_pmu.attr_rdpmc = !!val;
@@ -1682,13 +1650,20 @@ static void x86_pmu_flush_branch_stack(void)
x86_pmu.flush_branch_stack();
}
+void perf_check_microcode(void)
+{
+ if (x86_pmu.check_microcode)
+ x86_pmu.check_microcode();
+}
+EXPORT_SYMBOL_GPL(perf_check_microcode);
+
static struct pmu pmu = {
.pmu_enable = x86_pmu_enable,
.pmu_disable = x86_pmu_disable,

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event_amd.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event_intel.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event_intel_ds.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event_intel_uncore.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event_intel_uncore.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event_p4.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/cpu/perf_event_p6.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/microcode_core.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/paravirt.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/process_64.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/uprobes.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/pmu.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/trace.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/lib/msr-reg-export.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/lib/msr-reg.S

View file

This diff is incomplete. Download the complete patch.

arch/x86/oprofile/op_model_amd.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/vdso/vdso32-setup.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/xen/enlighten.c

View file

This diff is incomplete. Download the complete patch.

drivers/oprofile/oprofile_perf.c

View file

This diff is incomplete. Download the complete patch.

include/linux/ftrace_event.h

View file

This diff is incomplete. Download the complete patch.

include/linux/jump_label.h

View file

This diff is incomplete. Download the complete patch.

include/linux/pci_ids.h

View file

This diff is incomplete. Download the complete patch.

include/linux/perf_event.h

View file

This diff is incomplete. Download the complete patch.

include/linux/sched.h

View file

This diff is incomplete. Download the complete patch.

include/linux/tracepoint.h

View file

This diff is incomplete. Download the complete patch.

include/trace/ftrace.h

View file

This diff is incomplete. Download the complete patch.

kernel/events/core.c

View file

This diff is incomplete. Download the complete patch.

kernel/events/uprobes.c

View file

This diff is incomplete. Download the complete patch.

kernel/trace/ftrace.c

View file

This diff is incomplete. Download the complete patch.

kernel/trace/ring_buffer.c

View file

This diff is incomplete. Download the complete patch.

kernel/trace/trace.c

View file

This diff is incomplete. Download the complete patch.

kernel/trace/trace.h

View file

This diff is incomplete. Download the complete patch.

kernel/trace/trace_functions_graph.c

View file

This diff is incomplete. Download the complete patch.

kernel/trace/trace_output.c

View file

This diff is incomplete. Download the complete patch.

tools/lib/traceevent/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/lib/traceevent/event-parse.c

View file

This diff is incomplete. Download the complete patch.

tools/lib/traceevent/event-parse.h

View file

This diff is incomplete. Download the complete patch.

tools/lib/traceevent/parse-filter.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/Documentation/perf-bench.txt

View file

This diff is incomplete. Download the complete patch.

tools/perf/Documentation/perf-report.txt

View file

This diff is incomplete. Download the complete patch.

tools/perf/Documentation/perf-top.txt

View file

This diff is incomplete. Download the complete patch.

tools/perf/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/perf/bench/mem-memcpy.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/bench/mem-memset.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-bench.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-evlist.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-kmem.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-lock.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-record.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-report.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-sched.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-script.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-stat.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-test.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/builtin-top.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/config/feature-tests.mak

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/browsers/annotate.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/browsers/hists.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/gtk/browser.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/gtk/gtk.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/gtk/setup.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/gtk/util.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/tui/setup.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/tui/util.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/util.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/ui/util.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/debug.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/debug.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/evlist.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/evlist.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/evsel.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/evsel.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/header.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/hist.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/include/linux/kernel.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/map.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/parse-events-test.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/parse-events.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/parse-events.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/parse-events.l

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/parse-events.y

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/pmu.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/pmu.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/scripting-engines/trace-event-perl.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/scripting-engines/trace-event-python.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/session.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/session.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/sort.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/sort.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/string.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/symbol.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/symbol.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/top.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/trace-event-parse.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/trace-event-read.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/trace-event-scripting.c

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/trace-event.h

View file

This diff is incomplete. Download the complete patch.

tools/perf/util/util.h

View file

This diff is incomplete. Download the complete patch.