Add check of sched_stopped for probe_sched_wakeup
PATCH 1/2 Add check of sched_stopped for probe_sched_wakeup
We need check sched_stopped in probe_sched_wakeup() to stop tracing when an user stops it.
But current code can also do the right thing(stop tracing after echo 0 > tracing_enabled) just because tracing_sched_wakeup_trace() can return on buffer->record_disabled.
--- kernel/trace/trace_sched_switch.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
kernel/trace/trace_sched_switch.c +3 -0
@@ -62,6 +62,9 @@ probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee, int success) pc =preempt_count ();tracing_record_cmdline (current); +if (sched_stopped) +return ; +local_irq_save (flags); cpu =raw_smp_processor_id (); data = ctx_trace->data[cpu];
Signature · 1 line
1.5.5.3
PATCH 2/2 ftrace: Clean up enable logic for sched_switch
Unify sched_switch and sched_wakeup's action to following logic:
Do record_cmdline when start_cmdline_record() called. Trace event when trace is inited and started.
--- kernel/trace/trace_sched_switch.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
kernel/trace/trace_sched_switch.c +5 -5
@@ -29,13 +29,13 @@ probe_sched_switch(struct rq *__rq, struct task_struct *prev,int cpu;int pc; -if (!sched_ref || sched_stopped) +if (!likely (sched_ref))return ;tracing_record_cmdline (prev);tracing_record_cmdline (next); -if (!tracer_enabled) +if (!tracer_enabled || sched_stopped)return ; pc =preempt_count ();
@@ -56,15 +56,15 @@ probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee, int success)unsigned long flags;int cpu, pc; -if (!likely (tracer_enabled)) +if (!likely (sched_ref))return ; - pc =preempt_count ();tracing_record_cmdline (current); -if (sched_stopped) +if (!tracer_enabled || sched_stopped)return ; + pc =preempt_count ();local_irq_save (flags); cpu =raw_smp_processor_id (); data = ctx_trace->data[cpu];
Signature · 1 line
1.5.5.3
Steven Rostedt
maintainerRe: [PATCH 2/2] ftrace: Clean up enable logic for sched_switch
kernel/trace/trace_sched_switch.c probe_sched_switch(struct rq *__rq, struct task_struct *prev, · line 32
Quoted 11 lines · Zhaolei
kernel/trace/trace_sched_switch.c +1
-1@@ -29,13 +29,13 @@ probe_sched_switch(struct rq *__rq, struct task_struct *prev,int cpu;int pc; -if (!sched_ref || sched_stopped) +if (!likely (sched_ref))
That should be:
if (unlikely(!sched_ref))
Quoted 11 lines
kernel/trace/trace_sched_switch.c +1
-1return ;tracing_record_cmdline (prev);tracing_record_cmdline (next); -if (!tracer_enabled) +if (!tracer_enabled || sched_stopped)return ; pc =preempt_count ();
kernel/trace/trace_sched_switch.c probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee, int success) · line 59
Quoted 5 lines
kernel/trace/trace_sched_switch.c +1
-1@@ -56,15 +56,15 @@ probe_sched_wakeup(struct rq *__rq, struct task_struct *wakee, int success)unsigned long flags;int cpu, pc; -if (!likely (tracer_enabled)) +if (!likely (sched_ref))
Same here.
-- Steve
Quoted 18 lines
kernel/trace/trace_sched_switch.c +2
-2return ; - pc =preempt_count ();tracing_record_cmdline (current); -if (sched_stopped) +if (!tracer_enabled || sched_stopped)return ; + pc =preempt_count ();local_irq_save (flags); cpu =raw_smp_processor_id (); data = ctx_trace->data[cpu];Signature · 1 line
1.5.5.3