Small seqfile-use improvements
Subsystems (4)
cover Small seqfile-use improvements
Patches 1-3 are semantic patches for replacing certain seq_* calls with simpler equivalents, e.g. seq_printf(m, "literal") -> seq_puts(m, "literal"). 1 and 3 are guaranteed to preserve the semantics of the code. 2 may change it slightly, since if the seq_file overflows midway through a series of seq_puts calls, some of the strings have been printed; after applying 2, it is all-or-nothing. However, consecutive seq_puts calls with literal strings is mostly used to print long headers, so overflow is very unlikely.
As an example, I applied these coccinelle scripts to kernel/trace/. The net result is a nice round, but admittedly tiny, 256 byte .text reduction.
Rasmus Villemoes (6):
Coccinelle: Semantic patch for replacing puts with putc
Coccinelle: Semantic patch for joining seq_puts calls
Coccinelle: Semantic patch for replacing seq_printf calls with
equivalent but simpler functions
trace: Replace seq_printf by simpler equivalents
trace: Merge consecutive seq_puts calls
trace: Replace single-character seq_puts with seq_putc
kernel/trace/ftrace.c | 30 +++--- kernel/trace/trace.c | 86 ++++++++------- kernel/trace/trace_branch.c | 31 +++--- kernel/trace/trace_events.c | 4 +- kernel/trace/trace_events_trigger.c | 6 +- kernel/trace/trace_functions.c | 2 +- kernel/trace/trace_functions_graph.c | 28 ++--- kernel/trace/trace_kprobe.c | 12 +-- kernel/trace/trace_printk.c | 2 +- kernel/trace/trace_uprobe.c | 4 +- scripts/coccinelle/api/seq_printf.cocci | 156 +++++++++++++++++++++++++++ scripts/coccinelle/api/seq_puts_concat.cocci | 71 ++++++++++++ scripts/coccinelle/api/seq_putsc.cocci | 61 +++++++++++ 13 files changed, 393 insertions(+), 100 deletions(-) create mode 100644 scripts/coccinelle/api/seq_printf.cocci create mode 100644 scripts/coccinelle/api/seq_puts_concat.cocci create mode 100644 scripts/coccinelle/api/seq_putsc.cocci
Signature · 1 line
2.0.4
PATCH 1/6 Coccinelle: Semantic patch for replacing puts with putc
Using seq_puts to write a one-character string is suboptimal, since puts has to call strlen(). Replace those instances with putc. This also tends to give a tiny code size reduction at the call site.
seq_put[sc] return -1 on error, 0 on success. trace_seq_put[sc] return how much was written, which is either 0 or 1.
In both cases, _putc is a drop-in replacement for _puts when the argument is a one-character string.
--- scripts/coccinelle/api/seq_putsc.cocci | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 scripts/coccinelle/api/seq_putsc.cocci
scripts/coccinelle/api/seq_putsc.cocci new file +61 -0
@@ -0,0 +1,61 @@ +/// Using seq_puts to write a one-character string is suboptimal, +/// since puts has to call strlen(). Replace those instances with +/// putc. This also tends to give a tiny code size reduction at the +/// call site. +/// +/// seq_put[sc] return -1 on error, 0 on success. +/// trace_seq_put[sc] return how much was written, which is either 0 or 1. +/// +/// In both cases, _putc is a drop-in replacement for _puts when the +/// argument is a one-character string. +/// +// +// Confidence: High +// Options: --no-includes --include-headers +// +// Since the changes to any given line should consist of changing an s +// to a c and two " to ', the generated patches should be easy to +// proofread. + +virtual patch +virtual context +virtual org +virtual report + +@putc1 depends on patch@ +position p; +expression s; +constant c; +@@ + \(trace_seq_puts@p\|seq_puts@p\)(s, c) + +// Use python to check whether the string constant consists of a +// single character, and if so, create an "identifier" containing that +// single character as a C literal. +@script:python putc2@ +s << putc1.s; +c << putc1.c; +ch; +@@ +import re +import sys + +m = re.match("^\"(.|\\\\.)\"$", c) +if not m: + cocci.include_match(False) +else: + coccinelle.ch = "'" + m.group(1) + "'" + +@putc3 depends on patch@ +position putc1.p; +expression putc1.s; +constant putc1.c; +identifier putc2.ch; +@@ +( +- seq_puts@p(s, c) ++ seq_putc(s, ch) +| +- trace_seq_puts@p(s, c) ++ trace_seq_putc(s, ch) +)
Signature · 1 line
2.0.4
Re: [PATCH 1/6] Coccinelle: Semantic patch for replacing puts with putc
Quoted 2 lines
Using
seq_putsto write a one-character string is suboptimal, since puts has to callstrlen().
Are there any more functions which work with such strings in a similar way? Would it make sense to look also at other function names?
Regards,
Markus
PATCH 2/6 Coccinelle: Semantic patch for joining seq_puts calls
In reply to Rasmus VillemoesConsecutive calls of seq_puts with literal strings, where the return value is not checked, might as well be replaced by a single call with the combined string. This gives smaller generated code (less function calls), a slight .rodata reduction, since nul and padding bytes are eliminated, and hits fewer cache lines (nothing guarantees that the linker places string literals which are used together close together in the final image).
--- scripts/coccinelle/api/seq_puts_concat.cocci | 71 ++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 scripts/coccinelle/api/seq_puts_concat.cocci
scripts/coccinelle/api/seq_puts_concat.cocci new file +71 -0
@@ -0,0 +1,71 @@ +/// Consecutive calls of seq_puts with literal strings, where the +/// return value is not checked, might as well be replaced by a single +/// call with the combined string. This gives smaller generated code +/// (less function calls), a slight .rodata reduction, since nul and +/// padding bytes are eliminated, and hits fewer cache lines (nothing +/// guarantees that the linker places string literals which are used +/// together close together in the final image). +/// +/// Two small, but in practice irrelevant, issues: +/// +/// (1) If one of the strings is also used elsewhere, this reduces the +/// possiblity for the linker to do string merging (thus increasing +/// .rodata), but these multiple seq_puts calls are mostly to print +/// multi-line headers in various /proc or /sys files. +/// +/// (2) seq_puts is all-or-nothing, so if there is not room for the +/// entire string, one would previously get some of the strings +/// printed, but not all; combining the strings means nothing is +/// printed. So this formally changes the semantics of the +/// code. However, usually there is room. +/// +/// +// +// Run and apply repeatedly until no furter patches are generated, +// then fix up the whitespace. +// +// Confidence: High +// Options: --no-includes --include-headers + + +virtual patch +virtual context +virtual org +virtual report + +// Prevent "token already tagged" error +@r@ +position p; +@@ + seq_puts(...); + seq_puts(...); + seq_puts@p(...); + + +@concat1 depends on patch@ +expression s; +constant c1, c2; +position p1 != r.p, p2 != r.p; +@@ + seq_puts@p1(s, c1); + seq_puts@p2(s, c2); + +@script:python concat2@ +c1 << concat1.c1; +c2 << concat1.c2; +c3; +@@ + +// The indentation probably needs to be fixed manually +coccinelle.c3 = c1 + "\n\t" + c2 + +@concat3 depends on patch@ +identifier concat2.c3; +expression concat1.s; +constant concat1.c1, concat1.c2; +position concat1.p1, concat1.p2; +@@ +- seq_puts@p1(s, c1); +- seq_puts@p2(s, c2); ++ seq_puts(s, c3); +
Signature · 1 line
2.0.4
PATCH 3/6 Coccinelle: Semantic patch for replacing seq_printf calls with equivalent but simpler functions
In reply to Rasmus VillemoesUsing seq_printf to print a simple string is a lot more expensive than it needs to be, since seq_puts exists [1]. This semantic patch purposely also matches non-literals, since in that case it is also safer to use puts.
We also handle the cases where the format string is exactly "%s" or "%c" and replace with puts/putc.
[1] printf must push all the, in this case non-existent, varargs into a va_arg structure on the stack, then vprintf takes over and calls vsnprintf, ...
seq_{printf,puts,putc} all return -1 on error, 0 on success.
trace_seq_{printf,puts,putc} all return 0 on failure, but printf and putc return 1 on success, puts returns the length of the string. Therefore, we only do the printf->puts conversion where the return value of trace_seq_printf is either unused or used as a boolean; the printf->putc conversion can safely be done anywhere.
--- scripts/coccinelle/api/seq_printf.cocci | 156 ++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 scripts/coccinelle/api/seq_printf.cocci
scripts/coccinelle/api/seq_printf.cocci new file +156 -0
@@ -0,0 +1,156 @@ +/// Using seq_printf to print a simple string is a lot more expensive +/// than it needs to be, since seq_puts exists [1]. This semantic +/// patch purposely also matches non-literals, since in that case it +/// is also safer to use puts. +/// +/// We also handle the cases where the format string is exactly "%s" +/// or "%c" and replace with puts/putc. +/// +/// [1] printf must push all the, in this case non-existent, varargs +/// into a va_arg structure on the stack, then vprintf takes over and +/// calls vsnprintf, ... +/// +/// seq_{printf,puts,putc} all return -1 on error, 0 on success. +/// +/// trace_seq_{printf,puts,putc} all return 0 on failure, but printf +/// and putc return 1 on success, puts returns the length of the +/// string. Therefore, we only do the printf->puts conversion where +/// the return value of trace_seq_printf is either unused or used as a +/// boolean; the printf->putc conversion can safely be done anywhere. +/// +// +// Confidence: High +// Options: --no-includes --include-headers +// + +virtual patch +virtual context +virtual org +virtual report + + +// In order to DTRT when the format string contains %%, we need to +// process it with python. If t is actually an expression and not just +// a string literal, it is very unlikely to contain two adjacent % +// characters. But note that this does not handle the case where t is +// either a macro or a const char* which happens to point to a string +// containing two %%. git grep 'define.*%%' shows that macros +// containing %% are usually used in inline asm, and register +// specifiers tend to be unusable as format specifiers. +@p1a depends on patch@ +expression s; +expression t; +position p; +@@ + seq_printf@p(s, t) + +@script:python p1b@ +t << p1a.t; +tt; +@@ +import re +coccinelle.tt = re.sub('%%', '%', t) + +@p1c depends on p1a@ +expression p1a.s; +expression p1a.t; +position p1a.p; +identifier p1b.tt; +@@ +- seq_printf@p(s, t) ++ seq_puts(s, tt) + +// Using the string literal "%s" seems to be broken with my version of +// coccinelle (it matches any format string containing a single format +// specifier), so use a slightly uglier method. +@p2 depends on patch@ +expression s; +expression t; +format f =~ "^s$"; +@@ +- seq_printf(s, "%@f@", t) ++ seq_puts(s, t) + +@p3 depends on patch@ +expression s; +expression t; +format f =~ "^c$"; +@@ +- seq_printf(s, "%@f@", t) ++ seq_putc(s, t) + + + + +@tp1a depends on patch@ +expression s; +expression t; +position p; +@@ + trace_seq_printf@p(s, t); + +@script:python tp1b@ +t << tp1a.t; +tt; +@@ +import re +coccinelle.tt = re.sub('%%', '%', t) + +@tp1c depends on tp1a@ +expression tp1a.s; +expression tp1a.t; +position tp1a.p; +identifier tp1b.tt; +@@ +- trace_seq_printf@p(s, t); ++ trace_seq_puts(s, tt); + +@tp2 depends on patch@ +expression s; +expression t; +format f =~ "^s$"; +@@ +- trace_seq_printf(s, "%@f@", t); ++ trace_seq_puts(s, t); + + +@tp3a depends on patch@ +expression s; +expression t; +position p; +@@ + !trace_seq_printf@p(s, t) + +@script:python tp3b@ +t << tp3a.t; +tt; +@@ +import re +coccinelle.tt = re.sub('%%', '%', t) + +@tp3c depends on tp3a@ +expression tp3a.s; +expression tp3a.t; +position tp3a.p; +identifier tp3b.tt; +@@ +- !trace_seq_printf@p(s, t) ++ !trace_seq_puts(s, tt) + +@tp4 depends on patch@ +expression s; +expression t; +format f =~ "^s$"; +@@ +- !trace_seq_printf(s, "%@f@", t) ++ !trace_seq_puts(s, t) + + +@tp5 depends on patch@ +expression s; +expression t; +format f =~ "^c$"; +@@ +- trace_seq_printf(s, "%@f@", t) ++ trace_seq_putc(s, t) +
Signature · 1 line
2.0.4
PATCH 4/6 trace: Replace seq_printf by simpler equivalents
In reply to Rasmus VillemoesUsing seq_printf to print a simple string or a single character is a lot more expensive than it needs to be, since seq_puts and seq_putc exist.
These patches do
seq_printf(m, s) -> seq_puts(m, s)
seq_printf(m, "%s", s) -> seq_puts(m, s)
seq_printf(m, "%c", c) -> seq_putc(m, c)
Subsequent patches will simplify further.
--- kernel/trace/ftrace.c | 30 ++++++++++++------------ kernel/trace/trace.c | 44 ++++++++++++++++++------------------ kernel/trace/trace_branch.c | 24 +++++++++----------- kernel/trace/trace_events.c | 4 ++-- kernel/trace/trace_events_trigger.c | 2 +- kernel/trace/trace_functions.c | 2 +- kernel/trace/trace_functions_graph.c | 28 +++++++++++------------ kernel/trace/trace_kprobe.c | 4 ++-- kernel/trace/trace_uprobe.c | 2 +- 9 files changed, 69 insertions(+), 71 deletions(-)
kernel/trace/ftrace.c +15 -15
@@ -556,13 +556,13 @@ static int function_stat_cmp(void *p1, void *p2)static int function_stat_headers (struct seq_file *m) {#ifdef CONFIG_FUNCTION_GRAPH_TRACER -seq_printf (m," Function " -"Hit Time Avg s^2\n" -" -------- " -"--- ---- --- ---\n" ); +seq_puts (m, +" Function " "Hit Time Avg s^2\n" +" -------- " "--- ---- --- ---\n" );#else -seq_printf (m," Function Hit\n" -" -------- ---\n" ); +seq_puts (m, +" Function Hit\n" +" -------- ---\n" );#endif return 0 ; }
@@ -589,7 +589,7 @@ static int function_stat_show(struct seq_file *m, void *v)seq_printf (m," %-30.30s %10lu" , str, rec->counter);#ifdef CONFIG_FUNCTION_GRAPH_TRACER -seq_printf (m," " ); +seq_puts (m," " ); avg = rec->time;do_div (avg, rec->counter);
@@ -2941,9 +2941,9 @@ static int t_show(struct seq_file *m, void *v)if (iter->flags &FTRACE_ITER_PRINTALL ) {if (iter->flags &FTRACE_ITER_NOTRACE ) -seq_printf (m,"#### no functions disabled ####\n" ); +seq_puts (m,"#### no functions disabled ####\n" );else -seq_printf (m,"#### all functions enabled ####\n" ); +seq_puts (m,"#### all functions enabled ####\n" );return 0 ; }
@@ -2965,11 +2965,11 @@ static int t_show(struct seq_file *m, void *v)seq_printf (m,"\ttramp: %pS" , (void *)ops->trampoline); else - seq_printf(m, "\ttramp: ERROR!"); + seq_puts(m, "\ttramp: ERROR!"); } } -seq_printf (m,"\n" ); +seq_puts (m,"\n" );return 0 ; }
@@ -4149,9 +4149,9 @@ static int g_show(struct seq_file *m, void *v)struct ftrace_graph_data *fgd = m->private;if (fgd->table == ftrace_graph_funcs) -seq_printf (m,"#### all functions enabled ####\n" ); +seq_puts (m,"#### all functions enabled ####\n" );else -seq_printf (m,"#### no functions disabled ####\n" ); +seq_puts (m,"#### no functions disabled ####\n" );return 0 ; }
@@ -4989,12 +4989,12 @@ static int fpid_show(struct seq_file *m, void *v) const struct ftrace_pid *fpid = list_entry(v, struct ftrace_pid, list);if (v == (void *)1 ) { -seq_printf (m,"no pid\n" ); +seq_puts (m,"no pid\n" );return 0 ; }if (fpid->pid == ftrace_swapper_pid) -seq_printf (m,"swapper tasks\n" ); +seq_puts (m,"swapper tasks\n" );else seq_printf (m,"%u\n" ,pid_vnr (fpid->pid));
kernel/trace/trace.c +22 -22
83 lines not on this page · raw message
kernel/trace/trace_branch.c +11 -13
@@ -233,12 +233,13 @@ extern unsigned long __stop_annotated_branch_profile[];static int annotated_branch_stat_headers (struct seq_file *m) { -seq_printf (m," correct incorrect %% " ); -seq_printf (m," Function " -" File Line\n" -" ------- --------- - " -" -------- " -" ---- ----\n" ); +seq_puts (m," correct incorrect % " ); +seq_puts (m, +" Function " +" File Line\n" +" ------- --------- - " +" -------- " +" ---- ----\n" );return 0 ; }
@@ -274,7 +275,7 @@ static int branch_stat_show(struct seq_file *m, void *v)seq_printf (m,"%8lu %8lu " , p->correct, p->incorrect);if (percent <0 ) -seq_printf (m," X " ); +seq_puts (m," X " );else seq_printf (m,"%3ld " , percent);seq_printf (m,"%-30.30s %-20.20s %d\n" , p->func, f, p->line);
@@ -362,12 +363,9 @@ extern unsigned long __stop_branch_profile[];static int all_branch_stat_headers (struct seq_file *m) { -seq_printf (m," miss hit %% " ); -seq_printf (m," Function " -" File Line\n" -" ------- --------- - " -" -------- " -" ---- ----\n" ); +seq_puts (m," miss hit % " ); +seq_puts (m, +" Function " " File Line\n" " ------- --------- - " " -------- " " ---- ----\n" );return 0 ; }
kernel/trace/trace_events.c +2 -2
@@ -918,7 +918,7 @@ static int f_show(struct seq_file *m, void *v)case FORMAT_HEADER :seq_printf (m,"name: %s\n" ,ftrace_event_name (call));seq_printf (m,"ID: %d\n" , call->event.type); -seq_printf (m,"format:\n" ); +seq_puts (m,"format:\n" );return 0 ;case FORMAT_FIELD_SEPERATOR :
@@ -1988,7 +1988,7 @@ event_enable_print(struct seq_file *m, unsigned long ip, ftrace_event_name(data->file->event_call));if (data->count ==-1 ) -seq_printf (m,":unlimited\n" ); +seq_puts (m,":unlimited\n" );else seq_printf (m,":count=%ld\n" , data->count);
kernel/trace/trace_events_trigger.c +1 -1
@@ -373,7 +373,7 @@ event_trigger_print(const char *name, struct seq_file *m, {long count = (long )data; -seq_printf (m,"%s" , name); +seq_puts (m, name);if (count ==-1 )seq_puts (m,":unlimited" );
kernel/trace/trace_functions.c +1 -1
@@ -361,7 +361,7 @@ ftrace_probe_print(const char *name, struct seq_file *m,seq_printf (m,"%ps:%s" , (void *)ip, name);if (count ==-1 ) -seq_printf (m,":unlimited\n" ); +seq_puts (m,":unlimited\n" );else seq_printf (m,":count=%ld\n" , count);
kernel/trace/trace_functions_graph.c +14 -14
@@ -1407,32 +1407,32 @@ static void __print_graph_headers_flags(struct seq_file *s, u32 flags)print_lat_header (s, flags);/* 1st line */ -seq_printf (s,"#" ); +seq_puts (s,"#" );if (flags &TRACE_GRAPH_PRINT_ABS_TIME ) -seq_printf (s," TIME " ); +seq_puts (s," TIME " );if (flags &TRACE_GRAPH_PRINT_CPU ) -seq_printf (s," CPU" ); +seq_puts (s," CPU" );if (flags &TRACE_GRAPH_PRINT_PROC ) -seq_printf (s," TASK/PID " ); +seq_puts (s," TASK/PID " );if (lat) -seq_printf (s,"||||" ); +seq_puts (s,"||||" );if (flags &TRACE_GRAPH_PRINT_DURATION ) -seq_printf (s," DURATION " ); -seq_printf (s," FUNCTION CALLS\n" ); +seq_puts (s," DURATION " ); +seq_puts (s," FUNCTION CALLS\n" );/* 2nd line */ -seq_printf (s,"#" ); +seq_puts (s,"#" );if (flags &TRACE_GRAPH_PRINT_ABS_TIME ) -seq_printf (s," | " ); +seq_puts (s," | " );if (flags &TRACE_GRAPH_PRINT_CPU ) -seq_printf (s," | " ); +seq_puts (s," | " );if (flags &TRACE_GRAPH_PRINT_PROC ) -seq_printf (s," | | " ); +seq_puts (s," | | " );if (lat) -seq_printf (s,"||||" ); +seq_puts (s,"||||" );if (flags &TRACE_GRAPH_PRINT_DURATION ) -seq_printf (s," | | " ); -seq_printf (s," | | | |\n" ); +seq_puts (s," | | " ); +seq_puts (s," | | | |\n" ); }static void print_graph_headers (struct seq_file *s)
kernel/trace/trace_kprobe.c +2 -2
@@ -826,7 +826,7 @@ static int probes_seq_show(struct seq_file *m, void *v)struct trace_kprobe *tk = v;int i; -seq_printf (m,"%c" ,trace_kprobe_is_return (tk) ?'r' :'p' ); +seq_putc (m,trace_kprobe_is_return (tk) ?'r' :'p' );seq_printf (m,":%s/%s" , tk->tp.call.class->system,ftrace_event_name (&tk->tp.call));
@@ -840,7 +840,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tk->tp.nr_args; i++)seq_printf (m," %s=%s" , tk->tp.args[i].name, tk->tp.args[i].comm); -seq_printf (m,"\n" ); +seq_puts (m,"\n" );return 0 ; }
kernel/trace/trace_uprobe.c +1 -1
@@ -606,7 +606,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tu->tp.nr_args; i++)seq_printf (m," %s=%s" , tu->tp.args[i].name, tu->tp.args[i].comm); -seq_printf (m,"\n" ); +seq_puts (m,"\n" );return 0 ; }
Signature · 1 line
2.0.4
Steven Rostedt
maintainerRe: [PATCH 4/6] trace: Replace seq_printf by simpler equivalents
Quoted 30 lines · On Fri, 12 Sep 2014 11:25:52 +0200 Rasmus Villemoes <[email protected]>…
Using
seq_printfto print a simple string or a single character is a lot more expensive than it needs to be, sinceseq_putsandseq_putcexist.These patches do
seq_printf(m, s)->seq_puts(m, s)
seq_printf(m, "%s", s)->seq_puts(m, s)
seq_printf(m, "%c", c)->seq_putc(m, c)Subsequent patches will simplify further.
Signed-off-by Rasmus Villemoes <[email protected]>--- kernel/trace/ftrace.c | 30 ++++++++++++------------ kernel/trace/trace.c | 44 ++++++++++++++++++------------------ kernel/trace/trace_branch.c | 24 +++++++++----------- kernel/trace/trace_events.c | 4 ++-- kernel/trace/trace_events_trigger.c | 2 +- kernel/trace/trace_functions.c | 2 +- kernel/trace/trace_functions_graph.c | 28 +++++++++++------------ kernel/trace/trace_kprobe.c | 4 ++-- kernel/trace/trace_uprobe.c | 2 +- 9 files changed, 69 insertions(+), 71 deletions(-)kernel/trace/ftrace.c +0
-0
kernel/trace/ftrace.c static int function_stat_cmp(void *p1, void *p2) · line 561
Quoted 10 lines
kernel/trace/ftrace.c +3
-4@@ -556,13 +556,13 @@ static int function_stat_cmp(void *p1, void *p2)static int function_stat_headers (struct seq_file *m) {#ifdef CONFIG_FUNCTION_GRAPH_TRACER -seq_printf (m," Function " -"Hit Time Avg s^2\n" -" -------- " -"--- ---- --- ---\n" ); +seq_puts (m, +" Function " "Hit Time Avg s^2\n" +" -------- " "--- ---- --- ---\n" );
Please keep the original format. I know that it's considered bad form to split strings like this, but I consider this one of the exceptions to the rule.
Quoted 13 lines
kernel/trace/ftrace.c +3
-2#else -seq_printf (m," Function Hit\n" -" -------- ---\n" ); +seq_puts (m, +" Function Hit\n" +" -------- ---\n" );#endif return 0 ; }
kernel/trace/ftrace.c static int t_show(struct seq_file *m, void *v) · line 3253
Quoted 5 lines
kernel/trace/ftrace.c +1
-1@@ -3250,7 +3250,7 @@ static int t_show(struct seq_file *m, void *v)if (!t)return 0 ; -seq_printf (m,"%s" , t->name); +seq_puts (m, t->name);
This is wrong and dangerous.
What happens if "t->name" contains "%d" or "%s"?
Quoted 20 lines
kernel/trace/ftrace.c +2
-2if (t->next)seq_putc (m,' ' );else @@ -5752,10 +5752,10 @@ ftrace_snapshot_print(struct seq_file *m, unsigned long ip,seq_printf (m,"%ps:" , (void *)ip); -seq_printf (m,"snapshot" ); +seq_puts (m,"snapshot" );if (count ==-1 ) -seq_printf (m,":unlimited\n" ); +seq_puts (m,":unlimited\n" );else seq_printf (m,":count=%ld\n" , count);static int
all_branch_stat_headers(struct seq_file *m){
kernel/trace/ftrace.c
Quoted 9 lines
kernel/trace/ftrace.c +3
-6-seq_printf (m," miss hit %% " ); -seq_printf (m," Function " -" File Line\n" -" ------- --------- - " -" -------- " -" ---- ----\n" ); +seq_puts (m," miss hit % " ); +seq_puts (m, +" Function " " File Line\n" " ------- --------- - " " -------- " " ---- ----\n" );
Again, keep the original formatting. We can fix it up later, but not with this patch.
kernel/trace/trace_events_trigger.c event_trigger_print(const char *name, struct seq_file *m, · line 376
Quoted 13 lines
kernel/trace/ftrace.c +0
-0return 0 ; }kernel/trace/trace_events_trigger.c +1
-1@@ -373,7 +373,7 @@ event_trigger_print(const char *name, struct seq_file *m, {long count = (long )data; -seq_printf (m,"%s" , name); +seq_puts (m, name);
Again, this is wrong and dangerous.
-- Steve
Quoted 3 lines
kernel/trace/trace_events_trigger.c +0
-0if (count ==-1 )seq_puts (m,":unlimited" );
Re: [PATCH 4/6] trace: Replace seq_printf by simpler equivalents
Quoted 14 lines · Steven Rostedt
Quoted 11 lines · On Fri, 12 Sep 2014 11:25:52 +0200 Rasmus Villemoes <[email protected]>…
kernel/trace/ftrace.c +0
-3@@ -556,13 +556,13 @@ static int function_stat_cmp(void *p1, void *p2)static int function_stat_headers (struct seq_file *m) {#ifdef CONFIG_FUNCTION_GRAPH_TRACER -seq_printf (m," Function " -"Hit Time Avg s^2\n" - " -------- "
Quoted 8 lines
kernel/trace/ftrace.c static int function_stat_cmp(void *p1, void *p2) · line 561
Quoted 4 lines
kernel/trace/ftrace.c +3
-1- "--- ---- --- ---\n"); +seq_puts (m, +" Function " "Hit Time Avg s^2\n" +" -------- " "--- ---- --- ---\n" );Please keep the original format. I know that it's considered bad form to split strings like this, but I consider this one of the exceptions to the rule.
OK. Want me to resend?
Quoted 10 lines
kernel/trace/ftrace.c static int t_show(struct seq_file *m, void *v) · line 3253
Quoted 6 lines
kernel/trace/ftrace.c +1
-1@@ -3250,7 +3250,7 @@ static int t_show(struct seq_file *m, void *v)if (!t)return 0 ; -seq_printf (m,"%s" , t->name); +seq_puts (m, t->name);This is wrong and dangerous.
What happens if "
t->name" contains "%d" or "%s"?
Then those characters will be printed to the seq_file, just as they would previously? puts doesn't interpret its string argument in any way...
Quoted 10 lines
kernel/trace/trace_events_trigger.c event_trigger_print(const char *name, struct seq_file *m, · line 376
Quoted 8 lines
kernel/trace/trace_events_trigger.c +1
-1@@ -373,7 +373,7 @@ event_trigger_print(const char *name, struct seq_file *m, {long count = (long )data; -seq_printf (m,"%s" , name); +seq_puts (m, name);Again, this is wrong and dangerous.
I'm pretty sure it's neither :-)
Rasmus
Steven Rostedt
maintainerRe: [PATCH 4/6] trace: Replace seq_printf by simpler equivalents
Quoted 25 lines · On Wed, 05 Nov 2014 23:44:17 +0100 Rasmus Villemoes <[email protected]>…
Quoted 14 lines · Steven Rostedt
Quoted 11 lines · On Fri, 12 Sep 2014 11:25:52 +0200 Rasmus Villemoes <[email protected]>…
kernel/trace/ftrace.c +0
-3@@ -556,13 +556,13 @@ static int function_stat_cmp(void *p1, void *p2)static int function_stat_headers (struct seq_file *m) {#ifdef CONFIG_FUNCTION_GRAPH_TRACER -seq_printf (m," Function " -"Hit Time Avg s^2\n" - " -------- "Quoted 8 lines
kernel/trace/ftrace.c static int function_stat_cmp(void *p1, void *p2) · line 561
Quoted 4 lines
kernel/trace/ftrace.c +3
-1- "--- ---- --- ---\n"); +seq_puts (m, +" Function " "Hit Time Avg s^2\n" +" -------- " "--- ---- --- ---\n" );Please keep the original format. I know that it's considered bad form to split strings like this, but I consider this one of the exceptions to the rule.
Quoted 1 line
OK. Want me to resend?
Yeah, can you.
Quoted 22 lines
Quoted 11 lines
kernel/trace/ftrace.c static int t_show(struct seq_file *m, void *v) · line 3253
Quoted 7 lines
kernel/trace/ftrace.c +1
-1@@ -3250,7 +3250,7 @@ static int t_show(struct seq_file *m, void *v)if (!t)return 0 ; -seq_printf (m,"%s" , t->name); +seq_puts (m, t->name);This is wrong and dangerous.
What happens if "
t->name" contains "%d" or "%s"?Then those characters will be printed to the
seq_file, just as they would previously? puts doesn't interpret its string argument in any way...Quoted 6 lines
Quoted 6 lines
kernel/trace/trace_events_trigger.c +0
-0@@ -373,7 +373,7 @@ event_trigger_print(const char *name, struct seq_file *m, {long count = (long )data;
Quoted 6 lines
Quoted 4 lines
kernel/trace/trace_events_trigger.c event_trigger_print(const char *name, struct seq_file *m, · line 376
Quoted 2 lines
kernel/trace/trace_events_trigger.c +1
-1-seq_printf (m,"%s" , name); +seq_puts (m, name);Again, this is wrong and dangerous.
I'm pretty sure it's neither :-)
Ah you're correct. I was thinking of it as a printf and not a puts.
Never mind ;-) /me needs to work on only 3 different projects at once, not 4. :-p
-- Steve
Re: [PATCH 4/6] trace: Replace seq_printf by simpler equivalents
In reply to Steven RostedtQuoted 4 lines · Steven Rostedt
Quoted 3 lines · On Fri, 12 Sep 2014 11:25:52 +0200 Rasmus Villemoes <[email protected]>…
Using
seq_printfto print a simple string or a single character is a lot more expensive than it needs to be, sinceseq_putsandseq_putcexist.
[]
Quoted 1 line
kernel/trace/ftrace.c
Quoted 1 line
kernel/trace/ftrace.c +0
-0
[]
Quoted 7 lines
(quoted diff) +0
-0@@ -556,13 +556,13 @@ static int function_stat_cmp(void *p1, void *p2) > static int function_stat_headers(struct seq_file *m) > {Quoted 4 lines
#ifdef
CONFIG_FUNCTION_GRAPH_TRACERkernel/trace/ftrace.c +0
-3-seq_printf (m," Function " -"Hit Time Avg s^2\n" - " -------- "
Quoted 8 lines
kernel/trace/ftrace.c static int function_stat_cmp(void *p1, void *p2) · line 561
Quoted 4 lines
kernel/trace/ftrace.c +3
-1- "--- ---- --- ---\n"); +seq_puts (m, +" Function " "Hit Time Avg s^2\n" +" -------- " "--- ---- --- ---\n" );Please keep the original format. I know that it's considered bad form to split strings like this, but I consider this one of the exceptions to the rule.
Why is that?
btw: when the strings fragments are put on the same line, it's nicer to take out the intermediate joining " " bits too.
I'd've probably used 2 seq_puts calls like:
seq_puts(m, " Function Hit Time Avg s^2\n"); seq_puts(m, " -------- --- ---- --- ---\n");
Steven Rostedt
maintainerRe: [PATCH 4/6] trace: Replace seq_printf by simpler equivalents
Quoted 26 lines · On Wed, 05 Nov 2014 14:51:48 -0800 Joe Perches <[email protected]> wrote:
Quoted 4 lines · Steven Rostedt
Quoted 3 lines · On Fri, 12 Sep 2014 11:25:52 +0200 Rasmus Villemoes <[email protected]>…
Using
seq_printfto print a simple string or a single character is a lot more expensive than it needs to be, sinceseq_putsandseq_putcexist.[]
Quoted 1 line
kernel/trace/ftrace.c
Quoted 1 line
kernel/trace/ftrace.c +0
-0[]
Quoted 7 lines
(quoted diff) +0
-0@@ -556,13 +556,13 @@ static int function_stat_cmp(void *p1, void *p2) > static int function_stat_headers(struct seq_file *m) > {Quoted 4 lines
#ifdef
CONFIG_FUNCTION_GRAPH_TRACERkernel/trace/ftrace.c +0
-3-seq_printf (m," Function " -"Hit Time Avg s^2\n" - " -------- "Quoted 8 lines
kernel/trace/ftrace.c static int function_stat_cmp(void *p1, void *p2) · line 561
Quoted 4 lines
kernel/trace/ftrace.c +3
-1- "--- ---- --- ---\n"); +seq_puts (m, +" Function " "Hit Time Avg s^2\n" +" -------- " "--- ---- --- ---\n" );Please keep the original format. I know that it's considered bad form to split strings like this, but I consider this one of the exceptions to the rule.
Why is that?
Quoted 8 lines
btw: when the strings fragments are put on the same line, it's nicer to take out the intermediate joining " " bits too.
I'd've probably used 2
seq_putscalls like:seq_puts(m, " Function Hit Time Avg s^2\n"); seq_puts(m, " -------- --- ---- --- ---\n");
In this case it's just that I hate that big white space followed by content.
Maybe I'll change my mind in the future, but for now, I'd rather just leave it as is.
-- Steve
Re: [PATCH 4/6] trace: Replace seq_printf by simpler equivalents
Quoted 1 line · Steven Rostedt
On Wed, 05 Nov 2014 14:51:48 -0800 Joe Perches <[email protected]> wrote:
[]
Quoted 15 lines
Quoted 6 lines
Quoted 3 lines
I know that it's considered bad form
to split strings like this, but I consider this one of the exceptions to the rule.Why is that?
Quoted 8 lines
btw: when the strings fragments are put on the same line, it's nicer to take out the intermediate joining " " bits too.
I'd've probably used 2
seq_putscalls like:seq_puts(m, " Function Hit Time Avg s^2\n"); seq_puts(m, " -------- --- ---- --- ---\n");
Quoted 5 lines
In this case it's just that I hate that big white space followed by content.
Maybe I'll change my mind in the future, but for now, I'd rather just leave it as is.
My eyes generally skip over the embedded whitespace.
It's also generally less code space to use a single format string instead of something like:
printf(" %-39s%-7s%-16s%-16s%s\n", "Function", "Hit", "Time", "Avg", "s^2");v2 cover trace: Use simpler seq_file functions
In reply to Rasmus VillemoesUsing printf to print a simple string or puts to print a single character is more expensive than it needs to be. Also, consecutive puts calls can be replaced by a single call. These patches do this to kernel/trace/, saving ~256 bytes of .text.
v2: Keep the original splitting of strings across lines.
Rasmus Villemoes (3):
trace: Replace seq_printf by simpler equivalents
trace: Merge consecutive seq_puts calls
trace: Replace single-character seq_puts with seq_putc
kernel/trace/ftrace.c | 30 +++++++------- kernel/trace/trace.c | 78 ++++++++++++++++++------------------ kernel/trace/trace_branch.c | 32 +++++++-------- kernel/trace/trace_events.c | 4 +- kernel/trace/trace_events_trigger.c | 6 +-- kernel/trace/trace_functions.c | 2 +- kernel/trace/trace_functions_graph.c | 28 ++++++------- kernel/trace/trace_kprobe.c | 12 +++--- kernel/trace/trace_printk.c | 2 +- kernel/trace/trace_uprobe.c | 4 +- 10 files changed, 99 insertions(+), 99 deletions(-)
Signature · 1 line
2.0.4
PATCH v2 1/3 trace: Replace seq_printf by simpler equivalents
Using seq_printf to print a simple string or a single character is a lot more expensive than it needs to be, since seq_puts and seq_putc exist.
These patches do
seq_printf(m, s) -> seq_puts(m, s)
seq_printf(m, "%s", s) -> seq_puts(m, s)
seq_printf(m, "%c", c) -> seq_putc(m, c)
Subsequent patches will simplify further.
--- kernel/trace/ftrace.c | 30 ++++++++++++------------ kernel/trace/trace.c | 44 ++++++++++++++++++------------------ kernel/trace/trace_branch.c | 26 ++++++++++----------- kernel/trace/trace_events.c | 4 ++-- kernel/trace/trace_events_trigger.c | 2 +- kernel/trace/trace_functions.c | 2 +- kernel/trace/trace_functions_graph.c | 28 +++++++++++------------ kernel/trace/trace_kprobe.c | 4 ++-- kernel/trace/trace_uprobe.c | 2 +- 9 files changed, 71 insertions(+), 71 deletions(-)
kernel/trace/ftrace.c +15 -15
@@ -556,13 +556,13 @@ static int function_stat_cmp(void *p1, void *p2)static int function_stat_headers (struct seq_file *m) {#ifdef CONFIG_FUNCTION_GRAPH_TRACER -seq_printf (m," Function " -"Hit Time Avg s^2\n" -" -------- " -"--- ---- --- ---\n" ); +seq_puts (m," Function " +"Hit Time Avg s^2\n" +" -------- " +"--- ---- --- ---\n" );#else -seq_printf (m," Function Hit\n" -" -------- ---\n" ); +seq_puts (m," Function Hit\n" +" -------- ---\n" );#endif return 0 ; }
@@ -589,7 +589,7 @@ static int function_stat_show(struct seq_file *m, void *v)seq_printf (m," %-30.30s %10lu" , str, rec->counter);#ifdef CONFIG_FUNCTION_GRAPH_TRACER -seq_printf (m," " ); +seq_puts (m," " ); avg = rec->time;do_div (avg, rec->counter);
@@ -2941,9 +2941,9 @@ static int t_show(struct seq_file *m, void *v)if (iter->flags &FTRACE_ITER_PRINTALL ) {if (iter->flags &FTRACE_ITER_NOTRACE ) -seq_printf (m,"#### no functions disabled ####\n" ); +seq_puts (m,"#### no functions disabled ####\n" );else -seq_printf (m,"#### all functions enabled ####\n" ); +seq_puts (m,"#### all functions enabled ####\n" );return 0 ; }
@@ -2965,11 +2965,11 @@ static int t_show(struct seq_file *m, void *v)seq_printf (m,"\ttramp: %pS" , (void *)ops->trampoline); else - seq_printf(m, "\ttramp: ERROR!"); + seq_puts(m, "\ttramp: ERROR!"); } } -seq_printf (m,"\n" ); +seq_puts (m,"\n" );return 0 ; }
@@ -4149,9 +4149,9 @@ static int g_show(struct seq_file *m, void *v)struct ftrace_graph_data *fgd = m->private;if (fgd->table == ftrace_graph_funcs) -seq_printf (m,"#### all functions enabled ####\n" ); +seq_puts (m,"#### all functions enabled ####\n" );else -seq_printf (m,"#### no functions disabled ####\n" ); +seq_puts (m,"#### no functions disabled ####\n" );return 0 ; }
@@ -4989,12 +4989,12 @@ static int fpid_show(struct seq_file *m, void *v) const struct ftrace_pid *fpid = list_entry(v, struct ftrace_pid, list);if (v == (void *)1 ) { -seq_printf (m,"no pid\n" ); +seq_puts (m,"no pid\n" );return 0 ; }if (fpid->pid == ftrace_swapper_pid) -seq_printf (m,"swapper tasks\n" ); +seq_puts (m,"swapper tasks\n" );else seq_printf (m,"%u\n" ,pid_vnr (fpid->pid));
kernel/trace/trace.c +22 -22
83 lines not on this page · raw message
kernel/trace/trace_branch.c +13 -13
@@ -233,12 +233,12 @@ extern unsigned long __stop_annotated_branch_profile[];static int annotated_branch_stat_headers (struct seq_file *m) { -seq_printf (m," correct incorrect %% " ); -seq_printf (m," Function " -" File Line\n" -" ------- --------- - " -" -------- " -" ---- ----\n" ); +seq_puts (m," correct incorrect % " ); +seq_puts (m," Function " +" File Line\n" +" ------- --------- - " +" -------- " +" ---- ----\n" );return 0 ; }
@@ -274,7 +274,7 @@ static int branch_stat_show(struct seq_file *m, void *v)seq_printf (m,"%8lu %8lu " , p->correct, p->incorrect);if (percent <0 ) -seq_printf (m," X " ); +seq_puts (m," X " );else seq_printf (m,"%3ld " , percent);seq_printf (m,"%-30.30s %-20.20s %d\n" , p->func, f, p->line);
@@ -362,12 +362,12 @@ extern unsigned long __stop_branch_profile[];static int all_branch_stat_headers (struct seq_file *m) { -seq_printf (m," miss hit %% " ); -seq_printf (m," Function " -" File Line\n" -" ------- --------- - " -" -------- " -" ---- ----\n" ); +seq_puts (m," miss hit % " ); +seq_puts (m," Function " +" File Line\n" +" ------- --------- - " +" -------- " +" ---- ----\n" );return 0 ; }
kernel/trace/trace_events.c +2 -2
@@ -918,7 +918,7 @@ static int f_show(struct seq_file *m, void *v)case FORMAT_HEADER :seq_printf (m,"name: %s\n" ,ftrace_event_name (call));seq_printf (m,"ID: %d\n" , call->event.type); -seq_printf (m,"format:\n" ); +seq_puts (m,"format:\n" );return 0 ;case FORMAT_FIELD_SEPERATOR :
@@ -1988,7 +1988,7 @@ event_enable_print(struct seq_file *m, unsigned long ip, ftrace_event_name(data->file->event_call));if (data->count ==-1 ) -seq_printf (m,":unlimited\n" ); +seq_puts (m,":unlimited\n" );else seq_printf (m,":count=%ld\n" , data->count);
kernel/trace/trace_events_trigger.c +1 -1
@@ -373,7 +373,7 @@ event_trigger_print(const char *name, struct seq_file *m, {long count = (long )data; -seq_printf (m,"%s" , name); +seq_puts (m, name);if (count ==-1 )seq_puts (m,":unlimited" );
kernel/trace/trace_functions.c +1 -1
@@ -361,7 +361,7 @@ ftrace_probe_print(const char *name, struct seq_file *m,seq_printf (m,"%ps:%s" , (void *)ip, name);if (count ==-1 ) -seq_printf (m,":unlimited\n" ); +seq_puts (m,":unlimited\n" );else seq_printf (m,":count=%ld\n" , count);
kernel/trace/trace_functions_graph.c +14 -14
@@ -1407,32 +1407,32 @@ static void __print_graph_headers_flags(struct seq_file *s, u32 flags)print_lat_header (s, flags);/* 1st line */ -seq_printf (s,"#" ); +seq_puts (s,"#" );if (flags &TRACE_GRAPH_PRINT_ABS_TIME ) -seq_printf (s," TIME " ); +seq_puts (s," TIME " );if (flags &TRACE_GRAPH_PRINT_CPU ) -seq_printf (s," CPU" ); +seq_puts (s," CPU" );if (flags &TRACE_GRAPH_PRINT_PROC ) -seq_printf (s," TASK/PID " ); +seq_puts (s," TASK/PID " );if (lat) -seq_printf (s,"||||" ); +seq_puts (s,"||||" );if (flags &TRACE_GRAPH_PRINT_DURATION ) -seq_printf (s," DURATION " ); -seq_printf (s," FUNCTION CALLS\n" ); +seq_puts (s," DURATION " ); +seq_puts (s," FUNCTION CALLS\n" );/* 2nd line */ -seq_printf (s,"#" ); +seq_puts (s,"#" );if (flags &TRACE_GRAPH_PRINT_ABS_TIME ) -seq_printf (s," | " ); +seq_puts (s," | " );if (flags &TRACE_GRAPH_PRINT_CPU ) -seq_printf (s," | " ); +seq_puts (s," | " );if (flags &TRACE_GRAPH_PRINT_PROC ) -seq_printf (s," | | " ); +seq_puts (s," | | " );if (lat) -seq_printf (s,"||||" ); +seq_puts (s,"||||" );if (flags &TRACE_GRAPH_PRINT_DURATION ) -seq_printf (s," | | " ); -seq_printf (s," | | | |\n" ); +seq_puts (s," | | " ); +seq_puts (s," | | | |\n" ); }static void print_graph_headers (struct seq_file *s)
kernel/trace/trace_kprobe.c +2 -2
@@ -826,7 +826,7 @@ static int probes_seq_show(struct seq_file *m, void *v)struct trace_kprobe *tk = v;int i; -seq_printf (m,"%c" ,trace_kprobe_is_return (tk) ?'r' :'p' ); +seq_putc (m,trace_kprobe_is_return (tk) ?'r' :'p' );seq_printf (m,":%s/%s" , tk->tp.call.class->system,ftrace_event_name (&tk->tp.call));
@@ -840,7 +840,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tk->tp.nr_args; i++)seq_printf (m," %s=%s" , tk->tp.args[i].name, tk->tp.args[i].comm); -seq_printf (m,"\n" ); +seq_puts (m,"\n" );return 0 ; }
kernel/trace/trace_uprobe.c +1 -1
@@ -606,7 +606,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tu->tp.nr_args; i++)seq_printf (m," %s=%s" , tu->tp.args[i].name, tu->tp.args[i].comm); -seq_printf (m,"\n" ); +seq_puts (m,"\n" );return 0 ; }
Signature · 1 line
2.0.4
Steven Rostedt
maintainerRe: [PATCH v2 1/3] trace: Replace seq_printf by simpler equivalents
Quoted 21 lines · On Sat, 8 Nov 2014 21:42:10 +0100 Rasmus Villemoes <[email protected]>…
kernel/trace/trace_kprobe.c +2
-2-seq_printf (m,"\n" ); +seq_puts (m,"\n" );@@ -840,7 +840,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tk->tp.nr_args; i++)seq_printf (m," %s=%s" , tk->tp.args[i].name, tk->tp.args[i].comm); -seq_printf (m,"\n" ); +seq_puts (m,"\n" );return 0 ; }kernel/trace/trace_uprobe.c +0
-0
kernel/trace/trace_uprobe.c static int probes_seq_show(struct seq_file *m, void *v) · line 609
Quoted 5 lines
kernel/trace/trace_uprobe.c +1
-1@@ -606,7 +606,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tu->tp.nr_args; i++)seq_printf (m," %s=%s" , tu->tp.args[i].name, tu->tp.args[i].comm); -seq_printf (m,"\n" ); +seq_puts (m,"\n" );
These can actually be seq_putc(m, '\n');
I saw this because one of them conflicted with a change I already had.
No need to resend, I'll just update them myself. Trivial enough.
-- Steve
Quoted 3 lines
kernel/trace/trace_uprobe.c +0
-0return 0 ; }
PATCH v2 2/3 trace: Merge consecutive seq_puts calls
In reply to Rasmus VillemoesConsecutive seq_puts calls with literal strings can be merged to a single call. This reduces the size of the generated code, and can also lead to slight .rodata reduction (because of fewer nul and padding bytes). It should also shave a off a few clock cycles.
--- kernel/trace/trace.c | 64 ++++++++++++++++++++++----------------------- kernel/trace/trace_branch.c | 14 +++++----- 2 files changed, 39 insertions(+), 39 deletions(-)
kernel/trace/trace.c +32 -32
@@ -2508,14 +2508,14 @@ get_total_entries(struct trace_buffer *buf,static void print_lat_help_header (struct seq_file *m) { -seq_puts (m,"# _------=> CPU# \n" ); -seq_puts (m,"# / _-----=> irqs-off \n" ); -seq_puts (m,"# | / _----=> need-resched \n" ); -seq_puts (m,"# || / _---=> hardirq/softirq \n" ); -seq_puts (m,"# ||| / _--=> preempt-depth \n" ); -seq_puts (m,"# |||| / delay \n" ); -seq_puts (m,"# cmd pid ||||| time | caller \n" ); -seq_puts (m,"# \\ / ||||| \\ | / \n" ); +seq_puts (m,"# _------=> CPU# \n" +"# / _-----=> irqs-off \n" +"# | / _----=> need-resched \n" +"# || / _---=> hardirq/softirq \n" +"# ||| / _--=> preempt-depth \n" +"# |||| / delay \n" +"# cmd pid ||||| time | caller \n" +"# \\ / ||||| \\ | / \n" ); }static void print_event_info (struct trace_buffer *buf,struct seq_file *m)
@@ -2532,20 +2532,20 @@ static void print_event_info(struct trace_buffer *buf, struct seq_file *m)static void print_func_help_header (struct trace_buffer *buf,struct seq_file *m) {print_event_info (buf, m); -seq_puts (m,"# TASK-PID CPU# TIMESTAMP FUNCTION\n" ); -seq_puts (m,"# | | | | |\n" ); +seq_puts (m,"# TASK-PID CPU# TIMESTAMP FUNCTION\n" +"# | | | | |\n" ); }static void print_func_help_header_irq (struct trace_buffer *buf,struct seq_file *m) {print_event_info (buf, m); -seq_puts (m,"# _-----=> irqs-off\n" ); -seq_puts (m,"# / _----=> need-resched\n" ); -seq_puts (m,"# | / _---=> hardirq/softirq\n" ); -seq_puts (m,"# || / _--=> preempt-depth\n" ); -seq_puts (m,"# ||| / delay\n" ); -seq_puts (m,"# TASK-PID CPU# |||| TIMESTAMP FUNCTION\n" ); -seq_puts (m,"# | | | |||| | |\n" ); +seq_puts (m,"# _-----=> irqs-off\n" +"# / _----=> need-resched\n" +"# | / _---=> hardirq/softirq\n" +"# || / _--=> preempt-depth\n" +"# ||| / delay\n" +"# TASK-PID CPU# |||| TIMESTAMP FUNCTION\n" +"# | | | |||| | |\n" ); }void
@@ -2859,34 +2859,34 @@ static void test_ftrace_alive(struct seq_file *m) {if (!ftrace_is_dead ())return ; -seq_puts (m,"# WARNING: FUNCTION TRACING IS CORRUPTED\n" ); -seq_puts (m,"# MAY BE MISSING FUNCTION EVENTS\n" ); +seq_puts (m,"# WARNING: FUNCTION TRACING IS CORRUPTED\n" +"# MAY BE MISSING FUNCTION EVENTS\n" ); }#ifdef CONFIG_TRACER_MAX_TRACE static void show_snapshot_main_help (struct seq_file *m) { -seq_puts (m,"# echo 0 > snapshot : Clears and frees snapshot buffer\n" ); -seq_puts (m,"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" ); -seq_puts (m,"# Takes a snapshot of the main buffer.\n" ); -seq_puts (m,"# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n" ); -seq_puts (m,"# (Doesn't have to be '2' works with any number that\n" ); -seq_puts (m,"# is not a '0' or '1')\n" ); +seq_puts (m,"# echo 0 > snapshot : Clears and frees snapshot buffer\n" +"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" +"# Takes a snapshot of the main buffer.\n" +"# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n" +"# (Doesn't have to be '2' works with any number that\n" +"# is not a '0' or '1')\n" ); }static void show_snapshot_percpu_help (struct seq_file *m) {seq_puts (m,"# echo 0 > snapshot : Invalid for per_cpu snapshot file.\n" );#ifdef CONFIG_RING_BUFFER_ALLOW_SWAP -seq_puts (m,"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" ); -seq_puts (m,"# Takes a snapshot of the main buffer for this cpu.\n" ); +seq_puts (m,"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" +"# Takes a snapshot of the main buffer for this cpu.\n" );#else -seq_puts (m,"# echo 1 > snapshot : Not supported with this kernel.\n" ); -seq_puts (m,"# Must use main snapshot file to allocate.\n" ); +seq_puts (m,"# echo 1 > snapshot : Not supported with this kernel.\n" +"# Must use main snapshot file to allocate.\n" );#endif -seq_puts (m,"# echo 2 > snapshot : Clears this cpu's snapshot buffer (but does not allocate)\n" ); -seq_puts (m,"# (Doesn't have to be '2' works with any number that\n" ); -seq_puts (m,"# is not a '0' or '1')\n" ); +seq_puts (m,"# echo 2 > snapshot : Clears this cpu's snapshot buffer (but does not allocate)\n" +"# (Doesn't have to be '2' works with any number that\n" +"# is not a '0' or '1')\n" ); }static void print_snapshot_help (struct seq_file *m,struct trace_iterator *iter)
kernel/trace/trace_branch.c +7 -7
@@ -164,9 +164,9 @@ static enum print_line_t trace_branch_print(struct trace_iterator *iter,static void branch_print_header (struct seq_file *s) {seq_puts (s,"# TASK-PID CPU# TIMESTAMP CORRECT" -" FUNC:FILE:LINE\n" ); -seq_puts (s,"# | | | | | " -" |\n" ); +" FUNC:FILE:LINE\n" +"# | | | | | " +" |\n" ); }static struct trace_event_functions trace_branch_funcs = {
@@ -233,8 +233,8 @@ extern unsigned long __stop_annotated_branch_profile[];static int annotated_branch_stat_headers (struct seq_file *m) { -seq_puts (m," correct incorrect % " ); -seq_puts (m," Function " +seq_puts (m," correct incorrect % " +" Function " " File Line\n" " ------- --------- - " " -------- "
@@ -362,8 +362,8 @@ extern unsigned long __stop_branch_profile[];static int all_branch_stat_headers (struct seq_file *m) { -seq_puts (m," miss hit % " ); -seq_puts (m," Function " +seq_puts (m," miss hit % " +" Function " " File Line\n" " ------- --------- - " " -------- "
Signature · 1 line
2.0.4
PATCH v2 3/3 trace: Replace single-character seq_puts with seq_putc
In reply to Rasmus VillemoesPrinting a single character to a seqfile might as well be done with seq_putc instead of seq_puts; this avoids a strlen() call and a memory access. It also shaves another few bytes off the generated code.
--- kernel/trace/ftrace.c | 2 +- kernel/trace/trace_events_trigger.c | 4 ++-- kernel/trace/trace_functions_graph.c | 4 ++-- kernel/trace/trace_kprobe.c | 10 +++++----- kernel/trace/trace_printk.c | 2 +- kernel/trace/trace_uprobe.c | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-)
kernel/trace/ftrace.c +1 -1
@@ -2969,7 +2969,7 @@ static int t_show(struct seq_file *m, void *v) } } -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
kernel/trace/trace_events_trigger.c +2 -2
@@ -383,7 +383,7 @@ event_trigger_print(const char *name, struct seq_file *m,if (filter_str)seq_printf (m," if %s\n" , filter_str);else -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -1105,7 +1105,7 @@ event_enable_trigger_print(struct seq_file *m, struct event_trigger_ops *ops,if (data->filter_str)seq_printf (m," if %s\n" , data->filter_str);else -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
kernel/trace/trace_functions_graph.c +2 -2
@@ -1407,7 +1407,7 @@ static void __print_graph_headers_flags(struct seq_file *s, u32 flags)print_lat_header (s, flags);/* 1st line */ -seq_puts (s,"#" ); +seq_putc (s,'#' );if (flags &TRACE_GRAPH_PRINT_ABS_TIME )seq_puts (s," TIME " );if (flags &TRACE_GRAPH_PRINT_CPU )
@@ -1421,7 +1421,7 @@ static void __print_graph_headers_flags(struct seq_file *s, u32 flags)seq_puts (s," FUNCTION CALLS\n" );/* 2nd line */ -seq_puts (s,"#" ); +seq_putc (s,'#' );if (flags &TRACE_GRAPH_PRINT_ABS_TIME )seq_puts (s," | " );if (flags &TRACE_GRAPH_PRINT_CPU )
kernel/trace/trace_kprobe.c +5 -5
@@ -840,7 +840,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tk->tp.nr_args; i++)seq_printf (m," %s=%s" , tk->tp.args[i].name, tk->tp.args[i].comm); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -1030,7 +1030,7 @@ print_kprobe_event(struct trace_iterator *iter, int flags,if (!seq_print_ip_sym (s, field->ip, flags |TRACE_ITER_SYM_OFFSET )) goto partial; -if (!trace_seq_puts (s,")" )) +if (!trace_seq_putc (s,')' )) goto partial; data = (u8 *)&field[1 ];
@@ -1039,7 +1039,7 @@ print_kprobe_event(struct trace_iterator *iter, int flags, data + tp->args[i].offset, field)) goto partial; -if (!trace_seq_puts (s,"\n" )) +if (!trace_seq_putc (s,'\n' )) goto partial;return TRACE_TYPE_HANDLED ;
@@ -1072,7 +1072,7 @@ print_kretprobe_event(struct trace_iterator *iter, int flags,if (!seq_print_ip_sym (s, field->func, flags & ~TRACE_ITER_SYM_OFFSET )) goto partial; -if (!trace_seq_puts (s,")" )) +if (!trace_seq_putc (s,')' )) goto partial; data = (u8 *)&field[1 ];
@@ -1081,7 +1081,7 @@ print_kretprobe_event(struct trace_iterator *iter, int flags, data + tp->args[i].offset, field)) goto partial; -if (!trace_seq_puts (s,"\n" )) +if (!trace_seq_putc (s,'\n' )) goto partial;return TRACE_TYPE_HANDLED ;
kernel/trace/trace_printk.c +1 -1
@@ -305,7 +305,7 @@ static int t_show(struct seq_file *m, void *v)seq_puts (m,"\\t" );break ;case '\\' : -seq_puts (m,"\\" ); +seq_putc (m,'\\' );break ;case '"' :seq_puts (m,"\\\"" );
kernel/trace/trace_uprobe.c +2 -2
@@ -606,7 +606,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tu->tp.nr_args; i++)seq_printf (m," %s=%s" , tu->tp.args[i].name, tu->tp.args[i].comm); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -872,7 +872,7 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e goto partial; } -if (trace_seq_puts (s,"\n" )) +if (trace_seq_putc (s,'\n' ))return TRACE_TYPE_HANDLED ; partial:
Signature · 1 line
2.0.4
Steven Rostedt
maintainerRe: [PATCH v2 3/3] trace: Replace single-character seq_puts with seq_putc
Quoted 19 lines · On Sat, 8 Nov 2014 21:42:12 +0100 Rasmus Villemoes <[email protected]>…
Printing a single character to a seqfile might as well be done with
seq_putcinstead ofseq_puts; this avoids astrlen()call and a memory access. It also shaves another few bytes off the generated code.Signed-off-by Rasmus Villemoes <[email protected]>--- kernel/trace/ftrace.c | 2 +- kernel/trace/trace_events_trigger.c | 4 ++-- kernel/trace/trace_functions_graph.c | 4 ++-- kernel/trace/trace_kprobe.c | 10 +++++----- kernel/trace/trace_printk.c | 2 +- kernel/trace/trace_uprobe.c | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-)kernel/trace/ftrace.c +0
-0
kernel/trace/ftrace.c static int t_show(struct seq_file *m, void *v) · line 2972
Quoted 5 lines
kernel/trace/ftrace.c +1
-1@@ -2969,7 +2969,7 @@ static int t_show(struct seq_file *m, void *v) } } -seq_puts (m,"\n" ); +seq_putc (m,'\n' );
Ah, you did it here. Well, it is fine to have it in the first patch anyway.
-- Steve
PATCH 5/6 trace: Merge consecutive seq_puts calls
In reply to Rasmus VillemoesConsecutive seq_puts calls with literal strings can be merged to a single call. This reduces the size of the generated code, and can also lead to slight .rodata reduction (because of fewer nul and padding bytes). It should also shave a off a few clock cycles.
--- kernel/trace/trace.c | 72 +++++++++++++++++++++++++-------------------- kernel/trace/trace_branch.c | 13 ++++---- 2 files changed, 46 insertions(+), 39 deletions(-)
kernel/trace/trace.c +40 -32
@@ -2508,14 +2508,15 @@ get_total_entries(struct trace_buffer *buf,static void print_lat_help_header (struct seq_file *m) { -seq_puts (m,"# _------=> CPU# \n" ); -seq_puts (m,"# / _-----=> irqs-off \n" ); -seq_puts (m,"# | / _----=> need-resched \n" ); -seq_puts (m,"# || / _---=> hardirq/softirq \n" ); -seq_puts (m,"# ||| / _--=> preempt-depth \n" ); -seq_puts (m,"# |||| / delay \n" ); -seq_puts (m,"# cmd pid ||||| time | caller \n" ); -seq_puts (m,"# \\ / ||||| \\ | / \n" ); +seq_puts (m, +"# _------=> CPU# \n" +"# / _-----=> irqs-off \n" +"# | / _----=> need-resched \n" +"# || / _---=> hardirq/softirq \n" +"# ||| / _--=> preempt-depth \n" +"# |||| / delay \n" +"# cmd pid ||||| time | caller \n" +"# \\ / ||||| \\ | / \n" ); }static void print_event_info (struct trace_buffer *buf,struct seq_file *m)
@@ -2532,20 +2533,22 @@ static void print_event_info(struct trace_buffer *buf, struct seq_file *m)static void print_func_help_header (struct trace_buffer *buf,struct seq_file *m) {print_event_info (buf, m); -seq_puts (m,"# TASK-PID CPU# TIMESTAMP FUNCTION\n" ); -seq_puts (m,"# | | | | |\n" ); +seq_puts (m, +"# TASK-PID CPU# TIMESTAMP FUNCTION\n" +"# | | | | |\n" ); }static void print_func_help_header_irq (struct trace_buffer *buf,struct seq_file *m) {print_event_info (buf, m); -seq_puts (m,"# _-----=> irqs-off\n" ); -seq_puts (m,"# / _----=> need-resched\n" ); -seq_puts (m,"# | / _---=> hardirq/softirq\n" ); -seq_puts (m,"# || / _--=> preempt-depth\n" ); -seq_puts (m,"# ||| / delay\n" ); -seq_puts (m,"# TASK-PID CPU# |||| TIMESTAMP FUNCTION\n" ); -seq_puts (m,"# | | | |||| | |\n" ); +seq_puts (m, +"# _-----=> irqs-off\n" +"# / _----=> need-resched\n" +"# | / _---=> hardirq/softirq\n" +"# || / _--=> preempt-depth\n" +"# ||| / delay\n" +"# TASK-PID CPU# |||| TIMESTAMP FUNCTION\n" +"# | | | |||| | |\n" ); }void
@@ -2859,34 +2862,39 @@ static void test_ftrace_alive(struct seq_file *m) {if (!ftrace_is_dead ())return ; -seq_puts (m,"# WARNING: FUNCTION TRACING IS CORRUPTED\n" ); -seq_puts (m,"# MAY BE MISSING FUNCTION EVENTS\n" ); +seq_puts (m, +"# WARNING: FUNCTION TRACING IS CORRUPTED\n" +"# MAY BE MISSING FUNCTION EVENTS\n" ); }#ifdef CONFIG_TRACER_MAX_TRACE static void show_snapshot_main_help (struct seq_file *m) { -seq_puts (m,"# echo 0 > snapshot : Clears and frees snapshot buffer\n" ); -seq_puts (m,"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" ); -seq_puts (m,"# Takes a snapshot of the main buffer.\n" ); -seq_puts (m,"# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n" ); -seq_puts (m,"# (Doesn't have to be '2' works with any number that\n" ); -seq_puts (m,"# is not a '0' or '1')\n" ); +seq_puts (m, +"# echo 0 > snapshot : Clears and frees snapshot buffer\n" +"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" +"# Takes a snapshot of the main buffer.\n" +"# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n" +"# (Doesn't have to be '2' works with any number that\n" +"# is not a '0' or '1')\n" ); }static void show_snapshot_percpu_help (struct seq_file *m) {seq_puts (m,"# echo 0 > snapshot : Invalid for per_cpu snapshot file.\n" );#ifdef CONFIG_RING_BUFFER_ALLOW_SWAP -seq_puts (m,"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" ); -seq_puts (m,"# Takes a snapshot of the main buffer for this cpu.\n" ); +seq_puts (m, +"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n" +"# Takes a snapshot of the main buffer for this cpu.\n" );#else -seq_puts (m,"# echo 1 > snapshot : Not supported with this kernel.\n" ); -seq_puts (m,"# Must use main snapshot file to allocate.\n" ); +seq_puts (m, +"# echo 1 > snapshot : Not supported with this kernel.\n" +"# Must use main snapshot file to allocate.\n" );#endif -seq_puts (m,"# echo 2 > snapshot : Clears this cpu's snapshot buffer (but does not allocate)\n" ); -seq_puts (m,"# (Doesn't have to be '2' works with any number that\n" ); -seq_puts (m,"# is not a '0' or '1')\n" ); +seq_puts (m, +"# echo 2 > snapshot : Clears this cpu's snapshot buffer (but does not allocate)\n" +"# (Doesn't have to be '2' works with any number that\n" +"# is not a '0' or '1')\n" ); }static void print_snapshot_help (struct seq_file *m,struct trace_iterator *iter)
kernel/trace/trace_branch.c +6 -7
@@ -163,10 +163,9 @@ static enum print_line_t trace_branch_print(struct trace_iterator *iter,static void branch_print_header (struct seq_file *s) { -seq_puts (s,"# TASK-PID CPU# TIMESTAMP CORRECT" -" FUNC:FILE:LINE\n" ); -seq_puts (s,"# | | | | | " -" |\n" ); +seq_puts (s, +"# TASK-PID CPU# TIMESTAMP CORRECT" " FUNC:FILE:LINE\n" +"# | | | | | " " |\n" ); }static struct trace_event_functions trace_branch_funcs = {
@@ -233,8 +232,8 @@ extern unsigned long __stop_annotated_branch_profile[];static int annotated_branch_stat_headers (struct seq_file *m) { -seq_puts (m," correct incorrect % " );seq_puts (m, +" correct incorrect % " " Function " " File Line\n" " ------- --------- - "
@@ -363,9 +362,9 @@ extern unsigned long __stop_branch_profile[];static int all_branch_stat_headers (struct seq_file *m) { -seq_puts (m," miss hit % " );seq_puts (m, -" Function " " File Line\n" " ------- --------- - " " -------- " " ---- ----\n" ); +" miss hit % " " Function " " File Line\n" +" ------- --------- - " " -------- " " ---- ----\n" );return 0 ; }
Signature · 1 line
2.0.4
PATCH 6/6 trace: Replace single-character seq_puts with seq_putc
In reply to Rasmus VillemoesPrinting a single character to a seqfile might as well be done with seq_putc instead of seq_puts; this avoids a strlen() call and a memory access. It also shaves another few bytes off the generated code.
--- kernel/trace/ftrace.c | 2 +- kernel/trace/trace_events_trigger.c | 4 ++-- kernel/trace/trace_functions_graph.c | 4 ++-- kernel/trace/trace_kprobe.c | 10 +++++----- kernel/trace/trace_printk.c | 2 +- kernel/trace/trace_uprobe.c | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-)
kernel/trace/ftrace.c +1 -1
@@ -2969,7 +2969,7 @@ static int t_show(struct seq_file *m, void *v) } } -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
kernel/trace/trace_events_trigger.c +2 -2
@@ -383,7 +383,7 @@ event_trigger_print(const char *name, struct seq_file *m,if (filter_str)seq_printf (m," if %s\n" , filter_str);else -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -1105,7 +1105,7 @@ event_enable_trigger_print(struct seq_file *m, struct event_trigger_ops *ops,if (data->filter_str)seq_printf (m," if %s\n" , data->filter_str);else -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
kernel/trace/trace_functions_graph.c +2 -2
@@ -1407,7 +1407,7 @@ static void __print_graph_headers_flags(struct seq_file *s, u32 flags)print_lat_header (s, flags);/* 1st line */ -seq_puts (s,"#" ); +seq_putc (s,'#' );if (flags &TRACE_GRAPH_PRINT_ABS_TIME )seq_puts (s," TIME " );if (flags &TRACE_GRAPH_PRINT_CPU )
@@ -1421,7 +1421,7 @@ static void __print_graph_headers_flags(struct seq_file *s, u32 flags)seq_puts (s," FUNCTION CALLS\n" );/* 2nd line */ -seq_puts (s,"#" ); +seq_putc (s,'#' );if (flags &TRACE_GRAPH_PRINT_ABS_TIME )seq_puts (s," | " );if (flags &TRACE_GRAPH_PRINT_CPU )
kernel/trace/trace_kprobe.c +5 -5
@@ -840,7 +840,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tk->tp.nr_args; i++)seq_printf (m," %s=%s" , tk->tp.args[i].name, tk->tp.args[i].comm); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -1030,7 +1030,7 @@ print_kprobe_event(struct trace_iterator *iter, int flags,if (!seq_print_ip_sym (s, field->ip, flags |TRACE_ITER_SYM_OFFSET )) goto partial; -if (!trace_seq_puts (s,")" )) +if (!trace_seq_putc (s,')' )) goto partial; data = (u8 *)&field[1 ];
@@ -1039,7 +1039,7 @@ print_kprobe_event(struct trace_iterator *iter, int flags, data + tp->args[i].offset, field)) goto partial; -if (!trace_seq_puts (s,"\n" )) +if (!trace_seq_putc (s,'\n' )) goto partial;return TRACE_TYPE_HANDLED ;
@@ -1072,7 +1072,7 @@ print_kretprobe_event(struct trace_iterator *iter, int flags,if (!seq_print_ip_sym (s, field->func, flags & ~TRACE_ITER_SYM_OFFSET )) goto partial; -if (!trace_seq_puts (s,")" )) +if (!trace_seq_putc (s,')' )) goto partial; data = (u8 *)&field[1 ];
@@ -1081,7 +1081,7 @@ print_kretprobe_event(struct trace_iterator *iter, int flags, data + tp->args[i].offset, field)) goto partial; -if (!trace_seq_puts (s,"\n" )) +if (!trace_seq_putc (s,'\n' )) goto partial;return TRACE_TYPE_HANDLED ;
kernel/trace/trace_printk.c +1 -1
@@ -305,7 +305,7 @@ static int t_show(struct seq_file *m, void *v)seq_puts (m,"\\t" );break ;case '\\' : -seq_puts (m,"\\" ); +seq_putc (m,'\\' );break ;case '"' :seq_puts (m,"\\\"" );
kernel/trace/trace_uprobe.c +2 -2
@@ -606,7 +606,7 @@ static int probes_seq_show(struct seq_file *m, void *v)for (i =0 ; i < tu->tp.nr_args; i++)seq_printf (m," %s=%s" , tu->tp.args[i].name, tu->tp.args[i].comm); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -872,7 +872,7 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e goto partial; } -if (trace_seq_puts (s,"\n" )) +if (trace_seq_putc (s,'\n' ))return TRACE_TYPE_HANDLED ; partial:
Signature · 1 line
2.0.4