ftrace: kill the dead code in trace_sched_switch.c
cover ftrace: kill the dead code in trace_sched_switch.c
Quoted 4 lines · Oleg Nesterov
This motivated me to try to find something else unused. And it seems that almost all code in
kernel/trace/trace_sched_switch.cis dead? Hmm, and probably evenevent_context_switch... I'll recheck and send the patch.
No, event_context_switch can't simply go away. But afaics the only user is tracing_sched_switch_trace(), and the only caller of this function is probe_wakeup_sched_switch(). Looks a bit strange.
After this patch we should probably move tracing_sched_switch_trace() and tracing_sched_wakeup_trace() from trace_sched_switch.c to trace_sched_wakeup.c and make them static. And perhaps we can also move the rest of this code somewhere else and rm this file...
Oleg.
kernel/trace/trace.h | 3 - kernel/trace/trace_sched_switch.c | 88 ------------------------------------- 2 files changed, 0 insertions(+), 91 deletions(-)
PATCH 1/2 ftrace: Kill tracing_{start,stop}_sched_switch_record() and tracing_sched_switch_assign_trace()
tracing_{start,stop}_sched_switch_record() have no callers since 87d80de2800d "tracing: Remove obsolete sched_switch tracer".
The last caller of tracing_sched_switch_assign_trace() was removed by 30dbb20e68e6 "tracing: Remove boot tracer".
--- kernel/trace/trace.h | 3 -- kernel/trace/trace_sched_switch.c | 48 ------------------------------------- 2 files changed, 0 insertions(+), 51 deletions(-)
kernel/trace/trace.h +0 -3
@@ -595,9 +595,6 @@ void set_graph_array(struct trace_array *tr);void tracing_start_cmdline_record (void );void tracing_stop_cmdline_record (void ); -void tracing_sched_switch_assign_trace (struct trace_array *tr); -void tracing_stop_sched_switch_record (void ); -void tracing_start_sched_switch_record (void );int register_tracer (struct tracer *type);int is_tracing_stopped (void );
kernel/trace/trace_sched_switch.c +0 -48
51 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 2/2 ftrace: Kill the dead code in probe_sched_switch() and probe_sched_wakeup()
In reply to Oleg NesterovAfter the previous patch it is clear that "tracer_enabled" can never be true, we can remove the "if (tracer_enabled)" code in probe_sched_switch() and probe_sched_wakeup(). Plus we can obviously remove tracer_enabled, ctx_trace, and sched_stopped as well.
--- kernel/trace/trace_sched_switch.c | 40 ------------------------------------- 1 files changed, 0 insertions(+), 40 deletions(-)
kernel/trace/trace_sched_switch.c +0 -40
@@ -14,12 +14,8 @@#include "trace.h" -static struct trace_array *ctx_trace; -static int __read_mostly tracer_enabled;static int sched_ref;static DEFINE_MUTEX (sched_register_mutex); -static int sched_stopped; - void tracing_sched_switch_trace(struct trace_array *tr,
@@ -52,29 +48,11 @@ tracing_sched_switch_trace(struct trace_array *tr,static void probe_sched_switch (void *ignore,struct task_struct *prev,struct task_struct *next) { -struct trace_array_cpu *data; -unsigned long flags; -int cpu; -int pc; -if (unlikely (!sched_ref))return ;tracing_record_cmdline (prev);tracing_record_cmdline (next); - -if (!tracer_enabled || sched_stopped) -return ; - - pc =preempt_count (); -local_irq_save (flags); - cpu =raw_smp_processor_id (); - data =per_cpu_ptr (ctx_trace->trace_buffer.data, cpu); - -if (likely (!atomic_read (&data->disabled))) -tracing_sched_switch_trace (ctx_trace, prev, next, flags, pc); - -local_irq_restore (flags); }void
@@ -108,28 +86,10 @@ tracing_sched_wakeup_trace(struct trace_array *tr,static void probe_sched_wakeup (void *ignore,struct task_struct *wakee,int success) { -struct trace_array_cpu *data; -unsigned long flags; -int cpu, pc; -if (unlikely (!sched_ref))return ;tracing_record_cmdline (current); - -if (!tracer_enabled || sched_stopped) -return ; - - pc =preempt_count (); -local_irq_save (flags); - cpu =raw_smp_processor_id (); - data =per_cpu_ptr (ctx_trace->trace_buffer.data, cpu); - -if (likely (!atomic_read (&data->disabled))) -tracing_sched_wakeup_trace (ctx_trace, wakee, current, - flags, pc); - -local_irq_restore (flags); }static int tracing_sched_register (void )
Signature · 1 line
1.5.5.1