netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] once: switch to new jump label API
@ 2017-08-21 23:42 Eric Biggers
  2017-08-22 18:44 ` Hannes Frederic Sowa
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2017-08-21 23:42 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Hannes Frederic Sowa, Jason Baron, Peter Zijlstra,
	Eric Biggers

From: Eric Biggers <ebiggers@google.com>

Switch the DO_ONCE() macro from the deprecated jump label API to the new
one.  The new one is more readable, and for DO_ONCE() it also makes the
generated code more icache-friendly: now the one-time initialization
code is placed out-of-line at the jump target, rather than at the inline
fallthrough case.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 include/linux/once.h | 6 +++---
 lib/once.c           | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/once.h b/include/linux/once.h
index 9c98aaa87cbc..724724918e8b 100644
--- a/include/linux/once.h
+++ b/include/linux/once.h
@@ -5,7 +5,7 @@
 #include <linux/jump_label.h>
 
 bool __do_once_start(bool *done, unsigned long *flags);
-void __do_once_done(bool *done, struct static_key *once_key,
+void __do_once_done(bool *done, struct static_key_true *once_key,
 		    unsigned long *flags);
 
 /* Call a function exactly once. The idea of DO_ONCE() is to perform
@@ -38,8 +38,8 @@ void __do_once_done(bool *done, struct static_key *once_key,
 	({								     \
 		bool ___ret = false;					     \
 		static bool ___done = false;				     \
-		static struct static_key ___once_key = STATIC_KEY_INIT_TRUE; \
-		if (static_key_true(&___once_key)) {			     \
+		static DEFINE_STATIC_KEY_TRUE(___once_key);		     \
+		if (static_branch_unlikely(&___once_key)) {		     \
 			unsigned long ___flags;				     \
 			___ret = __do_once_start(&___done, &___flags);	     \
 			if (unlikely(___ret)) {				     \
diff --git a/lib/once.c b/lib/once.c
index 05c8604627eb..831c5a6b0bb2 100644
--- a/lib/once.c
+++ b/lib/once.c
@@ -5,7 +5,7 @@
 
 struct once_work {
 	struct work_struct work;
-	struct static_key *key;
+	struct static_key_true *key;
 };
 
 static void once_deferred(struct work_struct *w)
@@ -14,11 +14,11 @@ static void once_deferred(struct work_struct *w)
 
 	work = container_of(w, struct once_work, work);
 	BUG_ON(!static_key_enabled(work->key));
-	static_key_slow_dec(work->key);
+	static_branch_disable(work->key);
 	kfree(work);
 }
 
-static void once_disable_jump(struct static_key *key)
+static void once_disable_jump(struct static_key_true *key)
 {
 	struct once_work *w;
 
@@ -51,7 +51,7 @@ bool __do_once_start(bool *done, unsigned long *flags)
 }
 EXPORT_SYMBOL(__do_once_start);
 
-void __do_once_done(bool *done, struct static_key *once_key,
+void __do_once_done(bool *done, struct static_key_true *once_key,
 		    unsigned long *flags)
 	__releases(once_lock)
 {
-- 
2.14.1.480.gb18f417b89-goog

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] once: switch to new jump label API
  2017-08-21 23:42 [PATCH] once: switch to new jump label API Eric Biggers
@ 2017-08-22 18:44 ` Hannes Frederic Sowa
  2017-09-16  4:07   ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: Hannes Frederic Sowa @ 2017-08-22 18:44 UTC (permalink / raw)
  To: Eric Biggers
  Cc: netdev, linux-kernel, Jason Baron, Peter Zijlstra, Eric Biggers

Eric Biggers <ebiggers3@gmail.com> writes:

> From: Eric Biggers <ebiggers@google.com>
>
> Switch the DO_ONCE() macro from the deprecated jump label API to the new
> one.  The new one is more readable, and for DO_ONCE() it also makes the
> generated code more icache-friendly: now the one-time initialization
> code is placed out-of-line at the jump target, rather than at the inline
> fallthrough case.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org.

Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] once: switch to new jump label API
  2017-08-22 18:44 ` Hannes Frederic Sowa
@ 2017-09-16  4:07   ` Eric Biggers
  2017-10-09 20:27     ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2017-09-16  4:07 UTC (permalink / raw)
  To: Hannes Frederic Sowa
  Cc: David S. Miller, netdev, linux-kernel, Jason Baron,
	Peter Zijlstra, Eric Biggers

On Tue, Aug 22, 2017 at 02:44:41PM -0400, Hannes Frederic Sowa wrote:
> Eric Biggers <ebiggers3@gmail.com> writes:
> 
> > From: Eric Biggers <ebiggers@google.com>
> >
> > Switch the DO_ONCE() macro from the deprecated jump label API to the new
> > one.  The new one is more readable, and for DO_ONCE() it also makes the
> > generated code more icache-friendly: now the one-time initialization
> > code is placed out-of-line at the jump target, rather than at the inline
> > fallthrough case.
> >
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> 
> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org.
> 
> Thanks!

