linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Jason Baron" <jbaron@akamai.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	linux-trace-kernel@vger.kernel.org,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Arnd Bergmann" <arnd@arndb.de>,
	linux-arch@vger.kernel.org,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Sean Christopherson" <seanjc@google.com>,
	"Uros Bizjak" <ubizjak@gmail.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>, "Marc Zyngier" <maz@kernel.org>,
	"Oliver Upton" <oliver.upton@linux.dev>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	"Fuad Tabba" <tabba@google.com>,
	linux-arm-kernel@lists.infradead.org,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Anup Patel" <apatel@ventanamicro.com>,
	"Andrew Jones" <ajones@ventanamicro.com>,
	"Alexandre Ghiti" <alexghiti@rivosinc.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Samuel Holland" <samuel.holland@sifive.com>,
	linux-riscv@lists.infradead.org,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"WANG Xuerui" <kernel@xen0n.name>,
	"Bibo Mao" <maobibo@loongson.cn>,
	"Tiezhu Yang" <yangtiezhu@loongson.cn>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Tianrui Zhao" <zhaotianrui@loongson.cn>,
	loongarch@lists.linux.dev
Subject: Re: [PATCH v9 1/5] rust: add generic static_key_false
Date: Tue, 1 Oct 2024 17:46:06 -0400	[thread overview]
Message-ID: <20241001174606.6f396dfd@gandalf.local.home> (raw)
In-Reply-To: <20241001211543.qdjl4pyfhehxqfk7@treble>

On Tue, 1 Oct 2024 14:15:43 -0700
Josh Poimboeuf <jpoimboe@kernel.org> wrote:

> On Tue, Oct 01, 2024 at 01:29:58PM +0000, Alice Ryhl wrote:
> > Add just enough support for static key so that we can use it from
> > tracepoints. Tracepoints rely on `static_key_false` even though it is
> > deprecated, so we add the same functionality to Rust.  
> 
> Instead of extending the old deprecated static key interface into Rust,
> can we just change tracepoints to use the new one?

Sure, care to send the patch properly, and I can add it to my queue.

-- Steve

