diff options
| author | Kees Cook <keescook@chromium.org> | 2021-04-01 16:23:43 -0700 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2021-04-08 14:05:19 +0200 |
| commit | 51cba1ebc60df9c4ce034a9f5441169c0d0956c0 (patch) | |
| tree | 9f3f79596f1922730ac3d2a90a47ad493484c75d /include/linux | |
| parent | 0d66ccc1627013c95f1e7ef10b95b8451cd7834e (diff) | |
| download | cachepc-linux-51cba1ebc60df9c4ce034a9f5441169c0d0956c0.tar.gz cachepc-linux-51cba1ebc60df9c4ce034a9f5441169c0d0956c0.zip | |
init_on_alloc: Optimize static branches
The state of CONFIG_INIT_ON_ALLOC_DEFAULT_ON (and ...ON_FREE...) did not
change the assembly ordering of the static branches: they were always out
of line. Use the new jump_label macros to check the CONFIG settings to
default to the "expected" state, which slightly optimizes the resulting
assembly code.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexander Potapenko <glider@google.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Link: https://lore.kernel.org/r/20210401232347.2791257-3-keescook@chromium.org
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/mm.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 8ba434287387..616dcaf08d99 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2904,18 +2904,20 @@ static inline void kernel_poison_pages(struct page *page, int numpages) { } static inline void kernel_unpoison_pages(struct page *page, int numpages) { } #endif -DECLARE_STATIC_KEY_FALSE(init_on_alloc); +DECLARE_STATIC_KEY_MAYBE(CONFIG_INIT_ON_ALLOC_DEFAULT_ON, init_on_alloc); static inline bool want_init_on_alloc(gfp_t flags) { - if (static_branch_unlikely(&init_on_alloc)) + if (static_branch_maybe(CONFIG_INIT_ON_ALLOC_DEFAULT_ON, + &init_on_alloc)) return true; return flags & __GFP_ZERO; } -DECLARE_STATIC_KEY_FALSE(init_on_free); +DECLARE_STATIC_KEY_MAYBE(CONFIG_INIT_ON_FREE_DEFAULT_ON, init_on_free); static inline bool want_init_on_free(void) { - return static_branch_unlikely(&init_on_free); + return static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON, + &init_on_free); } extern bool _debug_pagealloc_enabled_early; |
