linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] jump_label: avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE}
@ 2022-02-13 16:57 Masahiro Yamada
  2022-02-13 16:57 ` [PATCH 2/2] jump_label: refactor #ifdef of struct static_key Masahiro Yamada
  2022-02-17 18:56 ` [tip: locking/core] jump_label: Avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE} tip-bot2 for Masahiro Yamada
  0 siblings, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-02-13 16:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, Masahiro Yamada, Ard Biesheuvel, Jason Baron,
	Josh Poimboeuf, Steven Rostedt

Commit 3821fd35b58d ("jump_label: Reduce the size of struct static_key")
introduced the union to struct static_key.

It is more natual to set JUMP_TYPE_* to the .type field without casting.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 include/linux/jump_label.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 48b9b2a82767..6924e6837e6d 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -251,10 +251,10 @@ extern void static_key_disable_cpuslocked(struct static_key *key);
  */
 #define STATIC_KEY_INIT_TRUE					\
 	{ .enabled = { 1 },					\
-	  { .entries = (void *)JUMP_TYPE_TRUE } }
+	  { .type = JUMP_TYPE_TRUE } }
 #define STATIC_KEY_INIT_FALSE					\
 	{ .enabled = { 0 },					\
-	  { .entries = (void *)JUMP_TYPE_FALSE } }
+	  { .type = JUMP_TYPE_FALSE } }
 
 #else  /* !CONFIG_JUMP_LABEL */
 
-- 
2.32.0


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

* [PATCH 2/2] jump_label: refactor #ifdef of struct static_key
  2022-02-13 16:57 [PATCH 1/2] jump_label: avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE} Masahiro Yamada
@ 2022-02-13 16:57 ` Masahiro Yamada
  2022-02-17 18:56   ` [tip: locking/core] jump_label: Refactor " tip-bot2 for Masahiro Yamada
  2022-02-18 19:07   ` [PATCH 2/2] jump_label: refactor " Jason Baron
  2022-02-17 18:56 ` [tip: locking/core] jump_label: Avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE} tip-bot2 for Masahiro Yamada
  1 sibling, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-02-13 16:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, Masahiro Yamada, Ard Biesheuvel, Jason Baron,
	Josh Poimboeuf, Steven Rostedt

Move #ifdef CONFIG_JUMP_LABEL inside the struct static_key.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 include/linux/jump_label.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 6924e6837e6d..107751cc047b 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -82,10 +82,9 @@ extern bool static_key_initialized;
 				    "%s(): static key '%pS' used before call to jump_label_init()", \
 				    __func__, (key))
 
-#ifdef CONFIG_JUMP_LABEL
-
 struct static_key {
 	atomic_t enabled;
+#ifdef CONFIG_JUMP_LABEL
 /*
  * Note:
  *   To make anonymous unions work with old compilers, the static
@@ -104,13 +103,9 @@ struct static_key {
 		struct jump_entry *entries;
 		struct static_key_mod *next;
 	};
+#endif	/* CONFIG_JUMP_LABEL */
 };
 
-#else
-struct static_key {
-	atomic_t enabled;
-};
-#endif	/* CONFIG_JUMP_LABEL */
 #endif /* __ASSEMBLY__ */
 
 #ifdef CONFIG_JUMP_LABEL
-- 
2.32.0


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

