From: Michal Hocko <mhocko@suse.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Zhaoyang Huang <huangzhaoyang@gmail.com>,
ke.wang@unisoc.com
Subject: Re: [PATCH] mm: remove redundant clear page when CONFIG_INIT_ON_ALLOC_DEFAULT_ON configured
Date: Mon, 11 Sep 2023 15:03:12 +0200 [thread overview]
Message-ID: <ZP8QEERuihh33Oki@dhcp22.suse.cz> (raw)
In-Reply-To: <ZP8MR6N8512YDU/j@casper.infradead.org>
On Mon 11-09-23 13:47:03, Matthew Wilcox wrote:
> On Mon, Sep 11, 2023 at 02:12:25PM +0200, Michal Hocko wrote:
> > On Mon 11-09-23 18:49:06, zhaoyang.huang wrote:
> > > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > >
> > > There will be redundant clear page within vma_alloc_zeroed_movable_folio
> > > when CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on. Remove it by judging related
> > > configs.
> >
> > Thanks for spotting this. I suspect this is a fix based on a code review
> > rather than a real performance issue, right? It is always good to
> > mention that. From a very quick look it seems that many architectures
> > just definte vma_alloc_zeroed_movable_folio to use __GFP_ZERO so they
> > are not affected by this. This means that only a subset of architectures
> > are really affected. This is an important information as well.
> > Finally I think it would be more appropriate to mention that the double
> > initialization is done when init_on_alloc is enabled rather than
> > referring to the above config option which only controls whether the
> > functionality is enabled by default.
>
> This may well be an unsaafe change to make. We're not just zeroing the
> page, we're calling clear_user_highpage() which tells the architecture
> which virtual address the page will be mapped at. It could be that
> skipping the zeroing ("because the page is already zero") isn't enough;
> there will be traces of the former contents of some page in the D-cache
> for this address.
I haven't realized this difference between clear_user_highpage and
kernel_init_pages which is used by the page allocator. Thanks for
pointing this out!
>
> Or it might just be an optimisation. The description of clear_user_page()
> isn't entirely clear; the port may be relying on clear_user_page()
> to have flushed the dcache aliases.
>
> At this point, I don't think this patch is worth the risk.
Agreed! Based on that I take my ack back.
> My mind is
> changable on this, but I think we'd need buy-in from ARM, SH and Xtensa
> (who directly define clear_user_highpage()) as well as Arc, csky, ia64,
> m68k, mips, nios2, parisc, powerpc, sparc who all seem to have non-trivial
> clear_user_page() implementations.
--
Michal Hocko
SUSE Labs
prev parent reply other threads:[~2023-09-11 13:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 10:49 zhaoyang.huang
2023-09-11 12:12 ` Michal Hocko
2023-09-11 12:24 ` Michal Hocko
2023-09-11 12:47 ` Matthew Wilcox
2023-09-11 13:03 ` Michal Hocko [this message]
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=ZP8QEERuihh33Oki@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=huangzhaoyang@gmail.com \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
--cc=zhaoyang.huang@unisoc.com \
/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