Re: [PATCH v5 11/17] perf: Simplify get_perf_callchain() user logic
From: Steven Rostedt
Date: Thu Apr 24 2025 - 13:26:17 EST
On Thu, 24 Apr 2025 18:36:07 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > +++ b/kernel/events/callchain.c
> > @@ -246,22 +246,20 @@ get_perf_callchain(struct pt_regs *regs, bool kernel, bool user,
> >
> > if (user) {
> > if (!user_mode(regs)) {
> > - if (current->mm)
> > - regs = task_pt_regs(current);
> > - else
> > - regs = NULL;
> > + if (!current->mm)
> > + goto exit_put;
> > + regs = task_pt_regs(current);
>
> I'm thinking this might be one of those is-kthread test written as
> has-mm, and they're broken.
>
> Notably things like the io-uring kthreads do have mm.
Would there ever be a case where:
current->mm == NULL && !(current->flags & PF_KTHREAD)
?
That is, do we still need to check for current->mm if it's not a kernel
thread, or can we assume it exists?
-- Steve