* [tip: locking/core] jump_label: Refactor #ifdef of struct static_key
  2022-02-13 16:57 ` [PATCH 2/2] jump_label: refactor #ifdef of struct static_key Masahiro Yamada
@ 2022-02-17 18:56   ` tip-bot2 for Masahiro Yamada
  2022-02-18 19:07   ` [PATCH 2/2] jump_label: refactor " Jason Baron
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Masahiro Yamada @ 2022-02-17 18:56 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Masahiro Yamada, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     cd27ccfc727e99352321c0c75012ab9c5a90321e
Gitweb:        https://git.kernel.org/tip/cd27ccfc727e99352321c0c75012ab9c5a90321e
Author:        Masahiro Yamada <masahiroy@kernel.org>
AuthorDate:    Mon, 14 Feb 2022 01:57:17 +09:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 16 Feb 2022 15:57:58 +01:00

jump_label: Refactor #ifdef of struct static_key

Move #ifdef CONFIG_JUMP_LABEL inside the struct static_key.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220213165717.2354046-2-masahiroy@kernel.org
---
 include/linux/jump_label.h |  9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 6924e68..107751c 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -82,10 +82,9 @@ extern bool static_key_initialized;
 				    "%s(): static key '%pS' used before call to jump_label_init()", \
 				    __func__, (key))
 
-#ifdef CONFIG_JUMP_LABEL
-
 struct static_key {
 	atomic_t enabled;
+#ifdef CONFIG_JUMP_LABEL
 /*
  * Note:
  *   To make anonymous unions work with old compilers, the static
@@ -104,13 +103,9 @@ struct static_key {
 		struct jump_entry *entries;
 		struct static_key_mod *next;
 	};
+#endif	/* CONFIG_JUMP_LABEL */
 };
 
-#else
-struct static_key {
-	atomic_t enabled;
-};
-#endif	/* CONFIG_JUMP_LABEL */
 #endif /* __ASSEMBLY__ */
 
 #ifdef CONFIG_JUMP_LABEL

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

* [tip: locking/core] jump_label: Avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE}
  2022-02-13 16:57 [PATCH 1/2] jump_label: avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE} Masahiro Yamada
  2022-02-13 16:57 ` [PATCH 2/2] jump_label: refactor #ifdef of struct static_key Masahiro Yamada
@ 2022-02-17 18:56 ` tip-bot2 for Masahiro Yamada
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Masahiro Yamada @ 2022-02-17 18:56 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Masahiro Yamada, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     fe65deb56e552a8c9bf7f27860dbdeac12a36116
Gitweb:        https://git.kernel.org/tip/fe65deb56e552a8c9bf7f27860dbdeac12a36116
Author:        Masahiro Yamada <masahiroy@kernel.org>
AuthorDate:    Mon, 14 Feb 2022 01:57:16 +09:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 16 Feb 2022 15:57:58 +01:00

jump_label: Avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE}

Commit 3821fd35b58d ("jump_label: Reduce the size of struct static_key")
introduced the union to struct static_key.

It is more natual to set JUMP_TYPE_* to the .type field without casting.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220213165717.2354046-1-masahiroy@kernel.org
---
 include/linux/jump_label.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 48b9b2a..6924e68 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -251,10 +251,10 @@ extern void static_key_disable_cpuslocked(struct static_key *key);
  */
 #define STATIC_KEY_INIT_TRUE					\
 	{ .enabled = { 1 },					\
-	  { .entries = (void *)JUMP_TYPE_TRUE } }
+	  { .type = JUMP_TYPE_TRUE } }
 #define STATIC_KEY_INIT_FALSE					\
 	{ .enabled = { 0 },					\
-	  { .entries = (void *)JUMP_TYPE_FALSE } }
+	  { .type = JUMP_TYPE_FALSE } }
 
 #else  /* !CONFIG_JUMP_LABEL */
 

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

* Re: [PATCH 2/2] jump_label: refactor #ifdef of struct static_key
  2022-02-13 16:57 ` [PATCH 2/2] jump_label: refactor #ifdef of struct static_key Masahiro Yamada
  2022-02-17 18:56   ` [tip: locking/core] jump_label: Refactor " tip-bot2 for Masahiro Yamada
@ 2022-02-18 19:07   ` Jason Baron
  2022-02-18 19:27     ` Josh Poimboeuf
  1 sibling, 1 reply; 6+ messages in thread
From: Jason Baron @ 2022-02-18 19:07 UTC (permalink / raw)
  To: Masahiro Yamada, Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, Ard Biesheuvel, Josh Poimboeuf, Steven Rostedt

On 2/13/22 11:57, Masahiro Yamada wrote:
> Move #ifdef CONFIG_JUMP_LABEL inside the struct static_key.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  include/linux/jump_label.h | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
> index 6924e6837e6d..107751cc047b 100644
> --- a/include/linux/jump_label.h
> +++ b/include/linux/jump_label.h
> @@ -82,10 +82,9 @@ extern bool static_key_initialized;
>  				    "%s(): static key '%pS' used before call to jump_label_init()", \
>  				    __func__, (key))
>  
> -#ifdef CONFIG_JUMP_LABEL
> -
>  struct static_key {
>  	atomic_t enabled;
> +#ifdef CONFIG_JUMP_LABEL
>  /*
>   * Note:
>   *   To make anonymous unions work with old compilers, the static
> @@ -104,13 +103,9 @@ struct static_key {
>  		struct jump_entry *entries;
>  		struct static_key_mod *next;
>  	};
> +#endif	/* CONFIG_JUMP_LABEL */
>  };
>  
> -#else
> -struct static_key {
> -	atomic_t enabled;
> -};
> -#endif	/* CONFIG_JUMP_LABEL */
>  #endif /* __ASSEMBLY__ */
>  
>  #ifdef CONFIG_JUMP_LABEL


These two cleanups look fine to me.

Acked-by: Jason Baron <jbaron@akamai.com>>

Thanks,

-Jason

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

* Re: [PATCH 2/2] jump_label: refactor #ifdef of struct static_key
  2022-02-18 19:07   ` [PATCH 2/2] jump_label: refactor " Jason Baron
