Skip to contentSkip to conversation

tracing: fix trace_find_cmdline()

tip:tracing/tasks Thomas Gleixner 1 participant 1 message Mar 18, 2009 Tracing

lore
Share & tools
lore
#0 lore raw
Commit-ID:  50d88758a3f9787cbdbdbc030560b815721eab4b
Gitweb:     http://git.kernel.org/tip/50d88758a3f9787cbdbdbc030560b815721eab4b
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Wed, 18 Mar 2009 08:58:44 +0100
Commit:     Ingo Molnar <[email protected]>
CommitDate: Wed, 18 Mar 2009 10:10:17 +0100

tracing: fix trace_find_cmdline()

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.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <new-submission>

---
 kernel/trace/trace.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
kernel/trace/trace.c +4 -5
index ca673c4..06c69a2 100644
@@ -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);
 }