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

Configure Feed

Select the types of activity you want to include in your feed.

perf,x86: fix kernel crash with PEBS/BTS after suspend/resume

This patch fixes a kernel crash when using precise sampling (PEBS)
after a suspend/resume. Turns out the CPU notifier code is not invoked
on CPU0 (BP). Therefore, the DS_AREA (used by PEBS) is not restored properly
by the kernel and keeps it power-on/resume value of 0 causing any PEBS
measurement to crash when running on CPU0.

The workaround is to add a hook in the actual resume code to restore
the DS Area MSR value. It is invoked for all CPUS. So for all but CPU0,
the DS_AREA will be restored twice but this is harmless.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Stephane Eranian and committed by
Linus Torvalds
1d9d8639 a2362d24

+12
+8
arch/x86/kernel/cpu/perf_event_intel_ds.c
··· 729 729 } 730 730 } 731 731 } 732 + 733 + void perf_restore_debug_store(void) 734 + { 735 + if (!x86_pmu.bts && !x86_pmu.pebs) 736 + return; 737 + 738 + init_debug_store_on_cpu(smp_processor_id()); 739 + }
+2
arch/x86/power/cpu.c
··· 11 11 #include <linux/suspend.h> 12 12 #include <linux/export.h> 13 13 #include <linux/smp.h> 14 + #include <linux/perf_event.h> 14 15 15 16 #include <asm/pgtable.h> 16 17 #include <asm/proto.h> ··· 229 228 do_fpu_end(); 230 229 x86_platform.restore_sched_clock_state(); 231 230 mtrr_bp_restore(); 231 + perf_restore_debug_store(); 232 232 } 233 233 234 234 /* Needed by apm.c */
+2
include/linux/perf_event.h
··· 758 758 extern void perf_event_disable(struct perf_event *event); 759 759 extern int __perf_event_disable(void *info); 760 760 extern void perf_event_task_tick(void); 761 + extern void perf_restore_debug_store(void); 761 762 #else 762 763 static inline void 763 764 perf_event_task_sched_in(struct task_struct *prev, ··· 798 797 static inline void perf_event_disable(struct perf_event *event) { } 799 798 static inline int __perf_event_disable(void *info) { return -1; } 800 799 static inline void perf_event_task_tick(void) { } 800 + static inline void perf_restore_debug_store(void) { } 801 801 #endif 802 802 803 803 #define perf_output_put(handle, x) perf_output_copy((handle), &(x), sizeof(x))