mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
50d88758a3
commit
a635cf0497
|
@ -738,8 +738,7 @@ void trace_stop_cmdline_recording(void);
|
||||||
|
|
||||||
static void trace_save_cmdline(struct task_struct *tsk)
|
static void trace_save_cmdline(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
unsigned map;
|
unsigned pid, idx;
|
||||||
unsigned idx;
|
|
||||||
|
|
||||||
if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT))
|
if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT))
|
||||||
return;
|
return;
|
||||||
|
@ -757,10 +756,17 @@ static void trace_save_cmdline(struct task_struct *tsk)
|
||||||
if (idx == NO_CMDLINE_MAP) {
|
if (idx == NO_CMDLINE_MAP) {
|
||||||
idx = (cmdline_idx + 1) % SAVED_CMDLINES;
|
idx = (cmdline_idx + 1) % SAVED_CMDLINES;
|
||||||
|
|
||||||
map = map_cmdline_to_pid[idx];
|
/*
|
||||||
if (map != NO_CMDLINE_MAP)
|
* Check whether the cmdline buffer at idx has a pid
|
||||||
map_pid_to_cmdline[map] = NO_CMDLINE_MAP;
|
* 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;
|
map_pid_to_cmdline[tsk->pid] = idx;
|
||||||
|
|
||||||
cmdline_idx = idx;
|
cmdline_idx = idx;
|
||||||
|
|
Loading…
Reference in New Issue