Commit 8de3f7a7 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull perf fixes from Ingo Molnar:
 "Two kernel side fixes:

   - an Intel uncore PMU driver potential crash fix
   - a kprobes/perf-call-graph interaction fix"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/x86/intel: Use rdmsrl_safe() when initializing RAPL PMU
  kprobes/x86: Fix page-fault handling logic
parents b9312420 24223657
...@@ -535,6 +535,7 @@ static int rapl_cpu_prepare(int cpu) ...@@ -535,6 +535,7 @@ static int rapl_cpu_prepare(int cpu)
struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu); struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu);
int phys_id = topology_physical_package_id(cpu); int phys_id = topology_physical_package_id(cpu);
u64 ms; u64 ms;
u64 msr_rapl_power_unit_bits;
if (pmu) if (pmu)
return 0; return 0;
...@@ -542,6 +543,9 @@ static int rapl_cpu_prepare(int cpu) ...@@ -542,6 +543,9 @@ static int rapl_cpu_prepare(int cpu)
if (phys_id < 0) if (phys_id < 0)
return -1; return -1;
if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
return -1;
pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu)); pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
if (!pmu) if (!pmu)
return -1; return -1;
...@@ -555,8 +559,7 @@ static int rapl_cpu_prepare(int cpu) ...@@ -555,8 +559,7 @@ static int rapl_cpu_prepare(int cpu)
* *
* we cache in local PMU instance * we cache in local PMU instance
*/ */
rdmsrl(MSR_RAPL_POWER_UNIT, pmu->hw_unit); pmu->hw_unit = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
pmu->hw_unit = (pmu->hw_unit >> 8) & 0x1FULL;
pmu->pmu = &rapl_pmu_class; pmu->pmu = &rapl_pmu_class;
/* /*
...@@ -677,7 +680,9 @@ static int __init rapl_pmu_init(void) ...@@ -677,7 +680,9 @@ static int __init rapl_pmu_init(void)
cpu_notifier_register_begin(); cpu_notifier_register_begin();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
rapl_cpu_prepare(cpu); ret = rapl_cpu_prepare(cpu);
if (ret)
goto out;
rapl_cpu_init(cpu); rapl_cpu_init(cpu);
} }
...@@ -700,6 +705,7 @@ static int __init rapl_pmu_init(void) ...@@ -700,6 +705,7 @@ static int __init rapl_pmu_init(void)
hweight32(rapl_cntr_mask), hweight32(rapl_cntr_mask),
ktime_to_ms(pmu->timer_interval)); ktime_to_ms(pmu->timer_interval));
out:
cpu_notifier_register_done(); cpu_notifier_register_done();
return 0; return 0;
......
...@@ -897,9 +897,10 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) ...@@ -897,9 +897,10 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
struct kprobe *cur = kprobe_running(); struct kprobe *cur = kprobe_running();
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
switch (kcb->kprobe_status) { if (unlikely(regs->ip == (unsigned long)cur->ainsn.insn)) {
case KPROBE_HIT_SS: /* This must happen on single-stepping */
case KPROBE_REENTER: WARN_ON(kcb->kprobe_status != KPROBE_HIT_SS &&
kcb->kprobe_status != KPROBE_REENTER);
/* /*
* We are here because the instruction being single * We are here because the instruction being single
* stepped caused a page fault. We reset the current * stepped caused a page fault. We reset the current
...@@ -914,9 +915,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) ...@@ -914,9 +915,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
else else
reset_current_kprobe(); reset_current_kprobe();
preempt_enable_no_resched(); preempt_enable_no_resched();
break; } else if (kcb->kprobe_status == KPROBE_HIT_ACTIVE ||
case KPROBE_HIT_ACTIVE: kcb->kprobe_status == KPROBE_HIT_SSDONE) {
case KPROBE_HIT_SSDONE:
/* /*
* We increment the nmissed count for accounting, * We increment the nmissed count for accounting,
* we can also use npre/npostfault count for accounting * we can also use npre/npostfault count for accounting
...@@ -945,10 +945,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) ...@@ -945,10 +945,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
* fixup routine could not handle it, * fixup routine could not handle it,
* Let do_page_fault() fix it. * Let do_page_fault() fix it.
*/ */
break;
default:
break;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment