--- kernel/trace/latency_hist.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) Index: linux-4.9.47-rt37/kernel/trace/latency_hist.c =================================================================== --- linux-4.9.47-rt37.orig/kernel/trace/latency_hist.c +++ linux-4.9.47-rt37/kernel/trace/latency_hist.c @@ -126,8 +126,10 @@ static notrace void probe_wakeup_latency struct task_struct *p); static notrace void probe_wakeup_latency_hist_stop(void *v, bool preempt, struct task_struct *prev, struct task_struct *next); +#ifdef CONFIG_SMP static notrace void probe_sched_migrate_task(void *, struct task_struct *task, int cpu); +#endif static struct enable_data wakeup_latency_enabled_data = { .latency_type = WAKEUP_LATENCY, .enabled = 0, @@ -692,6 +694,7 @@ do_enable(struct file *file, const char probe_wakeup_latency_hist_start, NULL); return ret; } +#ifdef CONFIG_SMP ret = register_trace_sched_migrate_task( probe_sched_migrate_task, NULL); if (ret) { @@ -704,6 +707,7 @@ do_enable(struct file *file, const char probe_wakeup_latency_hist_stop, NULL); return ret; } +#endif break; #endif #ifdef CONFIG_MISSED_TIMER_OFFSETS_HIST @@ -786,8 +790,10 @@ do_enable(struct file *file, const char probe_wakeup_latency_hist_start, NULL); unregister_trace_sched_switch( probe_wakeup_latency_hist_stop, NULL); +#ifdef CONFIG_SMP unregister_trace_sched_migrate_task( probe_sched_migrate_task, NULL); +#endif for_each_online_cpu(cpu) { per_cpu(wakeup_task, cpu) = NULL; @@ -975,6 +981,7 @@ static DEFINE_RAW_SPINLOCK(wakeup_lock); #ifdef CONFIG_SWITCHTIME_HIST static DEFINE_RAW_SPINLOCK(switchtime_lock); #endif +#ifdef CONFIG_SMP static notrace void probe_sched_migrate_task(void *v, struct task_struct *task, int cpu) { @@ -1012,6 +1019,7 @@ static notrace void probe_sched_migrate_ #endif } } +#endif /* CONFIG_SMP */ static notrace void probe_wakeup_latency_hist_start(void *v, struct task_struct *p) @@ -1140,8 +1148,11 @@ out: raw_spin_lock_irqsave(&switchtime_lock, flags); - cpu_switchtime_task = per_cpu(switchtime_task, cpu) = - next; + cpu_switchtime_task = per_cpu(switchtime_task, cpu); + if (cpu_switchtime_task != NULL) + put_task_struct(cpu_switchtime_task); + cpu_switchtime_task = next; + per_cpu(switchtime_task, cpu) = cpu_switchtime_task; get_task_struct(cpu_switchtime_task); raw_spin_unlock_irqrestore(&switchtime_lock, flags);