From: Vlastimil Babka <vbabka@suse.cz>
To: Sergei Trofimovich <slyfox@gentoo.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH] mm: page_alloc: ignore init_on_free=1 for page alloc
Date: Fri, 26 Mar 2021 15:17:00 +0100 [thread overview]
Message-ID: <6c4a20f3-16ab-3c6c-1d6d-4708db4e9ebf@suse.cz> (raw)
In-Reply-To: <20210326112650.307890-1-slyfox@gentoo.org>
On 3/26/21 12:26 PM, Sergei Trofimovich wrote:
> init_on_free=1 does not guarantee that free pages contain only zero bytes.
>
> Some examples:
> 1. page_poison=on takes presedence over init_on_alloc=1 / ini_on_free=1
Yes, and it spits out a message that you enabled both and poisoning takes
precedence. It was that way even before my changes IIRC, but not consistent.
> 2. free_pages_prepare() always poisons pages:
>
> if (want_init_on_free())
> kernel_init_free_pages(page, 1 << order);
> kernel_poison_pages(page, 1 << order
kernel_poison_pages() includes a test if poisoning is enabled. And in that case
want_init_on_free() shouldn't be. see init_mem_debugging_and_hardening()
>
> I observed use of poisoned pages as the crash on ia64 booted with
> init_on_free=1 init_on_alloc=1 (CONFIG_PAGE_POISONING=y config).
> There pmd page contained 0xaaaaaaaa poison pages and led to early crash.
Hm but that looks lika a sign that ia64 pmd allocation should use __GFP_ZERO and
doesn't. It shouldn't rely on init_on_alloc or init_on_free being enabled.
> The change drops the assumption that init_on_free=1 guarantees free
> pages to contain zeros.
The change assumes that page_poison=on also leaves want_init_on_free() enabled,
but it doesn't.
> Alternative would be to make interaction between runtime poisoning and
> sanitizing options and build-time debug flags like CONFIG_PAGE_POISONING
> more coherent. I took the simpler path.
So that was done in 5.11 and the decisions can be seen in
init_mem_debugging_and_hardening(). There might be of course a bug, or later
changes broke something. Which was the version that you observed a bug?
> Tested the fix on rx3600.
>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: linux-mm@kvack.org
> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
> ---
> mm/page_alloc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index cfc72873961d..d57d9b4f7089 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2301,7 +2301,7 @@ inline void post_alloc_hook(struct page *page, unsigned int order,
> kernel_unpoison_pages(page, 1 << order);
> set_page_owner(page, order, gfp_flags);
>
> - if (!want_init_on_free() && want_init_on_alloc(gfp_flags))
> + if (want_init_on_alloc(gfp_flags))
> kernel_init_free_pages(page, 1 << order);
> }
>
>
next prev parent reply other threads:[~2021-03-26 14:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-26 11:26 [PATCH] mm: page_alloc: ignore init_on_free=1 for page alloc Sergei Trofimovich
2021-03-26 13:48 ` David Hildenbrand
2021-03-26 15:00 ` Andrey Konovalov
2021-03-26 16:42 ` Sergei Trofimovich
2021-03-29 12:10 ` Vlastimil Babka
2021-03-29 22:00 ` Andrey Konovalov
2021-03-29 22:07 ` Vlastimil Babka
2021-03-30 14:48 ` Andrey Konovalov
2021-03-26 14:17 ` Vlastimil Babka [this message]
2021-03-26 17:25 ` Sergei Trofimovich
2021-03-27 18:03 ` Sergei Trofimovich
2021-03-27 18:21 ` [PATCH v2] mm: page_alloc: ignore init_on_free=1 for debug_pagealloc=1 Sergei Trofimovich
2021-03-29 9:23 ` David Hildenbrand
2021-03-29 11:59 ` Vlastimil Babka
2021-03-29 22:25 ` [PATCH v3] " Sergei Trofimovich
2021-03-30 8:39 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6c4a20f3-16ab-3c6c-1d6d-4708db4e9ebf@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=slyfox@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).