diff options
author | Carsten Emde <Carsten.Emde@osadl.org> | 2009-03-18 04:00:41 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-18 05:10:18 -0400 |
commit | a635cf0497342978d417cae19d4a4823932977ff (patch) | |
tree | afacf84eb85388801a04996ed62e000cdfad3bc2 /kernel/trace/trace.c | |
parent | 50d88758a3f9787cbdbdbc030560b815721eab4b (diff) |
tracing: fix command line to pid reverse map
Impact: fix command line to pid mapping
map_cmdline_to_pid[] is checked in trace_save_cmdline(), but never
updated. This results in stale pid to command line mappings and the
tracer output will associate the wrong comm string.
Signed-off-by: Carsten Emde <Carsten.Emde@osadl.org>
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>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 06c69a260328..305c562dae2a 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -738,8 +738,7 @@ void trace_stop_cmdline_recording(void); | |||
738 | 738 | ||
739 | static void trace_save_cmdline(struct task_struct *tsk) | 739 | static void trace_save_cmdline(struct task_struct *tsk) |
740 | { | 740 | { |
741 | unsigned map; | 741 | unsigned pid, idx; |
742 | unsigned idx; | ||
743 | 742 | ||
744 | if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT)) | 743 | if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT)) |
745 | return; | 744 | return; |
@@ -757,10 +756,17 @@ static void trace_save_cmdline(struct task_struct *tsk) | |||
757 | if (idx == NO_CMDLINE_MAP) { | 756 | if (idx == NO_CMDLINE_MAP) { |
758 | idx = (cmdline_idx + 1) % SAVED_CMDLINES; | 757 | idx = (cmdline_idx + 1) % SAVED_CMDLINES; |
759 | 758 | ||
760 | map = map_cmdline_to_pid[idx]; | 759 | /* |
761 | if (map != NO_CMDLINE_MAP) | 760 | * Check whether the cmdline buffer at idx has a pid |
762 | map_pid_to_cmdline[map] = NO_CMDLINE_MAP; | 761 | * mapped. We are going to overwrite that entry so we |
762 | * need to clear the map_pid_to_cmdline. Otherwise we | ||
763 | * would read the new comm for the old pid. | ||
764 | */ | ||
765 | pid = map_cmdline_to_pid[idx]; | ||
766 | if (pid != NO_CMDLINE_MAP) | ||
767 | map_pid_to_cmdline[pid] = NO_CMDLINE_MAP; | ||
763 | 768 | ||
769 | map_cmdline_to_pid[idx] = tsk->pid; | ||
764 | map_pid_to_cmdline[tsk->pid] = idx; | 770 | map_pid_to_cmdline[tsk->pid] = idx; |
765 | 771 | ||
766 | cmdline_idx = idx; | 772 | cmdline_idx = idx; |