[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tip-a635cf0497342978d417cae19d4a4823932977ff@git.kernel.org>
Date: Wed, 18 Mar 2009 09:18:55 GMT
From: Carsten Emde <Carsten.Emde@...dl.org>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, hpa@...or.com, mingo@...hat.com,
fweisbec@...il.com, srostedt@...hat.com, Carsten.Emde@...dl.org,
tglx@...utronix.de, mingo@...e.hu
Subject: [tip:tracing/tasks] tracing: fix command line to pid reverse map
Commit-ID: a635cf0497342978d417cae19d4a4823932977ff
Gitweb: http://git.kernel.org/tip/a635cf0497342978d417cae19d4a4823932977ff
Author: Carsten Emde <Carsten.Emde@...dl.org>
AuthorDate: Wed, 18 Mar 2009 09:00:41 +0100
Commit: Ingo Molnar <mingo@...e.hu>
CommitDate: Wed, 18 Mar 2009 10:10:18 +0100
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@...dl.org>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Steven Rostedt <srostedt@...hat.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
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 06c69a2..305c562 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -738,8 +738,7 @@ void trace_stop_cmdline_recording(void);
static void trace_save_cmdline(struct task_struct *tsk)
{
- unsigned map;
- unsigned idx;
+ unsigned pid, idx;
if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT))
return;
@@ -757,10 +756,17 @@ static void trace_save_cmdline(struct task_struct *tsk)
if (idx == NO_CMDLINE_MAP) {
idx = (cmdline_idx + 1) % SAVED_CMDLINES;
- map = map_cmdline_to_pid[idx];
- if (map != NO_CMDLINE_MAP)
- map_pid_to_cmdline[map] = NO_CMDLINE_MAP;
+ /*
+ * Check whether the cmdline buffer at idx has a pid
+ * mapped. We are going to overwrite that entry so we
+ * need to clear the map_pid_to_cmdline. Otherwise we
+ * would read the new comm for the old pid.
+ */
+ pid = map_cmdline_to_pid[idx];
+ if (pid != NO_CMDLINE_MAP)
+ map_pid_to_cmdline[pid] = NO_CMDLINE_MAP;
+ map_cmdline_to_pid[idx] = tsk->pid;
map_pid_to_cmdline[tsk->pid] = idx;
cmdline_idx = idx;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists