[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251030112251.5afcf9ed@mordecai>
Date: Thu, 30 Oct 2025 11:25:03 +0100
From: Petr Tesarik <ptesarik@...e.com>
To: Valentin Schneider <vschneid@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org, rcu@...r.kernel.org,
x86@...nel.org, linux-arm-kernel@...ts.infradead.org,
loongarch@...ts.linux.dev, linux-riscv@...ts.infradead.org,
linux-arch@...r.kernel.org, linux-trace-kernel@...r.kernel.org, Josh
Poimboeuf <jpoimboe@...nel.org>, Thomas Gleixner <tglx@...utronix.de>, Ingo
Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, Dave Hansen
<dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>, Andy
Lutomirski <luto@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Paolo Bonzini
<pbonzini@...hat.com>, Arnd Bergmann <arnd@...db.de>, Frederic Weisbecker
<frederic@...nel.org>, "Paul E. McKenney" <paulmck@...nel.org>, Jason Baron
<jbaron@...mai.com>, Steven Rostedt <rostedt@...dmis.org>, Ard Biesheuvel
<ardb@...nel.org>, Sami Tolvanen <samitolvanen@...gle.com>, "David S.
Miller" <davem@...emloft.net>, Neeraj Upadhyay
<neeraj.upadhyay@...nel.org>, Joel Fernandes <joelagnelf@...dia.com>, Josh
Triplett <josh@...htriplett.org>, Boqun Feng <boqun.feng@...il.com>,
Uladzislau Rezki <urezki@...il.com>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, Mel Gorman <mgorman@...e.de>, Andrew
Morton <akpm@...ux-foundation.org>, Masahiro Yamada <masahiroy@...nel.org>,
Han Shen <shenhan@...gle.com>, Rik van Riel <riel@...riel.com>, Jann Horn
<jannh@...gle.com>, Dan Carpenter <dan.carpenter@...aro.org>, Oleg Nesterov
<oleg@...hat.com>, Juri Lelli <juri.lelli@...hat.com>, Clark Williams
<williams@...hat.com>, Yair Podemsky <ypodemsk@...hat.com>, Marcelo Tosatti
<mtosatti@...hat.com>, Daniel Wagner <dwagner@...e.de>
Subject: Re: [PATCH v6 06/29] static_call: Add read-only-after-init static
calls
On Fri, 10 Oct 2025 17:38:16 +0200
Valentin Schneider <vschneid@...hat.com> wrote:
> From: Josh Poimboeuf <jpoimboe@...nel.org>
>
> Deferring a code patching IPI is unsafe if the patched code is in a
> noinstr region. In that case the text poke code must trigger an
> immediate IPI to all CPUs, which can rudely interrupt an isolated NO_HZ
> CPU running in userspace.
>
> If a noinstr static call only needs to be patched during boot, its key
> can be made ro-after-init to ensure it will never be patched at runtime.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
> ---
> include/linux/static_call.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/include/linux/static_call.h b/include/linux/static_call.h
> index 78a77a4ae0ea8..ea6ca57e2a829 100644
> --- a/include/linux/static_call.h
> +++ b/include/linux/static_call.h
> @@ -192,6 +192,14 @@ extern long __static_call_return0(void);
> }; \
> ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func)
>
> +#define DEFINE_STATIC_CALL_RO(name, _func) \
> + DECLARE_STATIC_CALL(name, _func); \
> + struct static_call_key __ro_after_init STATIC_CALL_KEY(name) = {\
> + .func = _func, \
> + .type = 1, \
> + }; \
> + ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func)
> +
> #define DEFINE_STATIC_CALL_NULL(name, _func) \
> DECLARE_STATIC_CALL(name, _func); \
> struct static_call_key STATIC_CALL_KEY(name) = { \
> @@ -200,6 +208,14 @@ extern long __static_call_return0(void);
> }; \
> ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)
>
> +#define DEFINE_STATIC_CALL_NULL_RO(name, _func) \
> + DECLARE_STATIC_CALL(name, _func); \
> + struct static_call_key __ro_after_init STATIC_CALL_KEY(name) = {\
> + .func = NULL, \
> + .type = 1, \
> + }; \
> + ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)
> +
I think it would be a good idea to add a comment describing when these
macros are supposed to be used, similar to the explanation you wrote for
the _NOINSTR variants. Just to provide a clue for people adding a new
static key in the future, because the commit message may become a bit
hard to find if there are a few cleanup patches on top.
Just my two cents,
Petr T
Powered by blists - more mailing lists