diff options
Diffstat (limited to 'kernel/trace/trace_sched_wakeup.c')
| -rw-r--r-- | kernel/trace/trace_sched_wakeup.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c index ad69f105a7c6..26185d727676 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c | |||
| @@ -24,6 +24,7 @@ static int __read_mostly tracer_enabled; | |||
| 24 | 24 | ||
| 25 | static struct task_struct *wakeup_task; | 25 | static struct task_struct *wakeup_task; |
| 26 | static int wakeup_cpu; | 26 | static int wakeup_cpu; |
| 27 | static int wakeup_current_cpu; | ||
| 27 | static unsigned wakeup_prio = -1; | 28 | static unsigned wakeup_prio = -1; |
| 28 | static int wakeup_rt; | 29 | static int wakeup_rt; |
| 29 | 30 | ||
| @@ -56,33 +57,23 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip) | |||
| 56 | resched = ftrace_preempt_disable(); | 57 | resched = ftrace_preempt_disable(); |
| 57 | 58 | ||
| 58 | cpu = raw_smp_processor_id(); | 59 | cpu = raw_smp_processor_id(); |
| 60 | if (cpu != wakeup_current_cpu) | ||
| 61 | goto out_enable; | ||
| 62 | |||
| 59 | data = tr->data[cpu]; | 63 | data = tr->data[cpu]; |
| 60 | disabled = atomic_inc_return(&data->disabled); | 64 | disabled = atomic_inc_return(&data->disabled); |
| 61 | if (unlikely(disabled != 1)) | 65 | if (unlikely(disabled != 1)) |
| 62 | goto out; | 66 | goto out; |
| 63 | 67 | ||
| 64 | local_irq_save(flags); | 68 | local_irq_save(flags); |
| 65 | __raw_spin_lock(&wakeup_lock); | ||
| 66 | |||
| 67 | if (unlikely(!wakeup_task)) | ||
| 68 | goto unlock; | ||
| 69 | |||
| 70 | /* | ||
| 71 | * The task can't disappear because it needs to | ||
| 72 | * wake up first, and we have the wakeup_lock. | ||
| 73 | */ | ||
| 74 | if (task_cpu(wakeup_task) != cpu) | ||
| 75 | goto unlock; | ||
| 76 | 69 | ||
| 77 | trace_function(tr, ip, parent_ip, flags, pc); | 70 | trace_function(tr, ip, parent_ip, flags, pc); |
| 78 | 71 | ||
| 79 | unlock: | ||
| 80 | __raw_spin_unlock(&wakeup_lock); | ||
| 81 | local_irq_restore(flags); | 72 | local_irq_restore(flags); |
| 82 | 73 | ||
| 83 | out: | 74 | out: |
| 84 | atomic_dec(&data->disabled); | 75 | atomic_dec(&data->disabled); |
| 85 | 76 | out_enable: | |
| 86 | ftrace_preempt_enable(resched); | 77 | ftrace_preempt_enable(resched); |
| 87 | } | 78 | } |
| 88 | 79 | ||
| @@ -107,11 +98,18 @@ static int report_latency(cycle_t delta) | |||
| 107 | return 1; | 98 | return 1; |
| 108 | } | 99 | } |
| 109 | 100 | ||
| 101 | static void probe_wakeup_migrate_task(struct task_struct *task, int cpu) | ||
| 102 | { | ||
| 103 | if (task != wakeup_task) | ||
| 104 | return; | ||
| 105 | |||
| 106 | wakeup_current_cpu = cpu; | ||
| 107 | } | ||
| 108 | |||
| 110 | static void notrace | 109 | static void notrace |
| 111 | probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev, | 110 | probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev, |
| 112 | struct task_struct *next) | 111 | struct task_struct *next) |
| 113 | { | 112 | { |
| 114 | unsigned long latency = 0, t0 = 0, t1 = 0; | ||
| 115 | struct trace_array_cpu *data; | 113 | struct trace_array_cpu *data; |
| 116 | cycle_t T0, T1, delta; | 114 | cycle_t T0, T1, delta; |
| 117 | unsigned long flags; | 115 | unsigned long flags; |
| @@ -157,10 +155,6 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev, | |||
| 157 | trace_function(wakeup_trace, CALLER_ADDR0, CALLER_ADDR1, flags, pc); | 155 | trace_function(wakeup_trace, CALLER_ADDR0, CALLER_ADDR1, flags, pc); |
| 158 | tracing_sched_switch_trace(wakeup_trace, prev, next, flags, pc); | 156 | tracing_sched_switch_trace(wakeup_trace, prev, next, flags, pc); |
| 159 | 157 | ||
| 160 | /* | ||
| 161 | * usecs conversion is slow so we try to delay the conversion | ||
| 162 | * as long as possible: | ||
| 163 | */ | ||
| 164 | T0 = data->preempt_timestamp; | 158 | T0 = data->preempt_timestamp; |
| 165 | T1 = ftrace_now(cpu); | 159 | T1 = ftrace_now(cpu); |
| 166 | delta = T1-T0; | 160 | delta = T1-T0; |
| @@ -168,13 +162,10 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev, | |||
| 168 | if (!report_latency(delta)) | 162 | if (!report_latency(delta)) |
| 169 | goto out_unlock; | 163 | goto out_unlock; |
| 170 | 164 | ||
| 171 | latency = nsecs_to_usecs(delta); | 165 | if (likely(!is_tracing_stopped())) { |
| 172 | 166 | tracing_max_latency = delta; | |
| 173 | tracing_max_latency = delta; | 167 | update_max_tr(wakeup_trace, wakeup_task, wakeup_cpu); |
| 174 | t0 = nsecs_to_usecs(T0); | 168 | } |
| 175 | t1 = nsecs_to_usecs(T1); | ||
| 176 | |||
| 177 | update_max_tr(wakeup_trace, wakeup_task, wakeup_cpu); | ||
| 178 | 169 | ||
| 179 | out_unlock: | 170 | out_unlock: |
| 180 | __wakeup_reset(wakeup_trace); | 171 | __wakeup_reset(wakeup_trace); |
| @@ -244,6 +235,7 @@ probe_wakeup(struct rq *rq, struct task_struct *p, int success) | |||
| 244 | __wakeup_reset(wakeup_trace); | 235 | __wakeup_reset(wakeup_trace); |
| 245 | 236 | ||
| 246 | wakeup_cpu = task_cpu(p); | 237 | wakeup_cpu = task_cpu(p); |
| 238 | wakeup_current_cpu = wakeup_cpu; | ||
| 247 | wakeup_prio = p->prio; | 239 | wakeup_prio = p->prio; |
| 248 | 240 | ||
| 249 | wakeup_task = p; | 241 | wakeup_task = p; |
| @@ -293,6 +285,13 @@ static void start_wakeup_tracer(struct trace_array *tr) | |||
| 293 | goto fail_deprobe_wake_new; | 285 | goto fail_deprobe_wake_new; |
| 294 | } | 286 | } |
| 295 | 287 | ||
| 288 | ret = register_trace_sched_migrate_task(probe_wakeup_migrate_task); | ||
| 289 | if (ret) { | ||
| 290 | pr_info("wakeup trace: Couldn't activate tracepoint" | ||
| 291 | " probe to kernel_sched_migrate_task\n"); | ||
| 292 | return; | ||
| 293 | } | ||
| 294 | |||
| 296 | wakeup_reset(tr); | 295 | wakeup_reset(tr); |
| 297 | 296 | ||
| 298 | /* | 297 | /* |
| @@ -325,6 +324,7 @@ static void stop_wakeup_tracer(struct trace_array *tr) | |||
| 325 | unregister_trace_sched_switch(probe_wakeup_sched_switch); | 324 | unregister_trace_sched_switch(probe_wakeup_sched_switch); |
| 326 | unregister_trace_sched_wakeup_new(probe_wakeup); | 325 | unregister_trace_sched_wakeup_new(probe_wakeup); |
| 327 | unregister_trace_sched_wakeup(probe_wakeup); | 326 | unregister_trace_sched_wakeup(probe_wakeup); |
| 327 | unregister_trace_sched_migrate_task(probe_wakeup_migrate_task); | ||
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | static int __wakeup_tracer_init(struct trace_array *tr) | 330 | static int __wakeup_tracer_init(struct trace_array *tr) |