> 
> /me makes a note to go convert the other users...
> 
> From: Josh Poimboeuf <jpoimboe@kernel.org>
> Subject: [PATCH] tracepoints: Use new static branch API
> 
> The old static key API based on 'struct static_key' is deprecated.
> Convert tracepoints to use the new API.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
>  include/linux/tracepoint-defs.h | 4 ++--
>  include/linux/tracepoint.h      | 8 ++++----
>  kernel/tracepoint.c             | 4 ++--
>  3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/tracepoint-defs.h b/include/linux/tracepoint-defs.h
> index 4dc4955f0fbf..60a6e8314d4c 100644
> --- a/include/linux/tracepoint-defs.h
> +++ b/include/linux/tracepoint-defs.h
> @@ -31,7 +31,7 @@ struct tracepoint_func {
>  
>  struct tracepoint {
>  	const char *name;		/* Tracepoint name */
> -	struct static_key key;
> +	struct static_key_false key;
>  	struct static_call_key *static_call_key;
>  	void *static_call_tramp;
>  	void *iterator;
> @@ -83,7 +83,7 @@ struct bpf_raw_event_map {
>  
>  #ifdef CONFIG_TRACEPOINTS
>  # define tracepoint_enabled(tp) \
> -	static_key_false(&(__tracepoint_##tp).key)
> +	static_branch_unlikely(&(__tracepoint_##tp).key)
>  #else
>  # define tracepoint_enabled(tracepoint) false
>  #endif
> diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> index 6be396bb4297..ab5162fc3e4a 100644
> --- a/include/linux/tracepoint.h
> +++ b/include/linux/tracepoint.h
> @@ -228,7 +228,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
>  #define __DECLARE_TRACE_RCU(name, proto, args, cond)			\
>  	static inline void trace_##name##_rcuidle(proto)		\
>  	{								\
> -		if (static_key_false(&__tracepoint_##name.key))		\
> +		if (static_branch_unlikely(&__tracepoint_##name.key))	\
>  			__DO_TRACE(name,				\
>  				TP_ARGS(args),				\
>  				TP_CONDITION(cond), 1);			\
> @@ -254,7 +254,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
>  	extern struct tracepoint __tracepoint_##name;			\
>  	static inline void trace_##name(proto)				\
>  	{								\
> -		if (static_key_false(&__tracepoint_##name.key))		\
> +		if (static_branch_unlikely(&__tracepoint_##name.key))	\
>  			__DO_TRACE(name,				\
>  				TP_ARGS(args),				\
>  				TP_CONDITION(cond), 0);			\
> @@ -291,7 +291,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
>  	static inline bool						\
>  	trace_##name##_enabled(void)					\
>  	{								\
> -		return static_key_false(&__tracepoint_##name.key);	\
> +		return static_branch_unlikely(&__tracepoint_##name.key);\
>  	}
>  
>  /*
> @@ -308,7 +308,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
>  	struct tracepoint __tracepoint_##_name	__used			\
>  	__section("__tracepoints") = {					\
>  		.name = __tpstrtab_##_name,				\
> -		.key = STATIC_KEY_INIT_FALSE,				\
> +		.key = STATIC_KEY_FALSE_INIT,				\
>  		.static_call_key = &STATIC_CALL_KEY(tp_func_##_name),	\
>  		.static_call_tramp = STATIC_CALL_TRAMP_ADDR(tp_func_##_name), \
>  		.iterator = &__traceiter_##_name,			\
> diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
> index 8d1507dd0724..dc160cc0b616 100644
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -358,7 +358,7 @@ static int tracepoint_add_func(struct tracepoint *tp,
>  		tracepoint_update_call(tp, tp_funcs);
>  		/* Both iterator and static call handle NULL tp->funcs */
>  		rcu_assign_pointer(tp->funcs, tp_funcs);
> -		static_key_enable(&tp->key);
> +		static_branch_enable(&tp->key);
>  		break;
>  	case TP_FUNC_2:		/* 1->2 */
>  		/* Set iterator static call */
> @@ -414,7 +414,7 @@ static int tracepoint_remove_func(struct tracepoint *tp,
>  		if (tp->unregfunc && static_key_enabled(&tp->key))
>  			tp->unregfunc();
>  
> -		static_key_disable(&tp->key);
> +		static_branch_disable(&tp->key);
>  		/* Set iterator static call */
>  		tracepoint_update_call(tp, tp_funcs);
>  		/* Both iterator and static call handle NULL tp->funcs */


  reply	other threads:[~2024-10-01 21:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-01 13:29 [PATCH v9 0/5] Tracepoints and static branch in Rust Alice Ryhl
2024-10-01 13:29 ` [PATCH v9 1/5] rust: add generic static_key_false Alice Ryhl
2024-10-01 14:12   ` Steven Rostedt
2024-10-01 14:13     ` Alice Ryhl
2024-10-01 21:15   ` Josh Poimboeuf
2024-10-01 21:46     ` Steven Rostedt [this message]
2024-10-01 22:28       ` Josh Poimboeuf
2024-10-10 19:43     ` Steven Rostedt
2024-10-11 10:16       ` Alice Ryhl
2024-10-01 13:29 ` [PATCH v9 2/5] rust: add tracepoint support Alice Ryhl
2024-10-01 13:30 ` [PATCH v9 3/5] rust: samples: add tracepoint to Rust sample Alice Ryhl
2024-10-01 13:30 ` [PATCH v9 4/5] jump_label: adjust inline asm to be consistent Alice Ryhl
2024-10-01 14:14   ` Steven Rostedt
2024-10-10 19:38     ` Steven Rostedt
2024-10-01 16:16   ` Catalin Marinas
2024-10-01 16:20     ` Steven Rostedt
2024-10-01 13:30 ` [PATCH v9 5/5] rust: add arch_static_branch Alice Ryhl

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=20241001174606.6f396dfd@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=a.hindborg@kernel.org \
    --cc=ajones@ventanamicro.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.gaynor@gmail.com \
    --cc=alexghiti@rivosinc.com \
    --cc=aliceryhl@google.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=apatel@ventanamicro.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=gary@garyguo.net \
    --cc=hpa@zytor.com \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=maobibo@loongson.cn \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=maz@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=samuel.holland@sifive.com \
    --cc=seanjc@google.com \
    --cc=tabba@google.com \
    --cc=tglx@linutronix.de \
    --cc=ubizjak@gmail.com \
    --cc=wedsonaf@gmail.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=yangtiezhu@loongson.cn \
    --cc=zhaotianrui@loongson.cn \
    /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;
as well as URLs for NNTP newsgroup(s).