The patch titled Subject: mm/page_poison.c: replace bool variable with static key has been added to the -mm tree. Its filename is mm-page_poisonc-replace-bool-variable-with-static-key.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-page_poisonc-replace-bool-variable-with-static-key.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-page_poisonc-replace-bool-variable-with-static-key.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Mateusz Nosek <mateusznosek0@xxxxxxxxx> Subject: mm/page_poison.c: replace bool variable with static key Variable 'want_page_poisoning' is a switch deciding if page poisoning should be enabled. This patch changes it to be static key. Link: https://lkml.kernel.org/r/20200921152931.938-1-mateusznosek0@xxxxxxxxx Signed-off-by: Mateusz Nosek <mateusznosek0@xxxxxxxxx> Cc: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> Cc: Oscar Salvador <OSalvador@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/page_poison.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- a/mm/page_poison.c~mm-page_poisonc-replace-bool-variable-with-static-key +++ a/mm/page_poison.c @@ -8,13 +8,23 @@ #include <linux/ratelimit.h> #include <linux/kasan.h> -static bool want_page_poisoning __read_mostly; +static DEFINE_STATIC_KEY_FALSE_RO(want_page_poisoning); static int __init early_page_poison_param(char *buf) { - if (!buf) - return -EINVAL; - return strtobool(buf, &want_page_poisoning); + int ret; + bool tmp; + + ret = strtobool(buf, &tmp); + if (ret) + return ret; + + if (tmp) + static_branch_enable(&want_page_poisoning); + else + static_branch_disable(&want_page_poisoning); + + return 0; } early_param("page_poison", early_page_poison_param); @@ -31,7 +41,7 @@ bool page_poisoning_enabled(void) * Page poisoning is debug page alloc for some arches. If * either of those options are enabled, enable poisoning. */ - return (want_page_poisoning || + return (static_branch_unlikely(&want_page_poisoning) || (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) && debug_pagealloc_enabled())); } _ Patches currently in -mm which might be from mateusznosek0@xxxxxxxxx are mm-slabc-clean-code-by-removing-redundant-if-condition.patch mm-page_allocc-clean-code-by-removing-unnecessary-initialization.patch mm-page_allocc-micro-optimization-remove-unnecessary-branch.patch mm-page_allocc-fix-early-params-garbage-value-accesses.patch mm-page_allocc-clean-code-by-merging-two-functions.patch mmzone-clean-code-by-removing-unused-macro-parameter.patch mm-compactionc-micro-optimization-remove-unnecessary-branch.patch include-linux-compactionh-clean-code-by-removing-unused-enum-value.patch mm-page_poisonc-replace-bool-variable-with-static-key.patch