linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Suren Baghdasaryan <surenb@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	maple-tree@lists.infradead.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	David Hildenbrand <david@redhat.com>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>, Michal Hocko <mhocko@suse.com>,
	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: [PATCH v1 8/9] mm/vma: Use unmap_desc in vms_clear_ptes() and exit_mmap()
Date: Thu, 11 Sep 2025 12:59:28 -0400	[thread overview]
Message-ID: <2slsnkd6abablb2zxvzti5w6e2sdacz2z7uzwvumodg4ccuykh@ul45isfoax3f> (raw)
In-Reply-To: <CAJuCfpFGo4JXQQGECFdCgNNVaQc5MDLghdmnVXEK8Zfag7KHiw@mail.gmail.com>

* Suren Baghdasaryan <surenb@google.com> [250909 18:16]:
> On Tue, Sep 9, 2025 at 12:10 PM Liam R. Howlett <Liam.Howlett@oracle.com> wrote:
> >
> > vms_clear_ptes() is slightly different than other callers to
> > unmap_region() and so had the unmapping open-coded.  Using the new
> > structure it is now possible to special-case the struct setup instead of
> > having the open-coded function.
> >
> > exit_mmap() also calls unmap_vmas() with many arguemnts.  Using the
> > unmap_all_init() function to set the unmap descriptor for all vmas makes
> > this a bit easier to read.
> >
> > Update to the vma test code is necessary to ensure testing continues to
> > function.
> >
> > No functional changes intended.
> >
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> > ---
> >  include/linux/mm.h               |  3 ---
> >  mm/internal.h                    |  3 +++
> >  mm/memory.c                      | 24 ++++++++------------
> >  mm/mmap.c                        |  5 +++-
> >  mm/vma.c                         | 39 ++++++++++++++++++--------------
> >  mm/vma.h                         | 14 ++++++++++++
> >  tools/testing/vma/vma_internal.h | 14 ++++--------
> >  7 files changed, 56 insertions(+), 46 deletions(-)

...

> >         struct vm_area_struct *vma;
> >         unsigned long nr_accounted = 0;
> >         VMA_ITERATOR(vmi, mm, 0);
> > +       struct unmap_desc unmap;
> >
> >         /* mm's last user has gone, and its about to be pulled down */
> >         mmu_notifier_release(mm);
> >
> > +       unmap.mm_wr_locked = false;
> 
> This will be reset by unmap_all_init() anyway, right?

Yes, I will drop that.  Thanks, I missed this when I rewrote to use a
different function.

> 
> >         mmap_read_lock(mm);
> >         arch_exit_mmap(mm);
> >
> > @@ -1295,11 +1297,12 @@ void exit_mmap(struct mm_struct *mm)
> >                 goto destroy;
> >         }
> >
> > +       unmap_all_init(&unmap, &vmi, vma);
> 
> Can we use a macro, something like DEFINE_UNMAP_ALL_REGIONS() instead
> of unmap_all_init()?

No, because the vma is unknown and we set up some of the unmap_desc from
the values in vma.

> 
> >         flush_cache_mm(mm);
> >         tlb_gather_mmu_fullmm(&tlb, mm);
> >         /* update_hiwater_rss(mm) here? but nobody should be looking */
> >         /* Use ULONG_MAX here to ensure all VMAs in the mm are unmapped */
> > -       unmap_vmas(&tlb, &vmi.mas, vma, 0, ULONG_MAX, ULONG_MAX, false);
> > +       unmap_vmas(&tlb, &unmap);
> >         mmap_read_unlock(mm);

...

Thanks,
Liam


  reply	other threads:[~2025-09-11 16:59 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09 19:09 [PATCH v1 0/9] Remove XA_ZERO from error recovery of dup_mmap() Liam R. Howlett
2025-09-09 19:09 ` [PATCH v1 1/9] mm/mmap: Move exit_mmap() trace point Liam R. Howlett
2025-09-09 20:07   ` Suren Baghdasaryan
2025-09-10 12:51   ` Pedro Falcato
2025-09-11  9:19   ` David Hildenbrand
2025-09-09 19:09 ` [PATCH v1 2/9] mm/mmap: Abstract vma clean up from exit_mmap() Liam R. Howlett
2025-09-09 20:09   ` Suren Baghdasaryan
2025-09-10 12:54   ` Pedro Falcato
2025-09-11  9:21   ` David Hildenbrand
2025-09-09 19:09 ` [PATCH v1 3/9] mm/vma: Add limits to unmap_region() for vmas Liam R. Howlett
2025-09-09 20:09   ` Suren Baghdasaryan
2025-09-10 12:56   ` Pedro Falcato
2025-09-11  8:56   ` Lorenzo Stoakes
2025-09-11  9:22   ` David Hildenbrand
2025-09-09 19:09 ` [PATCH v1 4/9] mm/memory: Add tree limit to free_pgtables() Liam R. Howlett
2025-09-09 21:05   ` Suren Baghdasaryan
2025-09-10 13:08   ` Pedro Falcato
2025-09-11  9:08   ` Lorenzo Stoakes
2025-09-11  9:24   ` David Hildenbrand
2025-09-09 19:09 ` [PATCH v1 5/9] mm/vma: Add page table limit to unmap_region() Liam R. Howlett
2025-09-09 21:29   ` Suren Baghdasaryan
2025-09-10 13:08   ` Pedro Falcato
2025-09-09 19:09 ` [PATCH v1 6/9] mm: Change dup_mmap() recovery Liam R. Howlett
2025-09-09 22:03   ` Suren Baghdasaryan
2025-09-10 13:23   ` Pedro Falcato
2025-09-11  9:13   ` Lorenzo Stoakes
2025-09-11  9:31   ` David Hildenbrand
2025-09-09 19:09 ` [PATCH v1 7/9] mm: Introduce unmap_desc struct to reduce function arguments Liam R. Howlett
2025-09-09 21:44   ` Suren Baghdasaryan
2025-09-11  9:22     ` Lorenzo Stoakes
2025-09-11 16:51       ` Suren Baghdasaryan
2025-09-11 16:56         ` Liam R. Howlett
2025-09-11 17:03           ` Suren Baghdasaryan
2025-09-10 13:10   ` Pedro Falcato
2025-09-11  9:20   ` Lorenzo Stoakes
2025-09-09 19:09 ` [PATCH v1 8/9] mm/vma: Use unmap_desc in vms_clear_ptes() and exit_mmap() Liam R. Howlett
2025-09-09 22:16   ` Suren Baghdasaryan
2025-09-11 16:59     ` Liam R. Howlett [this message]
2025-09-11  9:53   ` Lorenzo Stoakes
2025-09-12  5:08   ` kernel test robot
2025-09-09 19:09 ` [PATCH v1 9/9] mm: Use unmap_desc struct for freeing page tables Liam R. Howlett
2025-09-09 22:27   ` Suren Baghdasaryan
2025-09-11 10:06   ` 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=2slsnkd6abablb2zxvzti5w6e2sdacz2z7uzwvumodg4ccuykh@ul45isfoax3f \
    --to=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=lorenzo.stoakes@oracle.com \
    --cc=maple-tree@lists.infradead.org \
    --cc=mhocko@suse.com \
    --cc=nphamcs@gmail.com \
    --cc=pfalcato@suse.de \
    --cc=quic_charante@quicinc.com \
    --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