[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250122225257.h64ftfnorofe7cb4@jpoimboe>
Date: Wed, 22 Jan 2025 14:52:57 -0800
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: x86@...nel.org, Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
linux-kernel@...r.kernel.org, Indu Bhagat <indu.bhagat@...cle.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
linux-perf-users@...r.kernel.org, Mark Brown <broonie@...nel.org>,
linux-toolchains@...r.kernel.org, Jordan Rome <jordalgo@...a.com>,
Sam James <sam@...too.org>, linux-trace-kernel@...r.kernel.org,
Andrii Nakryiko <andrii.nakryiko@...il.com>,
Jens Remus <jremus@...ux.ibm.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Florian Weimer <fweimer@...hat.com>,
Andy Lutomirski <luto@...nel.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Weinan Liu <wnliu@...gle.com>
Subject: Re: [PATCH v4 30/39] unwind_user/deferred: Make unwind deferral
requests NMI-safe
On Wed, Jan 22, 2025 at 03:24:18PM +0100, Peter Zijlstra wrote:
> On Tue, Jan 21, 2025 at 06:31:22PM -0800, Josh Poimboeuf wrote:
> > +static int unwind_deferred_request_nmi(struct unwind_work *work, u64 *cookie)
> > +{
> > + struct unwind_task_info *info = ¤t->unwind_info;
> > + bool inited_cookie = false;
> > + int ret;
> > +
> > + *cookie = info->cookie;
> > + if (!*cookie) {
> > + /*
> > + * This is the first unwind request since the most recent entry
> > + * from user. Initialize the task cookie.
> > + *
> > + * Don't write to info->cookie directly, otherwise it may get
> > + * cleared if the NMI occurred in the kernel during early entry
> > + * or late exit before the task work gets to run. Instead, use
> > + * info->nmi_cookie which gets synced later by get_cookie().
> > + */
> > + if (!info->nmi_cookie) {
> > + u64 cpu = raw_smp_processor_id();
> > + u64 ctx_ctr;
> > +
> > + ctx_ctr = __this_cpu_inc_return(unwind_ctx_ctr);
>
> __this_cpu_inc_return() is *NOT* NMI safe IIRC.
Hm, I guess I was only looking at x86.
--
Josh
Powered by blists - more mailing lists