Skip to contentSkip to conversation

tracing: Snapshot command line and branch tracer fix

PATCH New Steven Rostedt 1 participant 3 messages Mar 8, 2013

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Snapshot command line and branch tracer fix

Two more patches to my queue. I added alloc_snapshot to the kernel command line parameter to alloc allocation of the snapshot buffer when the main tracing buffer is allocated, allowing the use of tracing_snapshot() without the fear of it not being allocated.

Also Fengguang Wu's tests discovered that my changes broke the branch tracer. I guess I should add that to my test suite ;-)

Steven Rostedt (Red Hat) (2):
tracing: Add alloc_snapshot kernel command line parameter
tracing: Fix the branch tracer that broke with buffer change

----

 Documentation/kernel-parameters.txt |    7 +++
 kernel/trace/trace.c                |   81 +++++++++++++++++++++--------------
 kernel/trace/trace.h                |    2 +-
 kernel/trace/trace_branch.c         |    4 +-
 kernel/trace/trace_events.c         |    4 +-
 5 files changed, 60 insertions(+), 38 deletions(-)
author maintainer
#2 lore raw

PATCH 2/2 tracing: Fix the branch tracer that broke with buffer change

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

The changce to add the trace_buffer struct to have the trace array have both the main buffer and max buffer broke the branch tracer because the change did not update that code. As the branch tracer adds a significant amount of overhead, and must be selected via a selection (not a allyesconfig) it was missed in testing.

---
 kernel/trace/trace_branch.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_branch.c +2 -2
index 6dadbef..d594da0 100644
@@ -52,12 +52,12 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
 
 	local_irq_save(flags);
 	cpu = raw_smp_processor_id();
-	data = per_cpu_ptr(tr->data, cpu);
+	data = per_cpu_ptr(tr->trace_buffer.data, cpu);
 	if (atomic_inc_return(&data->disabled) != 1)
 		goto out;
 
 	pc = preempt_count();
-	buffer = tr->buffer;
+	buffer = tr->trace_buffer.buffer;
 	event = trace_buffer_lock_reserve(buffer, TRACE_BRANCH,
 					  sizeof(*entry), flags, pc);
 	if (!event)
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH 1/2 tracing: Add alloc_snapshot kernel command line parameter

In reply to Steven Rostedt

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

If debugging the kernel, and the developer wants to use tracing_snapshot() in places where tracing_snapshot_alloc() may be difficult (or more likely, the developer is lazy and doesn't want to bother with tracing_snapshot_alloc() at all), then adding

alloc_snapshot

to the kernel command line parameter will tell ftrace to allocate the snapshot buffer (if configured) when it allocates the main tracing buffer.

I also noticed that ring_buffer_expanded and tracing_selftest_disabled had inconsistent use of boolean "true" and "false" with "0" and "1". I cleaned that up too.

---
 Documentation/kernel-parameters.txt |    7 +++
 kernel/trace/trace.c                |   81 +++++++++++++++++++++--------------
 kernel/trace/trace.h                |    2 +-
 kernel/trace/trace_events.c         |    4 +-
 4 files changed, 58 insertions(+), 36 deletions(-)
Documentation/kernel-parameters.txt +7 -0
index 6c72381..0edc409 100644
@@ -320,6 +320,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			on: enable for both 32- and 64-bit processes
 			off: disable for both 32- and 64-bit processes
 
+	alloc_snapshot	[FTRACE]
+			Allocate the ftrace snapshot buffer on boot up when the
+			main buffer is allocated. This is handy if debugging
+			and you need to use tracing_snapshot() on boot up, and
+			do not want to use tracing_snapshot_alloc() as it needs
+			to be done where GFP_KERNEL allocations are allowed.
+
 	amd_iommu=	[HW,X86-64]
 			Pass parameters to the AMD IOMMU driver in the system.
 			Possible values are:
kernel/trace/trace.c +48 -33

140 lines not on this page · raw message

kernel/trace/trace.h +1 -1
index a19459d..0b7f424 100644
@@ -656,7 +656,7 @@ extern int DYN_FTRACE_TEST_NAME(void);
 #define DYN_FTRACE_TEST_NAME2 trace_selftest_dynamic_test_func2
 extern int DYN_FTRACE_TEST_NAME2(void);
 
-extern int ring_buffer_expanded;
+extern bool ring_buffer_expanded;
 extern bool tracing_selftest_disabled;
 DECLARE_PER_CPU(int, ftrace_cpu_disabled);
 
kernel/trace/trace_events.c +2 -2
index a376ab5..38b54c5 100644
@@ -1844,8 +1844,8 @@ static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
 static __init int setup_trace_event(char *str)
 {
 	strlcpy(bootup_event_buf, str, COMMAND_LINE_SIZE);
-	ring_buffer_expanded = 1;
-	tracing_selftest_disabled = 1;
+	ring_buffer_expanded = true;
+	tracing_selftest_disabled = true;
 
 	return 1;
 }
Signature · 1 line
1.7.10.4