@ 2022-02-18 19:27     ` Josh Poimboeuf
  0 siblings, 0 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2022-02-18 19:27 UTC (permalink / raw)
  To: Jason Baron
  Cc: Masahiro Yamada, Peter Zijlstra, Ingo Molnar, linux-kernel,
	Ard Biesheuvel, Steven Rostedt

On Fri, Feb 18, 2022 at 02:07:26PM -0500, Jason Baron wrote:
> On 2/13/22 11:57, Masahiro Yamada wrote:
> > Move #ifdef CONFIG_JUMP_LABEL inside the struct static_key.
> > 
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> > 
> >  include/linux/jump_label.h | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> > 
> > diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
> > index 6924e6837e6d..107751cc047b 100644
> > --- a/include/linux/jump_label.h
> > +++ b/include/linux/jump_label.h
> > @@ -82,10 +82,9 @@ extern bool static_key_initialized;
> >  				    "%s(): static key '%pS' used before call to jump_label_init()", \
> >  				    __func__, (key))
> >  
> > -#ifdef CONFIG_JUMP_LABEL
> > -
> >  struct static_key {
> >  	atomic_t enabled;
> > +#ifdef CONFIG_JUMP_LABEL
> >  /*
> >   * Note:
> >   *   To make anonymous unions work with old compilers, the static
> > @@ -104,13 +103,9 @@ struct static_key {
> >  		struct jump_entry *entries;
> >  		struct static_key_mod *next;
> >  	};
> > +#endif	/* CONFIG_JUMP_LABEL */
> >  };
> >  
> > -#else
> > -struct static_key {
> > -	atomic_t enabled;
> > -};
> > -#endif	/* CONFIG_JUMP_LABEL */
> >  #endif /* __ASSEMBLY__ */
> >  
> >  #ifdef CONFIG_JUMP_LABEL
> 
> 
> These two cleanups look fine to me.
> 
> Acked-by: Jason Baron <jbaron@akamai.com>>

Both look fine to me as well.  For both patches:

Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>

-- 
Josh


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

end of thread, other threads:[~2022-02-18 19:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-13 16:57 [PATCH 1/2] jump_label: avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE} Masahiro Yamada
2022-02-13 16:57 ` [PATCH 2/2] jump_label: refactor #ifdef of struct static_key Masahiro Yamada
2022-02-17 18:56   ` [tip: locking/core] jump_label: Refactor " tip-bot2 for Masahiro Yamada
2022-02-18 19:07   ` [PATCH 2/2] jump_label: refactor " Jason Baron
2022-02-18 19:27     ` Josh Poimboeuf
2022-02-17 18:56 ` [tip: locking/core] jump_label: Avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE} tip-bot2 for Masahiro Yamada

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