[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRR2AV7_R20i4qi8@localhost.localdomain>
Date: Wed, 12 Nov 2025 12:56:49 +0100
From: Oscar Salvador <osalvador@...e.de>
To: "David Hildenbrand (Red Hat)" <david@...nel.org>
Cc: Hugh Dickins <hughd@...gle.com>, Muchun Song <muchun.song@...ux.dev>,
Deepanshu Kartikey <kartikey406@...il.com>,
Vivek Kasireddy <vivek.kasireddy@...el.com>,
baolin.wang@...ux.alibaba.com, akpm@...ux-foundation.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
syzbot+f64019ba229e3a5c411b@...kaller.appspotmail.com
Subject: Re: [PATCH] mm/memfd: clear hugetlb pages on allocation
On Wed, Nov 12, 2025 at 11:09:51AM +0100, David Hildenbrand (Red Hat) wrote:
> On 12.11.25 10:13, Oscar Salvador wrote:
> > memfd_alloc_folio() seems to try to recreate what hugetlb_no_page()
> > would do (slightly different though).
>
> Can we factor that out to merge both paths?
I guess it is worth looking into it, I shall fiddle with it.
> > Regarding the uptodate question, I do not see what is special about this situation
> > that we would not need it.
> > We seem to be marking the folio uptodate every time we do allocate a folio __and__
> > before adding it into the pagecache (which is expected, right?).
>
> Right, at least filemap.c heavily depends on it being set (I don't think
> hugetlb itself needs it).
Yes, you are probably right.
> > Now, for the GFP_ZERO question.
> > This one is nasty.
> > hugetlb_reserve_pages() will allocate surplus folios without zeroing, but those
> > will be zeroed in the faulting path before mapping them into userspace pagetables
> > (see folio_zero_user() in hugetlb_no_page()).
> > So unless I am missing something we need to zero them in this case as well.
>
> I assume we want to avoid GFP_ZERO and use folio_zero_user(), which is
> optimized for zeroing huge/gigantic pages.
Yes, I would go with folio_zero_user() as well, to match what we do in
all paths.
Maybe if we can factor it out, we can simplifiy it as right now seems a
small-duplication of hugetlb_no_page (and more so once we add what is
missing: mutex, uptodate and folio_zero_user).
--
Oscar Salvador
SUSE Labs
Powered by blists - more mailing lists