From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
David Hildenbrand <david@redhat.com>,
maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
Charan Teja Kalla <quic_charante@quicinc.com>,
shikemeng@huaweicloud.com, kasong@tencent.com, nphamcs@gmail.com,
bhe@redhat.com, baohua@kernel.org, chrisl@kernel.org,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [RFC PATCH 4/6] mm/memory: Add tree limit to free_pgtables()
Date: Thu, 4 Sep 2025 16:33:53 +0100 [thread overview]
Message-ID: <a558f789-8c21-4e10-acc6-fdcea110563d@lucifer.local> (raw)
In-Reply-To: <hs5nuhqzqyt5mp3fzznuaiyyck6b6ovuxoxayvm5ofhoa5324m@gtmezuqareiq>
On Wed, Sep 03, 2025 at 04:19:04PM -0400, Liam R. Howlett wrote:
> * Lorenzo Stoakes <lorenzo.stoakes@oracle.com> [250819 15:14]:
> > On Fri, Aug 15, 2025 at 03:10:29PM -0400, Liam R. Howlett wrote:
> > > The ceiling and tree search limit need to be different arguments for the
> > > future change in the failed fork attempt.
> > >
> > > No functional changes intended.
> > >
> > > Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> >
> > (Obv. in addition to comment about broken VMA tests :P)
> >
> > I guess intent is that if we discover any page tables beyond tree_max then
> > we ought to just wipe them all out so, in effect, we don't consider
> > mappings at or past tree_max to be valid?
>
> Actually... there are some archs that map outside the vma and they are
> valid.. I think mips? and I think lower, but yeah.. it's needed. This
> is why prev->vm_end and next->vm_start are used as page table limits,
> afaik. This is a serious annoyance because it frequently adds walks
> that are infrequently necessary to the vma tree.
ugh god. I was vaguely aware of this but that's gross. Very gross.
I need to document all the VMA weirdnesses smoewhere.
What do they do this for? Guard pages or something?
>
> >
> > I feel like we need a comment to this effect as this is confusing as it is.
> >
> > Could we add a kerneldoc comment for free_pgtables() spelling this out?
>
> I'll add a note here, but confusion will probably increase. I'll add a
> note about the tree max as well.
Thanks!
>
> >
> > > ---
> > > mm/internal.h | 4 +++-
> > > mm/memory.c | 7 ++++---
> > > mm/mmap.c | 2 +-
> > > mm/vma.c | 3 ++-
> > > 4 files changed, 10 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/mm/internal.h b/mm/internal.h
> > > index 45b725c3dc030..f9a278ac76d83 100644
> > > --- a/mm/internal.h
> > > +++ b/mm/internal.h
> > > @@ -444,7 +444,9 @@ void folio_activate(struct folio *folio);
> > >
> > > void free_pgtables(struct mmu_gather *tlb, struct ma_state *mas,
> > > struct vm_area_struct *start_vma, unsigned long floor,
> > > - unsigned long ceiling, bool mm_wr_locked);
> > > + unsigned long ceiling, unsigned long tree_max,
> > > + bool mm_wr_locked);
> > > +
> > > void pmd_install(struct mm_struct *mm, pmd_t *pmd, pgtable_t *pte);
> > >
> > > struct zap_details;
> > > diff --git a/mm/memory.c b/mm/memory.c
> > > index 0ba4f6b718471..3346514562bba 100644
> > > --- a/mm/memory.c
> > > +++ b/mm/memory.c
> > > @@ -371,7 +371,8 @@ void free_pgd_range(struct mmu_gather *tlb,
> > >
> > > void free_pgtables(struct mmu_gather *tlb, struct ma_state *mas,
> > > struct vm_area_struct *vma, unsigned long floor,
> > > - unsigned long ceiling, bool mm_wr_locked)
> > > + unsigned long ceiling, unsigned long tree_max,
> > > + bool mm_wr_locked)
> > > {
> > > struct unlink_vma_file_batch vb;
> > >
> > > @@ -385,7 +386,7 @@ void free_pgtables(struct mmu_gather *tlb, struct ma_state *mas,
> > > * Note: USER_PGTABLES_CEILING may be passed as ceiling and may
> > > * be 0. This will underflow and is okay.
> > > */
> > > - next = mas_find(mas, ceiling - 1);
> > > + next = mas_find(mas, tree_max - 1);
> >
> > Do we need to put some sort of sanity checks in to make sure tree_max <= ceiling
> > (though this 0 case is a pain... so I guess tree_max - 1 <= ceiling - 1?)
>
> Sure!
Thanks!
next prev parent reply other threads:[~2025-09-04 15:34 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 19:10 [RFC PATCH 0/6] Remove XA_ZERO from error recovery of Liam R. Howlett
2025-08-15 19:10 ` [RFC PATCH 1/6] mm/mmap: Move exit_mmap() trace point Liam R. Howlett
2025-08-19 18:27 ` Lorenzo Stoakes
2025-08-21 21:12 ` Chris Li
2025-08-15 19:10 ` [RFC PATCH 2/6] mm/mmap: Abstract vma clean up from exit_mmap() Liam R. Howlett
2025-08-19 18:38 ` Lorenzo Stoakes
2025-09-03 19:56 ` Liam R. Howlett
2025-09-04 15:21 ` Lorenzo Stoakes
2025-08-15 19:10 ` [RFC PATCH 3/6] mm/vma: Add limits to unmap_region() for vmas Liam R. Howlett
2025-08-19 18:48 ` Lorenzo Stoakes
2025-09-03 19:57 ` Liam R. Howlett
2025-09-04 15:23 ` Lorenzo Stoakes
2025-08-15 19:10 ` [RFC PATCH 4/6] mm/memory: Add tree limit to free_pgtables() Liam R. Howlett
2025-08-18 15:36 ` Lorenzo Stoakes
2025-08-18 15:54 ` Liam R. Howlett
2025-08-19 19:14 ` Lorenzo Stoakes
2025-09-03 20:19 ` Liam R. Howlett
2025-09-04 10:20 ` David Hildenbrand
2025-09-04 15:36 ` Lorenzo Stoakes
2025-09-09 17:19 ` Liam R. Howlett
2025-09-04 15:33 ` Lorenzo Stoakes [this message]
2025-08-15 19:10 ` [RFC PATCH 5/6] mm/vma: Add page table limit to unmap_region() Liam R. Howlett
2025-08-19 19:27 ` Lorenzo Stoakes
2025-08-15 19:10 ` [RFC PATCH 6/6] mm: Change dup_mmap() recovery Liam R. Howlett
2025-08-18 15:12 ` Lorenzo Stoakes
2025-08-18 15:29 ` Lorenzo Stoakes
2025-08-19 20:33 ` Lorenzo Stoakes
2025-09-04 0:13 ` Liam R. Howlett
2025-09-04 15:40 ` Lorenzo Stoakes
2025-08-15 19:49 ` [RFC PATCH 0/6] Remove XA_ZERO from error recovery of Jann Horn
2025-08-18 15:48 ` Liam R. Howlett
2025-08-18 9:44 ` David Hildenbrand
2025-08-18 14:26 ` Charan Teja Kalla
2025-08-18 14:54 ` Liam R. Howlett
2025-08-18 15:47 ` Lorenzo Stoakes
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=a558f789-8c21-4e10-acc6-fdcea110563d@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=bhe@redhat.com \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=jannh@google.com \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=mhocko@suse.com \
--cc=nphamcs@gmail.com \
--cc=pfalcato@suse.de \
--cc=quic_charante@quicinc.com \
--cc=rppt@kernel.org \
--cc=shikemeng@huaweicloud.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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
all inboxes | Powered by JetHome®