Skip to content

Commit

Permalink
tracing: fix trace_find_cmdline()
Browse files Browse the repository at this point in the history
Impact: prevent stale command line output

In case there is no valid command line mapping for a pid
trace_find_cmdline() returns without updating the comm buffer. The
trace dump keeps the previous entry which results in confusing trace
output:

     <idle>-0     [000]   280.702056 ....
     <idle>-23456 [000]   280.702080 ....

Update the comm buffer with "<...>" when no mapping is found.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Thomas Gleixner authored and Ingo Molnar committed Mar 18, 2009
1 parent 2c7eea4 commit 50d8875
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,12 +787,11 @@ void trace_find_cmdline(int pid, char comm[])

__raw_spin_lock(&trace_cmdline_lock);
map = map_pid_to_cmdline[pid];
if (map == NO_CMDLINE_MAP)
goto out;

strcpy(comm, saved_cmdlines[map]);
if (map != NO_CMDLINE_MAP)
strcpy(comm, saved_cmdlines[map]);
else
strcpy(comm, "<...>");

out:
__raw_spin_unlock(&trace_cmdline_lock);
}

Expand Down

0 comments on commit 50d8875

Please sign in to comment.