public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jens Axboe <axboe@kernel.dk>, Jiazi Li <jqqlijiazi@gmail.com>,
	linux-kernel@vger.kernel.org,
	"peixuan.qiu" <peixuan.qiu@transsion.com>,
	io-uring@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] stacktrace: do not trace user stack for user_worker tasks
Date: Wed, 25 Jun 2025 17:54:50 -0600	[thread overview]
Message-ID: <aFyMSoxZ-Iz33fL9@kbusch-mbp> (raw)
In-Reply-To: <20250625184144.48c87888@gandalf.local.home>

On Wed, Jun 25, 2025 at 06:41:44PM -0400, Steven Rostedt wrote:
> On Wed, 25 Jun 2025 16:30:55 -0600
> Jens Axboe <axboe@kernel.dk> wrote:
> 
> > On 6/25/25 2:50 PM, Steven Rostedt wrote:
> > > [
> > >   Adding Peter Zijlstra as he has been telling me to test against
> > >   PF_KTHREAD instead of current->mm to tell if it is a kernel thread.
> > >   But that seems to not be enough!
> > > ]  
> > 
> > Not sure I follow - if current->mm is NULL, then it's PF_KTHREAD too.
> > Unless it's used kthread_use_mm().
> > 
> > PF_USER_WORKER will have current->mm of the user task that it was cloned
> > from.
> 
> The suggestion was to use (current->flags & PF_KTHREAD) instead of
> !current->mm to determine if a task is a kernel thread or not as we don't
> want to do user space stack tracing on kernel threads. Peter said that
> because of io threads which have current->mm set, you can't rely on that,
> so check the PF_KHTREAD flag instead. This was assuming that io kthreads
> had that set too, but apparently it does not and we need to check for
> PF_USER_WORKER instead of just PF_KTHREAD.

If you're interested, here's a discussion with Linus on some fallout
with PF_USER_WORKER threads I stumbled upon a few months ago with no
clear longterm resolution:

  https://lore.kernel.org/kvm/CAHk-=wg4Wm4x9GoUk6M8BhLsrhLj4+n8jA2Kg8XUQF=kxgNL9g@mail.gmail.com/

That was about userspace problems with these PF_USER_WORKER tasks
spawned with vhost rather than anything in kernel, so it's from the
other side of what you're dealing with here. I'm just mentioning it in
case the improvements your considering could be useful for the userspace
side too.

      reply	other threads:[~2025-06-25 23:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250623115914.12076-1-jqqlijiazi@gmail.com>
2025-06-24 17:07 ` [PATCH] stacktrace: do not trace user stack for user_worker tasks Steven Rostedt
2025-06-25 10:00   ` Jiazi Li
2025-06-25 16:23   ` Jens Axboe
2025-06-25 20:50     ` Steven Rostedt
2025-06-25 22:30       ` Jens Axboe
2025-06-25 22:41         ` Steven Rostedt
2025-06-25 23:54           ` Keith Busch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aFyMSoxZ-Iz33fL9@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=jqqlijiazi@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peixuan.qiu@transsion.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox