[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250625100049.GA17376@Jiazi.Li>
Date: Wed, 25 Jun 2025 18:00:49 +0800
From: Jiazi Li <jqqlijiazi@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, "peixuan.qiu" <peixuan.qiu@...nssion.com>,
Jens Axboe <axboe@...nel.dk>, io-uring@...r.kernel.org
Subject: Re: [PATCH] stacktrace: do not trace user stack for user_worker tasks
On Tue, Jun 24, 2025 at 01:07:44PM -0400, Steven Rostedt wrote:
> On Mon, 23 Jun 2025 19:59:11 +0800
> Jiazi Li <jqqlijiazi@...il.com> wrote:
>
> > Tasks with PF_USER_WORKER flag also only run in kernel space,
> > so do not trace user stack for these tasks.
>
> What exactly is the difference between PF_KTHREAD and PF_USER_WORKER?
>
I think that apart from never return to user space, PF_USER_WORKER is
basically the same as user space task.
> Has all the locations that test for PF_KTHREAD been audited to make
> sure that PF_USER_WORKER isn't also needed?
>
No.
> I'm working on other code that needs to differentiate between user
> tasks and kernel tasks, and having to have multiple flags to test is
> becoming quite a burden.
>
Yes, so only check both PF_KTHREAD and PF_USER_WORKER before access
user space stack?
> -- Steve
>
>
> >
> > Signed-off-by: Jiazi Li <jqqlijiazi@...il.com>
> > Signed-off-by: peixuan.qiu <peixuan.qiu@...nssion.com>
> > ---
> > kernel/stacktrace.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
> > index afb3c116da91..82fbccdd1a24 100644
> > --- a/kernel/stacktrace.c
> > +++ b/kernel/stacktrace.c
> > @@ -228,8 +228,8 @@ unsigned int stack_trace_save_user(unsigned long *store, unsigned int size)
> > .size = size,
> > };
> >
> > - /* Trace user stack if not a kernel thread */
> > - if (current->flags & PF_KTHREAD)
> > + /* Skip tasks that do not return to userspace */
> > + if (current->flags & (PF_KTHREAD | PF_USER_WORKER))
> > return 0;
> >
> > arch_stack_walk_user(consume_entry, &c, task_pt_regs(current));
>
Powered by blists - more mailing lists