mm: page_alloc: ignore init_on_free=1 for debug_pagealloc=1
On !ARCH_SUPPORTS_DEBUG_PAGEALLOC (like ia64) debug_pagealloc=1 implies page_poison=on: if (page_poisoning_enabled() || (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) && debug_pagealloc_enabled())) static_branch_enable(&_page_poisoning_enabled); page_poison=on needs to override init_on_free=1. Before the change it did not work as expected for the following case: - have PAGE_POISONING=y - have page_poison unset - have !ARCH_SUPPORTS_DEBUG_PAGEALLOC arch (like ia64) - have init_on_free=1 - have debug_pagealloc=1 That way we get both keys enabled: - static_branch_enable(&init_on_free); - static_branch_enable(&_page_poisoning_enabled); which leads to poisoned pages returned for __GFP_ZERO pages. After the change we execute only: - static_branch_enable(&_page_poisoning_enabled); and ignore init_on_free=1. Link: https://lkml.kernel.org/r/20210329222555.3077928-1-slyfox@gentoo.org Link: https://lkml.org/lkml/2021/3/26/443 Fixes: 8db26a3d4735 ("mm, page_poison: use static key more efficiently") Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> Reviewed-by: David Hildenbrand <david@redhat.com> Cc: Andrey Konovalov <andreyknvl@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
be5dba25b4
commit
9df65f5225
@ -786,20 +786,7 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
|
|||||||
*/
|
*/
|
||||||
void init_mem_debugging_and_hardening(void)
|
void init_mem_debugging_and_hardening(void)
|
||||||
{
|
{
|
||||||
if (_init_on_alloc_enabled_early) {
|
bool page_poisoning_requested = false;
|
||||||
if (page_poisoning_enabled())
|
|
||||||
pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
|
|
||||||
"will take precedence over init_on_alloc\n");
|
|
||||||
else
|
|
||||||
static_branch_enable(&init_on_alloc);
|
|
||||||
}
|
|
||||||
if (_init_on_free_enabled_early) {
|
|
||||||
if (page_poisoning_enabled())
|
|
||||||
pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
|
|
||||||
"will take precedence over init_on_free\n");
|
|
||||||
else
|
|
||||||
static_branch_enable(&init_on_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_PAGE_POISONING
|
#ifdef CONFIG_PAGE_POISONING
|
||||||
/*
|
/*
|
||||||
@ -808,10 +795,27 @@ void init_mem_debugging_and_hardening(void)
|
|||||||
*/
|
*/
|
||||||
if (page_poisoning_enabled() ||
|
if (page_poisoning_enabled() ||
|
||||||
(!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) &&
|
(!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) &&
|
||||||
debug_pagealloc_enabled()))
|
debug_pagealloc_enabled())) {
|
||||||
static_branch_enable(&_page_poisoning_enabled);
|
static_branch_enable(&_page_poisoning_enabled);
|
||||||
|
page_poisoning_requested = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (_init_on_alloc_enabled_early) {
|
||||||
|
if (page_poisoning_requested)
|
||||||
|
pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
|
||||||
|
"will take precedence over init_on_alloc\n");
|
||||||
|
else
|
||||||
|
static_branch_enable(&init_on_alloc);
|
||||||
|
}
|
||||||
|
if (_init_on_free_enabled_early) {
|
||||||
|
if (page_poisoning_requested)
|
||||||
|
pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
|
||||||
|
"will take precedence over init_on_free\n");
|
||||||
|
else
|
||||||
|
static_branch_enable(&init_on_free);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_PAGEALLOC
|
#ifdef CONFIG_DEBUG_PAGEALLOC
|
||||||
if (!debug_pagealloc_enabled())
|
if (!debug_pagealloc_enabled())
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user