From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Peter Xu <peterx@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Huacai Chen <chenhuacai@kernel.org>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
loongarch@lists.linux.dev, linux-mips@vger.kernel.org,
Jason Gunthorpe <jgg@nvidia.com>,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH] mm/hugetlb: Remove prepare_hugepage_range()
Date: Wed, 2 Jul 2025 13:39:33 -0400 [thread overview]
Message-ID: <g4odcoaq4sf3iubkole75bvq5ezfg7bjvd7ritfwbekzl4sxi5@p4q7i3jfvapw> (raw)
In-Reply-To: <aGVqRQKWu9IDVwk6@x1.local>
* Peter Xu <peterx@redhat.com> [250702 13:20]:
> On Mon, Jun 30, 2025 at 10:26:13AM -0400, Liam R. Howlett wrote:
> > * Peter Xu <peterx@redhat.com> [250627 12:07]:
> > > Only mips and loongarch implemented this API, however what it does was
> > > checking against stack overflow for either len or addr. That's already
> > > done in arch's arch_get_unmapped_area*() functions, even though it may not
> > > be 100% identical checks.
> > >
> > > For example, for both of the architectures, there will be a trivial
> > > difference on how stack top was defined. The old code uses STACK_TOP which
> > > may be slightly smaller than TASK_SIZE on either of them, but the hope is
> > > that shouldn't be a problem.
> > >
> > > It means the whole API is pretty much obsolete at least now, remove it
> > > completely.
> >
> > Thanks for rewording this change, apologies for the late response on
> > your change log. I think it's fine.
>
> That's totally OK, thanks for keeping an eye.
>
> >
> > I think the only meaningful difference is that the failure would have
> > aborted entirely if stack_top - len < addr, but with this change it will
> > attempt to search in the opposite direction. Unless I missed something?
>
> IIUC the prepare_hugepage_range() API shouldn't affect the direction of VA
> allocation yet, but rather a (likely proven unnecessary by this patch) way
> to fail fast for hugetlbfs for no good reason.
>
> It is currently only invoked with MAP_FIXED, and if it returns 0 it'll
> further move on to the core VA allocator. Then the allocation can happen
> either TOP->DOWN or DOWN->TOP.
>
> So "stack_top - len < addr" check is meaningful no matter if MMF_TOPDOWN or
> not, because we want to make sure it won't overflow in any direction. It's
> just that it's already covered at least by the two archs providing this
> hugetlbfs specific hook.
What I meant was, before your change the failure would happen before the
we get to the core VA allocator, so the reverse direction would never
happen.
If this is only used with MAP_FIXED, then I don't think it matters as
many tests are skipped anyways. It might be worth mentioning that the
MAP_FIXED flag is checked in different orders based on the arch, again I
think this change resulted from forked archs cloning the code and
keeping up to date.
Thanks,
Liam
prev parent reply other threads:[~2025-07-02 17:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 16:07 Peter Xu
2025-06-30 7:29 ` Anshuman Khandual
2025-06-30 14:26 ` Liam R. Howlett
2025-07-02 17:20 ` Peter Xu
2025-07-02 17:39 ` Liam R. Howlett [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=g4odcoaq4sf3iubkole75bvq5ezfg7bjvd7ritfwbekzl4sxi5@p4q7i3jfvapw \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=chenhuacai@kernel.org \
--cc=david@redhat.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=loongarch@lists.linux.dev \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=tsbogend@alpha.franken.de \
/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