ftrace: fix trace_output
PATCH 1/1 ftrace: fix trace_output
Impact: fix bug for handling partial line
trace_seq_printf(), seq_print_userip_objs(), ... return
0 -- partial line was written
other(>0) -- success
duplicate output is also removed in trace_print_raw().
---
kernel/trace/trace_output.c +16 -19
@@ -443,9 +443,9 @@ trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags)if (trace_seq_printf (s,"%x %x\n" , field->ip, field->parent_ip)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ; -return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int
@@ -505,9 +505,9 @@ trace_ctxwake_print(struct trace_seq *s, struct trace_entry *entry, int flags, field->next_pid, field->next_prio, T, comm)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ; -return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int
@@ -542,9 +542,9 @@ trace_ctxwake_raw(struct trace_seq *s, struct trace_entry *entry, int flags, field->next_pid, field->next_prio, T)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ; -return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int
@@ -643,9 +643,9 @@ trace_special_print(struct trace_seq *s, struct trace_entry *entry, int flags) field->arg1, field->arg2, field->arg3)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ; -return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int
@@ -697,13 +697,13 @@ trace_stack_print(struct trace_seq *s, struct trace_entry *entry, int flags)for (i =0 ; i <FTRACE_STACK_ENTRIES ; i++) {if (i) { -if (trace_seq_puts (s," <= " )) +if (!trace_seq_puts (s," <= " )) goto partial; -if (seq_print_ip_sym (s, field->caller[i], flags)) +if (!seq_print_ip_sym (s, field->caller[i], flags)) goto partial; } -if (trace_seq_puts (s,"\n" )) +if (!trace_seq_puts (s,"\n" )) goto partial; }
@@ -731,10 +731,10 @@ trace_user_stack_print(struct trace_seq *s, struct trace_entry *entry,trace_assign_type (field, entry); -if (seq_print_userip_objs (field, s, flags)) +if (!seq_print_userip_objs (field, s, flags)) goto partial; -if (trace_seq_putc (s,'\n' )) +if (!trace_seq_putc (s,'\n' )) goto partial;return 0 ;
@@ -760,10 +760,10 @@ trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (seq_print_ip_sym (s, field->ip, flags)) +if (!seq_print_ip_sym (s, field->ip, flags)) goto partial; -if (trace_seq_printf (s,": %s" , field->buf)) +if (!trace_seq_printf (s,": %s" , field->buf)) goto partial;return 0 ;
@@ -779,10 +779,7 @@ trace_print_raw(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (seq_print_ip_sym (s, field->ip, flags)) - goto partial; - -if (trace_seq_printf (s,"# %lx %s" , field->ip, field->buf)) +if (!trace_seq_printf (s,"# %lx %s" , field->ip, field->buf)) goto partial;return 0 ;
kernel/trace/trace_output.h +2 -2
@@ -45,14 +45,14 @@ trace_nop_print(struct trace_seq *s, struct trace_entry *entry, int flags);#define SEQ_PUT_FIELD_RET (s, x) \ do { \ if (!trace_seq_putmem(s, &(x), sizeof(x))) \ - return 0; \ + return TRACE_TYPE_PARTIAL_LINE; \ } while (0)#define SEQ_PUT_HEX_FIELD_RET (s, x) \ do { \ BUILD_BUG_ON(sizeof(x) > MAX_MEMHEX_BYTES); \ if (!trace_seq_putmem_hex(s, &(x), sizeof(x))) \ - return 0; \ + return TRACE_TYPE_PARTIAL_LINE; \ } while (0)#endif
Steven Rostedt
maintainerHi Lai,
Quoted 16 lines · Lai Jiangshan
Impact: fix bug for handling partial line
trace_seq_printf(),seq_print_userip_objs(), ... return
0 -- partial line was written
other(>0) -- successduplicate output is also removed in
trace_print_raw().Signed-off-by Lai Jiangshan <[email protected]>---
kernel/trace/trace_output.c +0
-0
kernel/trace/trace_output.c trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags) · line 446
Quoted 5 lines
kernel/trace/trace_output.c +1
-1@@ -443,9 +443,9 @@ trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags)if (trace_seq_printf (s,"%x %x\n" , field->ip, field->parent_ip)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ;
Actually, could you change it to match the rest of the file.
That is to add the missing "!" instead of changing the two returns.
kernel/trace/trace_output.c trace_ctxwake_print(struct trace_seq *s, struct trace_entry *entry, int flags, · line 508
Quoted 12 lines
kernel/trace/trace_output.c +2
-2-return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int@@ -505,9 +505,9 @@ trace_ctxwake_print(struct trace_seq *s, struct trace_entry *entry, int flags, field->next_pid, field->next_prio, T, comm)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ;
Here too.
kernel/trace/trace_output.c trace_ctxwake_raw(struct trace_seq *s, struct trace_entry *entry, int flags, · line 545
Quoted 12 lines
kernel/trace/trace_output.c +2
-2-return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int@@ -542,9 +542,9 @@ trace_ctxwake_raw(struct trace_seq *s, struct trace_entry *entry, int flags, field->next_pid, field->next_prio, T)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ;
and here.
kernel/trace/trace_output.c trace_special_print(struct trace_seq *s, struct trace_entry *entry, int flags) · line 646
Quoted 12 lines
kernel/trace/trace_output.c +2
-2-return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int@@ -643,9 +643,9 @@ trace_special_print(struct trace_seq *s, struct trace_entry *entry, int flags) field->arg1, field->arg2, field->arg3)) -return TRACE_TYPE_PARTIAL_LINE ; +return 0 ;
and here.
kernel/trace/trace_output.c trace_stack_print(struct trace_seq *s, struct trace_entry *entry, int flags) · line 701
Quoted 13 lines
kernel/trace/trace_output.c +2
-2-return 0 ; +return TRACE_TYPE_PARTIAL_LINE ; } static int@@ -697,13 +697,13 @@ trace_stack_print(struct trace_seq *s, struct trace_entry *entry, int flags)for (i =0 ; i <FTRACE_STACK_ENTRIES ; i++) {if (i) { -if (trace_seq_puts (s," <= " )) +if (!trace_seq_puts (s," <= " )) goto partial;
This is good.
Quoted 11 lines
kernel/trace/trace_output.c +2
-2-if (seq_print_ip_sym (s, field->caller[i], flags)) +if (!seq_print_ip_sym (s, field->caller[i], flags)) goto partial; } -if (trace_seq_puts (s,"\n" )) +if (!trace_seq_puts (s,"\n" )) goto partial; }
kernel/trace/trace_output.c trace_user_stack_print(struct trace_seq *s, struct trace_entry *entry, · line 735
Quoted 6 lines
kernel/trace/trace_output.c +1
-1@@ -731,10 +731,10 @@ trace_user_stack_print(struct trace_seq *s, struct trace_entry *entry,trace_assign_type (field, entry); -if (seq_print_userip_objs (field, s, flags)) +if (!seq_print_userip_objs (field, s, flags)) goto partial;
This is also good.
kernel/trace/trace_output.c trace_user_stack_print(struct trace_seq *s, struct trace_entry *entry, · line 738
Quoted 4 lines
kernel/trace/trace_output.c +1
-1-if (trace_seq_putc (s,'\n' )) +if (!trace_seq_putc (s,'\n' )) goto partial;
also good.
Quoted 16 lines
kernel/trace/trace_output.c +2
-2return 0 ;@@ -760,10 +760,10 @@ trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (seq_print_ip_sym (s, field->ip, flags)) +if (!seq_print_ip_sym (s, field->ip, flags)) goto partial; -if (trace_seq_printf (s,": %s" , field->buf)) +if (!trace_seq_printf (s,": %s" , field->buf)) goto partial;return 0 ;
kernel/trace/trace_output.c trace_print_raw(struct trace_seq *s, struct trace_entry *entry, int flags) · line 783
Quoted 9 lines
kernel/trace/trace_output.c +1
-4@@ -779,10 +779,7 @@ trace_print_raw(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (seq_print_ip_sym (s, field->ip, flags)) - goto partial; - -if (trace_seq_printf (s,"# %lx %s" , field->ip, field->buf)) +if (!trace_seq_printf (s,"# %lx %s" , field->ip, field->buf)) goto partial;
The above looks good.
Quoted 11 lines
kernel/trace/trace_output.c +0
-0return 0 ;kernel/trace/trace_output.h +0
-1@@ -45,14 +45,14 @@ trace_nop_print(struct trace_seq *s, struct trace_entry *entry, int flags);#define SEQ_PUT_FIELD_RET (s, x) \ do { \ if (!trace_seq_putmem(s, &(x), sizeof(x))) \ - return 0; \
kernel/trace/trace_output.h trace_nop_print(struct trace_seq *s, struct trace_entry *entry, int flags); · line 56
Quoted 10 lines
kernel/trace/trace_output.h +2
-1+return TRACE_TYPE_PARTIAL_LINE ; \ } while (0)#define SEQ_PUT_HEX_FIELD_RET (s, x) \ do { \ BUILD_BUG_ON(sizeof(x) > MAX_MEMHEX_BYTES); \ if (!trace_seq_putmem_hex(s, &(x), sizeof(x))) \ - return 0; \ + return TRACE_TYPE_PARTIAL_LINE; \ } while (0)
Ah, that is correct as well.
Thanks,
-- Steve
Quoted 8 lines
kernel/trace/trace_output.h +0
-0#endif
Impact: fix bug for handling partial line
trace_seq_printf(), seq_print_userip_objs(), ... return
0 -- partial line was written
other(>0) -- success
duplicate output is also removed in trace_print_raw().
---
kernel/trace/trace_output.c +31 -34
@@ -440,9 +440,9 @@ trace_fn_raw(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (trace_seq_printf (s,"%x %x\n" , - field->ip, - field->parent_ip)) +if (!trace_seq_printf (s,"%x %x\n" , + field->ip, + field->parent_ip))return TRACE_TYPE_PARTIAL_LINE ;return 0 ;
@@ -497,14 +497,14 @@ trace_ctxwake_print(struct trace_seq *s, struct trace_entry *entry, int flags,T =task_state_char (field->next_state);S =task_state_char (field->prev_state); comm =trace_find_cmdline (field->next_pid); -if (trace_seq_printf (s," %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n" , - field->prev_pid, - field->prev_prio, -S , delim, - field->next_cpu, - field->next_pid, - field->next_prio, -T , comm)) +if (!trace_seq_printf (s," %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n" , + field->prev_pid, + field->prev_prio, +S , delim, + field->next_cpu, + field->next_pid, + field->next_prio, +T , comm))return TRACE_TYPE_PARTIAL_LINE ;return 0 ;
@@ -534,14 +534,14 @@ trace_ctxwake_raw(struct trace_seq *s, struct trace_entry *entry, int flags,if (!S )task_state_char (field->prev_state);T =task_state_char (field->next_state); -if (trace_seq_printf (s,"%d %d %c %d %d %d %c\n" , - field->prev_pid, - field->prev_prio, -S , - field->next_cpu, - field->next_pid, - field->next_prio, -T )) +if (!trace_seq_printf (s,"%d %d %c %d %d %d %c\n" , + field->prev_pid, + field->prev_prio, +S , + field->next_cpu, + field->next_pid, + field->next_prio, +T ))return TRACE_TYPE_PARTIAL_LINE ;return 0 ;
@@ -639,10 +639,10 @@ trace_special_print(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (trace_seq_printf (s,"# %ld %ld %ld\n" , - field->arg1, - field->arg2, - field->arg3)) +if (!trace_seq_printf (s,"# %ld %ld %ld\n" , + field->arg1, + field->arg2, + field->arg3))return TRACE_TYPE_PARTIAL_LINE ;return 0 ;
@@ -697,13 +697,13 @@ trace_stack_print(struct trace_seq *s, struct trace_entry *entry, int flags)for (i =0 ; i <FTRACE_STACK_ENTRIES ; i++) {if (i) { -if (trace_seq_puts (s," <= " )) +if (!trace_seq_puts (s," <= " )) goto partial; -if (seq_print_ip_sym (s, field->caller[i], flags)) +if (!seq_print_ip_sym (s, field->caller[i], flags)) goto partial; } -if (trace_seq_puts (s,"\n" )) +if (!trace_seq_puts (s,"\n" )) goto partial; }
@@ -731,10 +731,10 @@ trace_user_stack_print(struct trace_seq *s, struct trace_entry *entry,trace_assign_type (field, entry); -if (seq_print_userip_objs (field, s, flags)) +if (!seq_print_userip_objs (field, s, flags)) goto partial; -if (trace_seq_putc (s,'\n' )) +if (!trace_seq_putc (s,'\n' )) goto partial;return 0 ;
@@ -760,10 +760,10 @@ trace_print_print(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (seq_print_ip_sym (s, field->ip, flags)) +if (!seq_print_ip_sym (s, field->ip, flags)) goto partial; -if (trace_seq_printf (s,": %s" , field->buf)) +if (!trace_seq_printf (s,": %s" , field->buf)) goto partial;return 0 ;
@@ -779,10 +779,7 @@ trace_print_raw(struct trace_seq *s, struct trace_entry *entry, int flags)trace_assign_type (field, entry); -if (seq_print_ip_sym (s, field->ip, flags)) - goto partial; - -if (trace_seq_printf (s,"# %lx %s" , field->ip, field->buf)) +if (!trace_seq_printf (s,"# %lx %s" , field->ip, field->buf)) goto partial;return 0 ;
kernel/trace/trace_output.h +2 -2
@@ -45,14 +45,14 @@ trace_nop_print(struct trace_seq *s, struct trace_entry *entry, int flags);#define SEQ_PUT_FIELD_RET (s, x) \ do { \ if (!trace_seq_putmem(s, &(x), sizeof(x))) \ - return 0; \ + return TRACE_TYPE_PARTIAL_LINE; \ } while (0)#define SEQ_PUT_HEX_FIELD_RET (s, x) \ do { \ BUILD_BUG_ON(sizeof(x) > MAX_MEMHEX_BYTES); \ if (!trace_seq_putmem_hex(s, &(x), sizeof(x))) \ - return 0; \ + return TRACE_TYPE_PARTIAL_LINE; \ } while (0)#endif