Great!  Who though is the maintainer for this code?  It seems it was originally
taken by David Miller through the networking tree.  David, are you taking
further patches to the "once" functions, or should I be trying to get this into
-mm, or somewhere else?

Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] once: switch to new jump label API
  2017-09-16  4:07   ` Eric Biggers
@ 2017-10-09 20:27     ` Eric Biggers
  2017-10-09 21:14       ` Daniel Borkmann
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2017-10-09 20:27 UTC (permalink / raw)
  To: Hannes Frederic Sowa
  Cc: David S. Miller, netdev, linux-kernel, Jason Baron,
	Peter Zijlstra, Eric Biggers

On Fri, Sep 15, 2017 at 09:07:51PM -0700, Eric Biggers wrote:
> On Tue, Aug 22, 2017 at 02:44:41PM -0400, Hannes Frederic Sowa wrote:
> > Eric Biggers <ebiggers3@gmail.com> writes:
> > 
> > > From: Eric Biggers <ebiggers@google.com>
> > >
> > > Switch the DO_ONCE() macro from the deprecated jump label API to the new
> > > one.  The new one is more readable, and for DO_ONCE() it also makes the
> > > generated code more icache-friendly: now the one-time initialization
> > > code is placed out-of-line at the jump target, rather than at the inline
> > > fallthrough case.
> > >
> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > 
> > Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org.
> > 
> > Thanks!
> 
> Great!  Who though is the maintainer for this code?  It seems it was originally
> taken by David Miller through the networking tree.  David, are you taking
> further patches to the "once" functions, or should I be trying to get this into
> -mm, or somewhere else?
> 
> Eric

Ping.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] once: switch to new jump label API
  2017-10-09 20:27     ` Eric Biggers
@ 2017-10-09 21:14       ` Daniel Borkmann
  2017-10-09 21:17         ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Borkmann @ 2017-10-09 21:14 UTC (permalink / raw)
  To: Eric Biggers, Hannes Frederic Sowa
  Cc: David S. Miller, netdev, linux-kernel, Jason Baron,
	Peter Zijlstra, Eric Biggers

On 10/09/2017 10:27 PM, Eric Biggers wrote:
> On Fri, Sep 15, 2017 at 09:07:51PM -0700, Eric Biggers wrote:
>> On Tue, Aug 22, 2017 at 02:44:41PM -0400, Hannes Frederic Sowa wrote:
>>> Eric Biggers <ebiggers3@gmail.com> writes:
>>>> From: Eric Biggers <ebiggers@google.com>
>>>>
>>>> Switch the DO_ONCE() macro from the deprecated jump label API to the new
>>>> one.  The new one is more readable, and for DO_ONCE() it also makes the
>>>> generated code more icache-friendly: now the one-time initialization
>>>> code is placed out-of-line at the jump target, rather than at the inline
>>>> fallthrough case.
>>>>
>>>> Signed-off-by: Eric Biggers <ebiggers@google.com>
>>>
>>> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org.
>>>
>>> Thanks!
>>
>> Great!  Who though is the maintainer for this code?  It seems it was originally
>> taken by David Miller through the networking tree.  David, are you taking
>> further patches to the "once" functions, or should I be trying to get this into
>> -mm, or somewhere else?
>>
>> Eric
>
> Ping.

Given original code was accepted against net-next tree as major users of
the api are networking related anyway, it should be fine here as well to
route through this tree. Maybe resend the patch with a [PATCH net-next]
in the subject line (as usually done) to make the targeted tree more clear.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] once: switch to new jump label API
  2017-10-09 21:14       ` Daniel Borkmann
@ 2017-10-09 21:17         ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-09 21:17 UTC (permalink / raw)
  To: daniel; +Cc: ebiggers3, hannes, netdev, linux-kernel, jbaron, peterz, ebiggers

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Mon, 09 Oct 2017 23:14:42 +0200

> Given original code was accepted against net-next tree as major
> users of the api are networking related anyway, it should be fine
> here as well to route through this tree. Maybe resend the patch with
> a [PATCH net-next] in the subject line (as usually done) to make the
> targeted tree more clear.

Indeed, please do, sorry for not replying.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-09 21:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-21 23:42 [PATCH] once: switch to new jump label API Eric Biggers
2017-08-22 18:44 ` Hannes Frederic Sowa
2017-09-16  4:07   ` Eric Biggers
2017-10-09 20:27     ` Eric Biggers
2017-10-09 21:14       ` Daniel Borkmann
2017-10-09 21:17         ` David Miller

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).