jump_label: avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE}
PATCH 1/2 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.
---
include/linux/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/jump_label.h +2 -2
@@ -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 */
Signature · 1 line
2.32.0
PATCH 2/2 jump_label: refactor #ifdef of struct static_key
Move #ifdef CONFIG_JUMP_LABEL inside the struct static_key.
---
include/linux/jump_label.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
include/linux/jump_label.h +2 -7
@@ -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
Signature · 1 line
2.32.0
[tip: locking/core] jump_label: Refactor #ifdef of struct static_key
The following commit has been merged into the locking/core branch of tip:
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 <[email protected]> AuthorDate: Mon, 14 Feb 2022 01:57:17 +09:00 Committer: Peter Zijlstra <[email protected]> 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.
--- include/linux/jump_label.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
include/linux/jump_label.h +2 -7
@@ -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
Re: [PATCH 2/2] jump_label: refactor #ifdef of struct static_key
In reply to Masahiro YamadaQuoted 29 lines · Masahiro Yamada
Move #ifdef
CONFIG_JUMP_LABELinside the structstatic_key.Signed-off-by Masahiro Yamada <[email protected]>---
include/linux/jump_label.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)include/linux/jump_label.h +2
-2@@ -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 */
include/linux/jump_label.h struct static_key { · line 111
Quoted 10 lines
include/linux/jump_label.h +0
-5}; -#else -struct static_key { -atomic_t enabled; -}; -#endif /* CONFIG_JUMP_LABEL */ #endif /* __ASSEMBLY__ */ #ifdef CONFIG_JUMP_LABEL
These two cleanups look fine to me.
Thanks,
-Jason
Josh Poimboeuf
Acked-byRe: [PATCH 2/2] jump_label: refactor #ifdef of struct static_key
Quoted 39 lines · Jason Baron
Quoted 38 lines · Masahiro Yamada
Move #ifdef
CONFIG_JUMP_LABELinside the structstatic_key.Signed-off-by Masahiro Yamada <[email protected]>---
include/linux/jump_label.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)include/linux/jump_label.h +2
-7@@ -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__ */
Quoted 6 lines
include/linux/jump_label.h struct static_key { · line 111
Quoted 1 line
include/linux/jump_label.h +0
-0#ifdef CONFIG_JUMP_LABEL These two cleanups look fine to me.
Acked-by Jason Baron <[email protected]>>
Both look fine to me as well. For both patches:
Signature · 1 line
Josh
[tip: locking/core] jump_label: Avoid unneeded casts in STATIC_KEY_INIT_{TRUE,FALSE}
In reply to Masahiro YamadaThe following commit has been merged into the locking/core branch of tip:
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 <[email protected]> AuthorDate: Mon, 14 Feb 2022 01:57:16 +09:00 Committer: Peter Zijlstra <[email protected]> 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.
--- include/linux/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/jump_label.h +2 -2
@@ -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 */