Commit 0d905bca authored by Ingo Molnar's avatar Ingo Molnar

perf_counter: initialize the per-cpu context earlier

percpu scheduling for perfcounters wants to take the context lock,
but that lock first needs to be initialized. Currently it is an
early_initcall() - but that is too late, the task tick runs much
sooner than that.

Call it explicitly from the scheduler init sequence instead.

[ Impact: fix access-before-init crash ]

LKML-Reference: <new-submission>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent ba77813a
...@@ -573,6 +573,8 @@ extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs); ...@@ -573,6 +573,8 @@ extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);
extern int sysctl_perf_counter_priv; extern int sysctl_perf_counter_priv;
extern void perf_counter_init(void);
#else #else
static inline void static inline void
perf_counter_task_sched_in(struct task_struct *task, int cpu) { } perf_counter_task_sched_in(struct task_struct *task, int cpu) { }
...@@ -603,6 +605,7 @@ perf_counter_munmap(unsigned long addr, unsigned long len, ...@@ -603,6 +605,7 @@ perf_counter_munmap(unsigned long addr, unsigned long len,
unsigned long pgoff, struct file *file) { } unsigned long pgoff, struct file *file) { }
static inline void perf_counter_comm(struct task_struct *tsk) { } static inline void perf_counter_comm(struct task_struct *tsk) { }
static inline void perf_counter_init(void) { }
#endif #endif
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -3265,15 +3265,12 @@ static struct notifier_block __cpuinitdata perf_cpu_nb = { ...@@ -3265,15 +3265,12 @@ static struct notifier_block __cpuinitdata perf_cpu_nb = {
.notifier_call = perf_cpu_notify, .notifier_call = perf_cpu_notify,
}; };
static int __init perf_counter_init(void) void __init perf_counter_init(void)
{ {
perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_UP_PREPARE, perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_UP_PREPARE,
(void *)(long)smp_processor_id()); (void *)(long)smp_processor_id());
register_cpu_notifier(&perf_cpu_nb); register_cpu_notifier(&perf_cpu_nb);
return 0;
} }
early_initcall(perf_counter_init);
static ssize_t perf_show_reserve_percpu(struct sysdev_class *class, char *buf) static ssize_t perf_show_reserve_percpu(struct sysdev_class *class, char *buf)
{ {
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/kernel_stat.h> #include <linux/kernel_stat.h>
#include <linux/debug_locks.h> #include <linux/debug_locks.h>
#include <linux/perf_counter.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/profile.h> #include <linux/profile.h>
...@@ -9097,6 +9098,8 @@ void __init sched_init(void) ...@@ -9097,6 +9098,8 @@ void __init sched_init(void)
alloc_bootmem_cpumask_var(&cpu_isolated_map); alloc_bootmem_cpumask_var(&cpu_isolated_map);
#endif /* SMP */ #endif /* SMP */
perf_counter_init();
scheduler_running = 1; scheduler_running = 1;
} }
......
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