Skip to content

Commit

Permalink
mm/page_poison.c: replace bool variable with static key
Browse files Browse the repository at this point in the history
Variable 'want_page_poisoning' is a switch deciding if page poisoning
should be enabled.  This patch changes it to be static key.

Signed-off-by: Mateusz Nosek <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: Oscar Salvador <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Mateusz Nosek authored and torvalds committed Oct 16, 2020
1 parent b94e028 commit 11c9c7e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions mm/page_poison.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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()));
}
Expand Down

0 comments on commit 11c9c7e

Please sign in to comment.