[PATCH V2] tracing: Revert "tracing: Remove pid in task_rename tracing output"

Xuewen Yan posted 1 patch 1 month ago
include/trace/events/task.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH V2] tracing: Revert "tracing: Remove pid in task_rename tracing output"
Posted by Xuewen Yan 1 month ago
This reverts commit e3f6a42272e028c46695acc83fc7d7c42f2750ad.

The commit says that the tracepoint only deals with the current task,
however the following case is not current task:

comm_write() {
    p = get_proc_task(inode);
    if (!p)
        return -ESRCH;

    if (same_thread_group(current, p))
        set_task_comm(p, buffer);
}
where set_task_comm() calls __set_task_comm() which records
the update of p and not current.

So revert the patch to show pid.

Fixes: e3f6a42272e0 ("tracing: Remove pid in task_rename tracing output")
Reported-by: Guohua Yan <guohua.yan@unisoc.com>
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
v2:
- update commit message (Steven)
---
 include/trace/events/task.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/task.h b/include/trace/events/task.h
index 4f0759634306..b9a129eb54d9 100644
--- a/include/trace/events/task.h
+++ b/include/trace/events/task.h
@@ -38,19 +38,22 @@ TRACE_EVENT(task_rename,
 	TP_ARGS(task, comm),
 
 	TP_STRUCT__entry(
+		__field(	pid_t,	pid)
 		__array(	char, oldcomm,  TASK_COMM_LEN)
 		__array(	char, newcomm,  TASK_COMM_LEN)
 		__field(	short,	oom_score_adj)
 	),
 
 	TP_fast_assign(
+		__entry->pid = task->pid;
 		memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
 		strscpy(entry->newcomm, comm, TASK_COMM_LEN);
 		__entry->oom_score_adj = task->signal->oom_score_adj;
 	),
 
-	TP_printk("oldcomm=%s newcomm=%s oom_score_adj=%hd",
-		  __entry->oldcomm, __entry->newcomm, __entry->oom_score_adj)
+	TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%hd",
+		__entry->pid, __entry->oldcomm,
+		__entry->newcomm, __entry->oom_score_adj)
 );
 
 /**
-- 
2.25.1
Re: [PATCH V2] tracing: Revert "tracing: Remove pid in task_rename tracing output"
Posted by Steven Rostedt 1 month ago
On Fri, 6 Mar 2026 15:59:54 +0800
Xuewen Yan <xuewen.yan@unisoc.com> wrote:

> This reverts commit e3f6a42272e028c46695acc83fc7d7c42f2750ad.
> 
> The commit says that the tracepoint only deals with the current task,
> however the following case is not current task:
> 
> comm_write() {
>     p = get_proc_task(inode);
>     if (!p)
>         return -ESRCH;
> 
>     if (same_thread_group(current, p))
>         set_task_comm(p, buffer);
> }
> where set_task_comm() calls __set_task_comm() which records
> the update of p and not current.
> 
> So revert the patch to show pid.
> 
> Fixes: e3f6a42272e0 ("tracing: Remove pid in task_rename tracing output")
> Reported-by: Guohua Yan <guohua.yan@unisoc.com>
> Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>

Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve

> ---
> v2:
> - update commit message (Steven)
> ---
>  include/trace/events/task.h | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/include/trace/events/task.h b/include/trace/events/task.h
> index 4f0759634306..b9a129eb54d9 100644
> --- a/include/trace/events/task.h
> +++ b/include/trace/events/task.h
> @@ -38,19 +38,22 @@ TRACE_EVENT(task_rename,
>  	TP_ARGS(task, comm),
>  
>  	TP_STRUCT__entry(
> +		__field(	pid_t,	pid)
>  		__array(	char, oldcomm,  TASK_COMM_LEN)
>  		__array(	char, newcomm,  TASK_COMM_LEN)
>  		__field(	short,	oom_score_adj)
>  	),
>  
>  	TP_fast_assign(
> +		__entry->pid = task->pid;
>  		memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
>  		strscpy(entry->newcomm, comm, TASK_COMM_LEN);
>  		__entry->oom_score_adj = task->signal->oom_score_adj;
>  	),
>  
> -	TP_printk("oldcomm=%s newcomm=%s oom_score_adj=%hd",
> -		  __entry->oldcomm, __entry->newcomm, __entry->oom_score_adj)
> +	TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%hd",
> +		__entry->pid, __entry->oldcomm,
> +		__entry->newcomm, __entry->oom_score_adj)
>  );
>  
>  /**
Re: [PATCH V2] tracing: Revert "tracing: Remove pid in task_rename tracing output"
Posted by Xuewen Yan 3 weeks, 3 days ago
Hi Steven,

Unless there are any further comments, could you please help to take
this through the tracing tree?

Thanks!

On Fri, Mar 6, 2026 at 11:06 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Fri, 6 Mar 2026 15:59:54 +0800
> Xuewen Yan <xuewen.yan@unisoc.com> wrote:
>
> > This reverts commit e3f6a42272e028c46695acc83fc7d7c42f2750ad.
> >
> > The commit says that the tracepoint only deals with the current task,
> > however the following case is not current task:
> >
> > comm_write() {
> >     p = get_proc_task(inode);
> >     if (!p)
> >         return -ESRCH;
> >
> >     if (same_thread_group(current, p))
> >         set_task_comm(p, buffer);
> > }
> > where set_task_comm() calls __set_task_comm() which records
> > the update of p and not current.
> >
> > So revert the patch to show pid.
> >
> > Fixes: e3f6a42272e0 ("tracing: Remove pid in task_rename tracing output")
> > Reported-by: Guohua Yan <guohua.yan@unisoc.com>
> > Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
>
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
>
> -- Steve
>
> > ---
> > v2:
> > - update commit message (Steven)
> > ---
> >  include/trace/events/task.h | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/trace/events/task.h b/include/trace/events/task.h
> > index 4f0759634306..b9a129eb54d9 100644
> > --- a/include/trace/events/task.h
> > +++ b/include/trace/events/task.h
> > @@ -38,19 +38,22 @@ TRACE_EVENT(task_rename,
> >       TP_ARGS(task, comm),
> >
> >       TP_STRUCT__entry(
> > +             __field(        pid_t,  pid)
> >               __array(        char, oldcomm,  TASK_COMM_LEN)
> >               __array(        char, newcomm,  TASK_COMM_LEN)
> >               __field(        short,  oom_score_adj)
> >       ),
> >
> >       TP_fast_assign(
> > +             __entry->pid = task->pid;
> >               memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
> >               strscpy(entry->newcomm, comm, TASK_COMM_LEN);
> >               __entry->oom_score_adj = task->signal->oom_score_adj;
> >       ),
> >
> > -     TP_printk("oldcomm=%s newcomm=%s oom_score_adj=%hd",
> > -               __entry->oldcomm, __entry->newcomm, __entry->oom_score_adj)
> > +     TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%hd",
> > +             __entry->pid, __entry->oldcomm,
> > +             __entry->newcomm, __entry->oom_score_adj)
> >  );
> >
> >  /**
>
Re: [PATCH V2] tracing: Revert "tracing: Remove pid in task_rename tracing output"
Posted by Steven Rostedt 3 weeks, 3 days ago
On Mon, 16 Mar 2026 10:00:13 +0800
Xuewen Yan <xuewen.yan94@gmail.com> wrote:

> Unless there are any further comments, could you please help to take
> this through the tracing tree?

I guess this file doesn't really have an owner, so yeah, I'll take it.

-- Steve