ftrace: recordmcount for sh and arm, plus permanent disable API
Subsystems (3)
Steven Rostedt
maintainercover ftrace: recordmcount for sh and arm, plus permanent disable API
Ingo,
The first two patches are changes to recordmcount.pl that I've tested to make sure they do not break x86 or PPC. These are changes that are needed for sh and ARM. I do not include the changes needed in the arch itself, those need to go through the arch maintainers.
The other patches are for the permanent disabling of the tracer and ring buffer.
I know you prefered having the ring buffer disable flag be 0 1 -1 for off, on, and disable respectively, but this becomes a problem to implement safely for all archs. What I did instead was to have two bits in the flags. On is a simple on/off bit for the users to use, the other is a set once flag that will permantly disable the ring buffers once set. This allows me to use the set/clear bit API that works on all architectures nicely. And I personally find this easier to understand.
The following patches are in:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
branch: tip/devel
Jim Radford (1):
ftrace: mcountrecord.pl for arm
Matt Fleming (1):
ftrace: Specify $alignment for sh architecture
Steven Rostedt (3):
ring-buffer: add tracing_off_permanent
ftrace: add ftrace_off_permanent
trace: fix compiler warning in branch profiler
----
include/linux/ftrace.h | 2 + include/linux/ring_buffer.h | 1 + kernel/trace/ring_buffer.c | 79 ++++++++++++++++++++++++++++++++++++------- kernel/trace/trace.c | 15 ++++++++ kernel/trace/trace_branch.c | 10 +++--- scripts/recordmcount.pl | 11 +++++- 6 files changed, 98 insertions(+), 20 deletions(-)
Steven Rostedt
maintainerPATCH 1/5 ftrace: Specify $alignment for sh architecture
From: Matt Fleming <[email protected]>
Set $alignment=2 for the sh architecture so that a ".align 2" directive will be emitted for all __mcount_loc sections. Fix a whitspace error while I'm here (converted spaces to tabs).
--- scripts/recordmcount.pl | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
scripts/recordmcount.pl +2 -1
@@ -135,7 +135,7 @@ my $section_regex; # Find the start of a section my $function_regex; # Find the name of a function # (return offset and func name) my $mcount_regex; # Find the call site to mcount (return offset) -my $alignment; # The .align value to use for $mcount_section +my $alignment; # The .align value to use for $mcount_section if ($arch eq "x86") { if ($bits == 64) {
@@ -176,6 +176,7 @@ if ($arch eq "x86_64") { $cc .= " -m32"; } elsif ($arch eq "sh") { + $alignment = 2; # force flags for this arch $ld .= " -m shlelf_linux";
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 2/5 ftrace: mcountrecord.pl for arm
In reply to Steven RostedtFrom: Jim Radford <[email protected]>
Arm uses %progbits instead of @progbits and requires only 4 byte alignment.
[ Thanks to Sam Ravnborg for mentioning that ARM uses %progbits ]
--- scripts/recordmcount.pl | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
scripts/recordmcount.pl +7 -1
@@ -136,6 +136,7 @@ my $function_regex; # Find the name of a function # (return offset and func name) my $mcount_regex; # Find the call site to mcount (return offset) my $alignment; # The .align value to use for $mcount_section +my $section_type; # Section header plus possible alignment command if ($arch eq "x86") { if ($bits == 64) {
@@ -153,6 +154,7 @@ $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; $section_regex = "Disassembly of section\\s+(\\S+):"; $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; +$section_type = '@progbits'; $type = ".long"; if ($arch eq "x86_64") {
@@ -192,6 +194,10 @@ if ($arch eq "x86_64") { $type = ".quad"; } +} elsif ($arch eq "arm") { + $alignment = 2; + $section_type = '%progbits'; + } else { die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; }
@@ -312,7 +318,7 @@ sub update_funcs if (!$opened) { open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; $opened = 1; - print FILE "\t.section $mcount_section,\"a\",\@progbits\n"; + print FILE "\t.section $mcount_section,\"a\",$section_type\n"; print FILE "\t.align $alignment\n" if (defined($alignment)); } printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset;
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 3/5 ring-buffer: add tracing_off_permanent
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: feature to permanently disable ring buffer
This patch adds a API to the ring buffer code that will permanently disable the ring buffer from ever recording. This should only be called when some serious anomaly is detected, and the system may be in an unstable state. When that happens, shutting down the recording to the ring buffers may be appropriate.
--- include/linux/ring_buffer.h | 1 + kernel/trace/ring_buffer.c | 79 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 67 insertions(+), 13 deletions(-)
include/linux/ring_buffer.h +1 -0
@@ -122,6 +122,7 @@ void ring_buffer_normalize_time_stamp(int cpu, u64 *ts);void tracing_on (void );void tracing_off (void ); +void tracing_off_permanent (void );enum ring_buffer_flags {RB_FL_OVERWRITE =1 <<0 ,
kernel/trace/ring_buffer.c +66 -13
136 lines not on this page · raw message
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 4/5 ftrace: add ftrace_off_permanent
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: feature to disable all of ftrace on anomalies
It case of a serious anomaly being detected (like something caught by lockdep) it is a good idea to disable all tracing immediately, without grabing any locks.
This patch adds ftrace_off_permanent that disables the tracers, function tracing and ring buffers without a way to enable them again. This should only be used when something serious has been detected.
--- include/linux/ftrace.h | 2 ++ kernel/trace/trace.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-)
include/linux/ftrace.h +2 -0
@@ -257,6 +257,7 @@ extern int ftrace_dump_on_oops;extern void tracing_start (void );extern void tracing_stop (void ); +extern void ftrace_off_permanent (void );extern void ftrace_special (unsigned long arg1,unsigned long arg2,unsigned long arg3);
@@ -290,6 +291,7 @@ ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));static inline void tracing_start (void ) { }static inline void tracing_stop (void ) { } +static inline void ftrace_off_permanent (void ) { }static inline int ftrace_printk (const char *fmt, ...) {
kernel/trace/trace.c +15 -0
@@ -639,6 +639,21 @@ static int trace_stop_count;static DEFINE_SPINLOCK (tracing_start_lock);/** +* ftrace_off_permanent - disable all ftrace code permanently +* +* This should only be called when a serious anomally has +* been detected. This will turn off the function tracing, +* ring buffers, and other tracing utilites. It takes no +* locks and can be called from any context. +*/ +void ftrace_off_permanent (void ) +{ + tracing_disabled =1 ; +ftrace_stop (); +tracing_off_permanent (); +} + +/** * tracing_start - quick start of the tracer * * If tracing is enabled but was stopped by tracing_stop,
Signature · 3 lines
1.5.6.5 --
Steven Rostedt
maintainerPATCH 5/5 trace: fix compiler warning in branch profiler
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
Impact: fix complier warning
The ftrace_pointers used in the branch profiler are constant values. They should never change. But the compiler complains when they are passed into the debugfs_create_file as a data pointer, because the function discards the qualifier.
This patch typecasts the parameter to debugfs_create_file back to a void pointer. To remind the callbacks that they are pointing to a constant value, I also modified the callback local pointers to be const struct ftrace_pointer * as well.
--- kernel/trace/trace_branch.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
kernel/trace/trace_branch.c +5 -5
@@ -191,7 +191,7 @@ struct ftrace_pointer {static void *t_next (struct seq_file *m,void *v,loff_t *pos) { -struct ftrace_pointer *f = m->private; +const struct ftrace_pointer *f = m->private;struct ftrace_branch_data *p = v; (*pos)++;
@@ -224,7 +224,7 @@ static void t_stop(struct seq_file *m, void *p)static int t_show (struct seq_file *m,void *v) { -struct ftrace_pointer *fp = m->private; +const struct ftrace_pointer *fp = m->private;struct ftrace_branch_data *p = v;const char *f;long percent;
@@ -296,7 +296,7 @@ static const struct file_operations tracing_branch_fops = {extern unsigned long __start_branch_profile[];extern unsigned long __stop_branch_profile[]; -static struct ftrace_pointer ftrace_branch_pos = { +static const struct ftrace_pointer ftrace_branch_pos = { .start = __start_branch_profile, .stop = __stop_branch_profile, .hit =1 ,
@@ -320,7 +320,7 @@ static __init int ftrace_branch_init(void) d_tracer =tracing_init_dentry (); entry =debugfs_create_file ("profile_annotated_branch" ,0444 , d_tracer, - &ftrace_annotated_branch_pos, + (void *)&ftrace_annotated_branch_pos, &tracing_branch_fops);if (!entry) pr_warning("Could not create debugfs "
@@ -328,7 +328,7 @@ static __init int ftrace_branch_init(void)#ifdef CONFIG_PROFILE_ALL_BRANCHES entry =debugfs_create_file ("profile_branch" ,0444 , d_tracer, - &ftrace_branch_pos, + (void *)&ftrace_branch_pos, &tracing_branch_fops);if (!entry) pr_warning("Could not create debugfs"
Signature · 3 lines
1.5.6.5 --
Quoted 7 lines
The following patches are in:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.gitbranch: tip/devel
thanks Steve - i've picked up you latest tip/devel lineup, with the following topic mappings - comment lines show places where i had to touch the commit:
ab687e9: trace: fix compiler warning in branch profiler
=> tip/tracing/branch-tracer
# fixed typo in commit log
43f6f85: ftrace: add ftrace_off_permanent
=> tip/tracing/ftrace
# tweaked the impact line
fe40c4d: ring-buffer: add tracing_off_permanent
=> tip/tracing/ring-buffer
5143dac: ftrace: mcountrecord.pl for arm
=> tip/tracing/ftrace
# fixed subject line
# added impact-line 5bb2800: ftrace: Specify $alignment for sh architecture
=> tip/tracing/ftrace
# fixed subject line capitalization
# added impact-line cf4b087: trace: profile all if conditionals
=> tip/tracing/branch-tracer
3d89c08: trace: branch profiling should not print percent without data
=> tip/tracing/branch-tracer
f174c21: trace: consolidate unlikely and likely profiler
=> tip/tracing/branch-tracer
61980a9: trace: remove extra assign in branch check
=> tip/tracing/branch-tracer
48a4227: ftrace: create default variables for archs in recordmcount.pl
=> tip/tracing/ftrace
1d18d90: ftrace: add support for powerpc to recordmcount.pl script
=> tip/tracing/ftrace
cf68a8f: sh: dynamic ftrace support.
=> tip/tracing/ftrace
the final commit IDs are:
0429149: trace: fix compiler warning in branch profiler 69bb54e: ftrace: add ftrace_off_permanent
033601a: ring-buffer: add tracing_off_permanent
e58918a: ftrace: scripts/recordmcount.pl support for ARM 3a3d04a: ftrace: specify $alignment for sh architecture 2bcd521: trace: profile all if conditionals
bac28bf: trace: branch profiling should not print percent without data 45b7974: trace: consolidate unlikely and likely profiler 42f565e: trace: remove extra assign in branch check
c204f72: ftrace: create default variables for archs in recordmcount.pl 42e007d: ftrace: add support for powerpc to recordmcount.pl script 0da85c0: sh: dynamic ftrace support.
Thanks,
Ingo