Messages in this thread | | | Subject | Re: [PATCH] tracing: save cmdline only when task does not exist in savecmd for optimization | From | Yang Jihong <> | Date | Fri, 15 Oct 2021 09:27:35 +0800 |
| |
Hi Steven,
On 2021/10/14 22:32, Steven Rostedt wrote: > On Mon, 11 Oct 2021 19:50:18 +0800 > Yang Jihong <yangjihong1@huawei.com> wrote: > >> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c >> index 7896d30d90f7..a795610a3b37 100644 >> --- a/kernel/trace/trace.c >> +++ b/kernel/trace/trace.c >> @@ -2427,8 +2427,11 @@ static int trace_save_cmdline(struct task_struct *tsk) >> savedcmd->cmdline_idx = idx; >> } >> >> - savedcmd->map_cmdline_to_pid[idx] = tsk->pid; >> - set_cmdline(idx, tsk->comm); >> + /* save cmdline only when task does not exist in savecmd */ >> + if (savedcmd->map_cmdline_to_pid[idx] != tsk->pid) { >> + savedcmd->map_cmdline_to_pid[idx] = tsk->pid; >> + set_cmdline(idx, tsk->comm); >> + } >> > > I now remember why I never did it this way. This breaks saving the command > line when we do an exec. > > That is, just because mapped_pid == tsk->pid does not mean that the comm is > the same. > If do an exec, the original process is replaced with a new binary. Therefore, the command changes but the tsk->pid does not change. Therefore, we need to savecmd here again?
Okay, I see. Thank you for the detailed explanation. :)
Thanks, Jihong > -- Steve > . >
| |