[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8c612fbd-2f23-486c-9f6b-8bf4d0c23705@roeck-us.net>
Date: Mon, 26 Jan 2026 09:29:27 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, Masami Hiramatsu <mhiramat@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>, Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [RESEND][PATCH 3/5] perf: Use current->flags &
PF_KTHREAD|PF_USER_WORKER instead of current->mm == NULL
On 1/26/26 09:18, Steven Rostedt wrote:
> On Mon, 26 Jan 2026 12:05:53 -0500
> Steven Rostedt <rostedt@...nel.org> wrote:
>
>> I guess we need to also test for !current->mm because the flags set for an
>> exiting task is done when we can still do callchains. Thus, the only way to
>> know if it is safe to do a callchain when a task is exiting is via task->mm
>> and not task->flags :-/
>
> Can you test this patch?
>
Sure, though we had dropped the offending patch from the LTS backport, so that
will take a bit.
Guenter
> -- Steve
>
> diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
> index 1f6589578703..c82d61d73bd8 100644
> --- a/kernel/events/callchain.c
> +++ b/kernel/events/callchain.c
> @@ -246,7 +246,14 @@ get_perf_callchain(struct pt_regs *regs, bool kernel, bool user,
>
> if (user && !crosstask) {
> if (!user_mode(regs)) {
> - if (current->flags & (PF_KTHREAD | PF_USER_WORKER))
> + /*
> + * Testing current->mm is not enough as some kernel threads
> + * may have one set. But testing the flags is not enough
> + * either as this can be called after a user task
> + * frees its mm just before it exits.
> + */
> + if (!current->mm ||
> + (current->flags & (PF_KTHREAD | PF_USER_WORKER)))
> goto exit_put;
> regs = task_pt_regs(current);
> }
Powered by blists - more mailing lists