From: Peter Xu <peterx@redhat.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
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:20:05 -0400 [thread overview]
Message-ID: <aGVqRQKWu9IDVwk6@x1.local> (raw)
In-Reply-To: <jjwzfnbz7uzuniwd2qc6prfg4sboa7dnjswnbeotjbaqngbs6s@2y42bsqcjpv6>
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.
>
> I suspect that this wasn't meant to happen in the first place anyways,
> and I bet there are no tests for it and no real-world harm in changing
> an error scenario into a potential successful mapping.
Yes, checking stack for hugetlbfs so far just looks redundant. Maybe keep
digging the history we may found why we had it before, but so far it looks
not useful at all.
>
> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2025-07-02 17:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 16:07 [PATCH] mm/hugetlb: Remove prepare_hugepage_range() Peter Xu
2025-06-30 7:29 ` Anshuman Khandual
2025-06-30 14:26 ` Liam R. Howlett
2025-07-02 17:20 ` Peter Xu [this message]
2025-07-02 17:39 ` Liam R. Howlett
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=aGVqRQKWu9IDVwk6@x1.local \
--to=peterx@redhat.com \
--cc=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=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