linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ftrace: kill the dead code in trace_sched_switch.c
@ 2014-07-23 19:34 Oleg Nesterov
  2014-07-23 19:35 ` [PATCH 1/2] ftrace: Kill tracing_{start,stop}_sched_switch_record() and tracing_sched_switch_assign_trace() Oleg Nesterov
  2014-07-23 19:35 ` [PATCH 2/2] ftrace: Kill the dead code in probe_sched_switch() and probe_sched_wakeup() Oleg Nesterov
  0 siblings, 2 replies; 3+ messages in thread
From: Oleg Nesterov @ 2014-07-23 19:34 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Namhyung Kim, Ingo Molnar, linux-kernel

On 07/23, Oleg Nesterov wrote:
>
> This motivated me to try to find something else unused. And it seems that
> almost all code in kernel/trace/trace_sched_switch.c is dead? Hmm, and
> probably even event_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(-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] ftrace: Kill tracing_{start,stop}_sched_switch_record() and tracing_sched_switch_assign_trace()
  2014-07-23 19:34 [PATCH 0/2] ftrace: kill the dead code in trace_sched_switch.c Oleg Nesterov
@ 2014-07-23 19:35 ` Oleg Nesterov
  2014-07-23 19:35 ` [PATCH 2/2] ftrace: Kill the dead code in probe_sched_switch() and probe_sched_wakeup() Oleg Nesterov
  1 sibling, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2014-07-23 19:35 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Namhyung Kim, Ingo Molnar, linux-kernel

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".

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/trace/trace.h              |    3 --
 kernel/trace/trace_sched_switch.c |   48 -------------------------------------
 2 files changed, 0 insertions(+), 51 deletions(-)

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 9258f5a..df2b33b 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -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);
 
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index 3f34dc9..3b60301 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -197,51 +197,3 @@ void tracing_stop_cmdline_record(void)
 {
 	tracing_stop_sched_switch();
 }
-
-/**
- * tracing_start_sched_switch_record - start tracing context switches
- *
- * Turns on context switch tracing for a tracer.
- */
-void tracing_start_sched_switch_record(void)
-{
-	if (unlikely(!ctx_trace)) {
-		WARN_ON(1);
-		return;
-	}
-
-	tracing_start_sched_switch();
-
-	mutex_lock(&sched_register_mutex);
-	tracer_enabled++;
-	mutex_unlock(&sched_register_mutex);
-}
-
-/**
- * tracing_stop_sched_switch_record - start tracing context switches
- *
- * Turns off context switch tracing for a tracer.
- */
-void tracing_stop_sched_switch_record(void)
-{
-	mutex_lock(&sched_register_mutex);
-	tracer_enabled--;
-	WARN_ON(tracer_enabled < 0);
-	mutex_unlock(&sched_register_mutex);
-
-	tracing_stop_sched_switch();
-}
-
-/**
- * tracing_sched_switch_assign_trace - assign a trace array for ctx switch
- * @tr: trace array pointer to assign
- *
- * Some tracers might want to record the context switches in their
- * trace. This function lets those tracers assign the trace array
- * to use.
- */
-void tracing_sched_switch_assign_trace(struct trace_array *tr)
-{
-	ctx_trace = tr;
-}
-
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ftrace: Kill the dead code in probe_sched_switch() and probe_sched_wakeup()
  2014-07-23 19:34 [PATCH 0/2] ftrace: kill the dead code in trace_sched_switch.c Oleg Nesterov
  2014-07-23 19:35 ` [PATCH 1/2] ftrace: Kill tracing_{start,stop}_sched_switch_record() and tracing_sched_switch_assign_trace() Oleg Nesterov
@ 2014-07-23 19:35 ` Oleg Nesterov
  1 sibling, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2014-07-23 19:35 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Namhyung Kim, Ingo Molnar, linux-kernel

After 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.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/trace/trace_sched_switch.c |   40 -------------------------------------
 1 files changed, 0 insertions(+), 40 deletions(-)

diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index 3b60301..f7c7f4f 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -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)
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-23 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23 19:34 [PATCH 0/2] ftrace: kill the dead code in trace_sched_switch.c Oleg Nesterov
2014-07-23 19:35 ` [PATCH 1/2] ftrace: Kill tracing_{start,stop}_sched_switch_record() and tracing_sched_switch_assign_trace() Oleg Nesterov
2014-07-23 19:35 ` [PATCH 2/2] ftrace: Kill the dead code in probe_sched_switch() and probe_sched_wakeup() Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).