From: Oscar Salvador <osalvador@suse.de>
To: "David Hildenbrand (Red Hat)" <david@kernel.org>
Cc: Hugh Dickins <hughd@google.com>,
Muchun Song <muchun.song@linux.dev>,
Deepanshu Kartikey <kartikey406@gmail.com>,
Vivek Kasireddy <vivek.kasireddy@intel.com>,
baolin.wang@linux.alibaba.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
syzbot+f64019ba229e3a5c411b@syzkaller.appspotmail.com
Subject: Re: [PATCH] mm/memfd: clear hugetlb pages on allocation
Date: Wed, 12 Nov 2025 12:56:49 +0100 [thread overview]
Message-ID: <aRR2AV7_R20i4qi8@localhost.localdomain> (raw)
In-Reply-To: <6a63dbb8-58f7-4511-8090-18a58c3206d8@kernel.org>
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
next prev parent reply other threads:[~2025-11-12 11:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 3:16 Deepanshu Kartikey
2025-11-12 6:55 ` Hugh Dickins
2025-11-12 7:28 ` Deepanshu Kartikey
2025-11-12 7:55 ` Hugh Dickins
2025-11-12 9:13 ` Oscar Salvador
2025-11-12 9:26 ` Deepanshu Kartikey
2025-11-12 10:09 ` David Hildenbrand (Red Hat)
2025-11-12 11:56 ` Oscar Salvador [this message]
2025-11-12 12:06 ` Deepanshu Kartikey
2025-11-12 14:54 ` Deepanshu Kartikey
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=aRR2AV7_R20i4qi8@localhost.localdomain \
--to=osalvador@suse.de \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=hughd@google.com \
--cc=kartikey406@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=syzbot+f64019ba229e3a5c411b@syzkaller.appspotmail.com \
--cc=vivek.kasireddy@intel.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