Skip to contentSkip to conversation

tracing: Some clean ups to the code

PATCH New Steven Rostedt 1 participant 5 messages Nov 4, 2014

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Some clean ups to the code

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next-next

Head SHA1: bff81446ec9f8331b6443bddb92177fe10e27cb5

Jiang Liu (1):

      tracing: Add entry->next_cpu to trace_ctxwake_bin()

Oleg Nesterov (2):
tracing: Kill tracing_{start,stop}_sched_switch_record() and tracing_sched_switch_assign_trace()
tracing: Kill the dead code in probe_sched_switch() and probe_sched_wakeup()

Steven Rostedt (Red Hat) (1):
tracing: Move tracing_sched_{switch,wakeup}() into wakeup tracer

----

 kernel/trace/trace.h              |  12 ----
 kernel/trace/trace_output.c       |   1 +
 kernel/trace/trace_sched_switch.c | 144 --------------------------------------
 kernel/trace/trace_sched_wakeup.c |  56 +++++++++++++++
 4 files changed, 57 insertions(+), 156 deletions(-)
author maintainer
#1 lore raw

PATCH 1/4 tracing: Kill tracing_{start,stop}_sched_switch_record() and tracing_sched_switch_assign_trace()

From: Oleg Nesterov <[email protected]>

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, 51 deletions(-)
kernel/trace/trace.h +0 -3
index 385391fb1d3b..a3a82d5f25dc 100644
@@ -597,9 +597,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
2.1.1
author maintainer
#2 lore raw

PATCH 2/4 tracing: Kill the dead code in probe_sched_switch() and probe_sched_wakeup()

In reply to Steven Rostedt

From: Oleg Nesterov <[email protected]>

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.

---
 kernel/trace/trace_sched_switch.c | 40 ---------------------------------------
 1 file changed, 40 deletions(-)
kernel/trace/trace_sched_switch.c +0 -40
index 3b60301c59d2..f7c7f4f1544c 100644
@@ -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
2.1.1
author maintainer
#3 lore raw

PATCH 3/4 tracing: Move tracing_sched_{switch,wakeup}() into wakeup tracer

In reply to Steven Rostedt

From: "Steven Rostedt (Red Hat)" <[email protected]>

The only code that references tracing_sched_switch_trace() and tracing_sched_wakeup_trace() is the wakeup latency tracer. Those two functions use to belong to the sched_switch tracer which has long been removed. These functions were left behind because the wakeup latency tracer used them. But since the wakeup latency tracer is the only one to use them, they should be static functions inside that code.

---
 kernel/trace/trace.h              |  9 -------
 kernel/trace/trace_sched_switch.c | 56 ---------------------------------------
 kernel/trace/trace_sched_wakeup.c | 56 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 65 deletions(-)
kernel/trace/trace.h +0 -9
index a3a82d5f25dc..3376de623ea0 100644
@@ -569,15 +569,6 @@ void trace_init_global_iter(struct trace_iterator *iter);
 
 void tracing_iter_reset(struct trace_iterator *iter, int cpu);
 
-void tracing_sched_switch_trace(struct trace_array *tr,
-				struct task_struct *prev,
-				struct task_struct *next,
-				unsigned long flags, int pc);
-
-void tracing_sched_wakeup_trace(struct trace_array *tr,
-				struct task_struct *wakee,
-				struct task_struct *cur,
-				unsigned long flags, int pc);
 void trace_function(struct trace_array *tr,
 		    unsigned long ip,
 		    unsigned long parent_ip,
kernel/trace/trace_sched_switch.c +0 -56

68 lines not on this page · raw message

kernel/trace/trace_sched_wakeup.c +56 -0

62 lines not on this page · raw message

Signature · 1 line
2.1.1
author maintainer
#4 lore raw

PATCH 4/4 tracing: Add entry->next_cpu to trace_ctxwake_bin()

In reply to Steven Rostedt

From: Jiang Liu <[email protected]>

Function trace_ctxwake_bin() misses ctx_switch_entry->next_cpu field, so user will get stale value for "next_cpu".

---
 kernel/trace/trace_output.c | 1 +
 1 file changed, 1 insertion(+)
kernel/trace/trace_output.c +1 -0
index c6977d5a9b12..cfa91de22e27 100644
@@ -976,6 +976,7 @@ static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter,
 	SEQ_PUT_FIELD_RET(s, field->prev_pid);
 	SEQ_PUT_FIELD_RET(s, field->prev_prio);
 	SEQ_PUT_FIELD_RET(s, field->prev_state);
+	SEQ_PUT_FIELD_RET(s, field->next_cpu);
 	SEQ_PUT_FIELD_RET(s, field->next_pid);
 	SEQ_PUT_FIELD_RET(s, field->next_prio);
 	SEQ_PUT_FIELD_RET(s, field->next_state);
Signature · 1 line
2.1.1