All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 "Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	 Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
	 Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	 Michal Hocko <mhocko@suse.com>, Jonathan Corbet <corbet@lwn.net>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
	 Jason Gunthorpe <jgg@ziepe.ca>,
	Leon Romanovsky <leon@kernel.org>,
	 Paul Moore <paul@paul-moore.com>,
	Stephen Smalley <stephen.smalley.work@gmail.com>,
	 Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	 Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	 Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	 Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Zi Yan <ziy@nvidia.com>,
	 Baolin Wang <baolin.wang@linux.alibaba.com>,
	Nico Pache <nico.pache@linux.dev>,
	 Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>,
	 Lance Yang <lance.yang@linux.dev>,
	Usama Arif <usama.arif@linux.dev>,
	 Kiryl Shutsemau <kas@kernel.org>,
	Doug Gilbert <dgilbert@interlog.com>,
	 "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <mkp@kernel.org>,
	 Simona Vetter <simona@ffwll.ch>, Helge Deller <deller@gmx.de>,
	Sebastian Reichel <sre@kernel.org>,
	 John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	 Masami Hiramatsu <mhiramat@kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	 Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@kernel.org>,
	 Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, Arnaldo Carvalho de Melo <acme@kernel.org>,
	 Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	 Rik van Riel <riel@surriel.com>, Harry Yoo <harry@kernel.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	 Vincent Guittot <vincent.guittot@linaro.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>, Will Deacon <will@kernel.org>,
	 "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
	Nick Piggin <npiggin@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
	 Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	 "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Jan Kara <jack@suse.cz>, Marc Zyngier <maz@kernel.org>,
	 Oliver Upton <oupton@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	 Madhavan Srinivasan <maddy@linux.ibm.com>,
	Anup Patel <anup@brainfault.org>, Paul Walmsley <pjw@kernel.org>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	 Christian Borntraeger <borntraeger@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	 Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	 Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	 Vasily Gorbik <gor@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	 Andreas Larsson <andreas@gaisler.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner <brauner@kernel.org>,
	Matthew Brost <matthew.brost@intel.com>,
	 Joshua Hahn <joshua.hahnjy@gmail.com>,
	Rakie Kim <rakie.kim@sk.com>, Byungchul Park <byungchul@sk.com>,
	 Gregory Price <gourry@gourry.net>,
	Ying Huang <ying.huang@linux.alibaba.com>,
	 Alistair Popple <apopple@nvidia.com>,
	Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
	 Kemeng Shi <shikemeng@huaweicloud.com>,
	Nhat Pham <nphamcs@gmail.com>, Baoquan He <baoquan.he@linux.dev>,
	 Youngjun Park <youngjun.park@lge.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	 Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	 Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	 Chengming Zhou <chengming.zhou@linux.dev>,
	Michal Hocko <mhocko@kernel.org>,
	 Miklos Szeredi <miklos@szeredi.hu>, Xu Xin <xu.xin@linux.dev>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-usb@vger.kernel.org,
	 linux-rdma@vger.kernel.org, selinux@vger.kernel.org,
	linux-sound@vger.kernel.org,  bpf@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-fbdev@vger.kernel.org,
	 dri-devel@lists.freedesktop.org,
	linux-trace-kernel@vger.kernel.org,
	 linux-perf-users@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linuxppc-dev@lists.ozlabs.org,  kvm@vger.kernel.org,
	kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org,
	 linux-s390@vger.kernel.org, sparclinux@vger.kernel.org,
	fuse-devel@lists.linux.dev,
	 Ihor Solodrai <ihor.solodrai@linux.dev>,
	Bert Karwatzki <spasswolf@web.de>
Subject: Re: [PATCH v5 23/38] mm/mlock: eliminate weird VMA_IO_BIT abuse and simplify
Date: Mon, 12 Oct 2026 19:38:21 +0100	[thread overview]
Message-ID: <as0osndioe9xxoG1@gremlin> (raw)
In-Reply-To: <50c967fb-b6de-4189-9430-5455c26a5385@kernel.org>

On Mon, Oct 12, 2026 at 08:23:15PM +0200, David Hildenbrand (Arm) wrote:
> On 10/9/26 20:04, Lorenzo Stoakes (ARM) wrote:
> > When performing mlock() or munlock() otherwise normal VMAs have VMA_IO_BIT
> > solely to fix a race with migration which might otherwise double-count
> > mlock VMAs.
> >
> > This is unnecessary - at the point of applying folio mlock state, whether
> > setting or clearing PG_mlocked, we know whether or not we are locking.
> >
> > Solve this in two ways - thread a boolean through the page table walk
> > indicating whether a lock or unlock is being performed, and run a locking
> > walk with VMA_LOCKONFAULT_BIT set and VMA_LOCKED_BIT cleared.
> >
> > This state never occurs otherwise, as VMA_LOCKONFAULT_BIT always implies
> > VMA_LOCKED_BIT. These are also always cleared together.
> >
> > Then, update folio_add_lru_vma() and mlock_folio() to check only for
> > VMA_LOCKED_BIT, and update try_to_unmap_one() to check for VMA_LOCKED_MASK
> > instead.
> >
> > Also remove the useless invocation of allow_mlock_munlock() which simply
> > returns true if unlocking and instead rename it to allow_mlock() and only
> > call it when locking.
> >
> > With the other mlock abuse of VMA_IO_BIT addressed, update
> > mlock_vma_folio() and folio_add_lru_vma() to simply test for
> > VMA_LOCKED_BIT.
> >
> > The munlock_vma_folio() function tests VMA_LOCKED_MASK instead, as an
> > unmap racing with the locking walk must still munlock folios the walk has
> > already counted.
> >
> > Additionally, in order to ensure a racing unmap/migration releases the
> > reference munlock_folio() took (whose put was batched), check
> > VMA_LOCKED_MASK before calling mlock_drain_local() in try_to_unmap_one()
> > and try_to_migrate_one().
> >
> > While here, also replace some deprecated VMA flag predicates.
> >
> > Reviewed-by: Zi Yan <ziy@nvidia.com>
> > Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> > ---
> >  mm/folio.c    |  2 +-
> >  mm/internal.h | 10 +++++++---
> >  mm/mlock.c    | 51 +++++++++++++++++++--------------------------------
> >  mm/rmap.c     |  8 +++++---
> >  4 files changed, 32 insertions(+), 39 deletions(-)
> >
> > diff --git a/mm/folio.c b/mm/folio.c
> > index 47a437e0f7fd..35e242b48870 100644
> > --- a/mm/folio.c
> > +++ b/mm/folio.c
> > @@ -505,7 +505,7 @@ void folio_add_lru_vma(struct folio *folio, struct vm_area_struct *vma)
> >  {
> >  	VM_BUG_ON_FOLIO(folio_test_lru(folio), folio);
> >
> > -	if (unlikely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) == VM_LOCKED))
> > +	if (vma_test(vma, VMA_LOCKED_BIT))
> >  		mlock_new_folio(folio);
> >  	else
> >  		folio_add_lru(folio);
> > diff --git a/mm/internal.h b/mm/internal.h
> > index 4ae08fedffff..ea8fa94ebe1b 100644
> > --- a/mm/internal.h
> > +++ b/mm/internal.h
> > @@ -970,8 +970,7 @@ void mlock_folio(struct folio *folio);
> >  static inline void mlock_vma_folio(struct folio *folio,
> >  				struct vm_area_struct *vma)
> >  {
> > -	/* The VM_IO check prevents migration from double-counting during mlock. */
> > -	if (unlikely((vma->vm_flags & (VM_LOCKED|VM_SPECIAL)) == VM_LOCKED))
> > +	if (vma_test(vma, VMA_LOCKED_BIT))
> >  		mlock_folio(folio);
> >  }
> >
> > @@ -988,7 +987,12 @@ static inline void munlock_vma_folio(struct folio *folio,
> >  	 * always munlock the folio and page reclaim will correct it
> >  	 * if it's wrong.
> >  	 */
> > -	if (unlikely(vma->vm_flags & VM_LOCKED))
> > +	/*
> > +	 * VMA_LOCKONFAULT_BIT alone marks an mlock walk in progress, see
> > +	 * mlock_vma_pages_range(). An unmap racing with the walk must still
> > +	 * munlock folios the walk has already counted.
> > +	 */
> > +	if (unlikely(vma_test_any_mask(vma, VMA_LOCKED_MASK)))
> >  		munlock_folio(folio);
> >  }
> >
> > diff --git a/mm/mlock.c b/mm/mlock.c
> > index 39215a3eab1f..4235a1518fc9 100644
> > --- a/mm/mlock.c
> > +++ b/mm/mlock.c
> > @@ -316,22 +316,10 @@ static inline unsigned int folio_mlock_step(struct folio *folio,
> >  	return folio_pte_batch(folio, pte, ptent, count);
> >  }
> >
> > -static inline bool allow_mlock_munlock(struct folio *folio,
> > +static inline bool allow_mlock(struct folio *folio,
> >  		struct vm_area_struct *vma, unsigned long start,
> >  		unsigned long end, unsigned int step)
> >  {
> > -	/*
> > -	 * For unlock, allow munlock large folio which is partially
> > -	 * mapped to VMA. As it's possible that large folio is
> > -	 * mlocked and VMA is split later.
> > -	 *
> > -	 * During memory pressure, such kind of large folio can
> > -	 * be split. And the pages are not in VM_LOCKed VMA
> > -	 * can be reclaimed.
> > -	 */
> > -	if (!vma_test(vma, VMA_LOCKED_BIT))
> > -		return true;
> > -
> >  	/* folio_within_range() cannot take KSM, but any small folio is OK */
> >  	if (!folio_test_large(folio))
> >  		return true;
> > @@ -352,6 +340,7 @@ static int mlock_pte_range(pmd_t *pmd, unsigned long addr,
> >
> >  {
> >  	struct vm_area_struct *vma = walk->vma;
> > +	const bool lock = walk->private;
> >  	spinlock_t *ptl;
> >  	pte_t *start_pte, *pte;
> >  	pte_t ptent;
> > @@ -368,7 +357,7 @@ static int mlock_pte_range(pmd_t *pmd, unsigned long addr,
> >  		folio = pmd_folio(*pmd);
> >  		if (folio_is_zone_device(folio))
> >  			goto out;
> > -		if (vma_test(vma, VMA_LOCKED_BIT))
> > +		if (lock)
> >  			mlock_folio(folio);
> >  		else
> >  			munlock_folio(folio);
> > @@ -390,10 +379,10 @@ static int mlock_pte_range(pmd_t *pmd, unsigned long addr,
> >  			continue;
> >
> >  		step = folio_mlock_step(folio, pte, addr, end);
> > -		if (!allow_mlock_munlock(folio, vma, start, end, step))
> > +		if (lock && !allow_mlock(folio, vma, start, end, step))
> >  			goto next_entry;
> >
> > -		if (vma_test(vma, VMA_LOCKED_BIT))
> > +		if (lock)
> >  			mlock_folio(folio);
> >  		else
> >  			munlock_folio(folio);
> > @@ -428,31 +417,29 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
> >  		.pmd_entry = mlock_pte_range,
> >  		.walk_lock = PGWALK_WRLOCK_VERIFY,
> >  	};
> > +	const bool lock = vma_flags_test(new_vma_flags, VMA_LOCKED_BIT);
> > +	vma_flags_t walk_flags = *new_vma_flags;
> >
> >  	/*
> > -	 * There is a slight chance that concurrent page migration,
> > -	 * or page reclaim finding a page of this now-VMA_LOCKED_BIT vma,
> > -	 * will call mlock_vma_folio() and raise page's mlock_count:
> > -	 * double counting, leaving the page unevictable indefinitely.
> > -	 * Communicate this danger to mlock_vma_folio() with VMA_IO_BIT,
> > -	 * which is a VMA_SPECIAL_FLAGS flag not allowed on VMA_LOCKED_BIT vmas.
> > -	 * mmap_lock is held in write mode here, so this weird
> > -	 * combination should not be visible to other mmap_lock users;
> > -	 * but WRITE_ONCE so rmap walkers must see VMA_IO_BIT if VMA_LOCKED_BIT.
> > +	 * LOCKONFAULT without LOCKED never otherwise occurs: it marks a walk in
> > +	 * progress so that rmap-side callers, which test VMA_LOCKED_BIT, do not
> > +	 * count folios, while try_to_unmap_one(), which tests VMA_LOCKED_MASK,
> > +	 * still refuses to unmap them.
> >  	 */
> > -	if (vma_flags_test(new_vma_flags, VMA_LOCKED_BIT))
> > -		vma_flags_set(new_vma_flags, VMA_IO_BIT);
> > +	if (lock) {
> > +		vma_flags_clear(&walk_flags, VMA_LOCKED_BIT);
> > +		vma_flags_set(&walk_flags, VMA_LOCKONFAULT_BIT);
> > +	}
> > +
> >  	vma_start_write(vma);
> > -	vma_flags_reset_once(vma, new_vma_flags);
> > +	vma_flags_reset_once(vma, &walk_flags);
> >
> >  	lru_add_drain();
> > -	walk_page_range_vma(vma, start, end, &mlock_walk_ops, NULL);
> > +	walk_page_range_vma(vma, start, end, &mlock_walk_ops, (void *)lock);
> >  	lru_add_drain();
> >
> > -	if (vma_flags_test(new_vma_flags, VMA_IO_BIT)) {
> > -		vma_flags_clear(new_vma_flags, VMA_IO_BIT);
> > +	if (lock)
> >  		vma_flags_reset_once(vma, new_vma_flags);
> > -	}
> >  }
> >
> >  /*
> > diff --git a/mm/rmap.c b/mm/rmap.c
> > index 5332c52909be..b4a4b3929044 100644
> > --- a/mm/rmap.c
> > +++ b/mm/rmap.c
> > @@ -2239,9 +2239,11 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
> >
> >  		/*
> >  		 * If the folio is in an mlock()d vma, we must not swap it out.
> > +		 * VMA_LOCKONFAULT_BIT alone marks an mlock walk in progress, see
> > +		 * mlock_vma_pages_range().
> >  		 */
> >  		if (!(flags & TTU_IGNORE_MLOCK) &&
> > -		    (vma->vm_flags & VM_LOCKED)) {
> > +		    vma_test_any_mask(vma, VMA_LOCKED_MASK)) {
> >  			ptes++;
> >
> >  			/*
> > @@ -2395,7 +2397,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
> >  		}
> >  finish_unmap:
> >  		folio_remove_rmap_ptes(folio, page, nr_pages, vma);
> > -		if (vma->vm_flags & VM_LOCKED)
> > +		if (vma_test_any_mask(vma, VMA_LOCKED_MASK))
> >  			mlock_drain_local();
> >  		folio_put_refs(folio, nr_pages);
> >
> > @@ -2770,7 +2772,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma,
> >  			hugetlb_remove_rmap(folio);
> >  		else
> >  			folio_remove_rmap_pte(folio, subpage, vma);
> > -		if (vma->vm_flags & VM_LOCKED)
> > +		if (vma_test_any_mask(vma, VMA_LOCKED_MASK))
> >  			mlock_drain_local();
> >  		folio_put(folio);
> >  	}
> >
>
> The mlock.c changes are a bit over my head (mostly the old VM_IO handling ...),
> but it looks good from what I can tell (hoping Hugh could review ...)

If it helps, Lance tested thoroughly and found 1 place I forgot to update, now
addressed, and Zi has carefully gone through too.

Essentially it's doing the same thing VMA_IO_BIT did only with
VMA_LOCKONFAULT_BIT, which is still pretty gross but much much less so and makes
it all make a lot more sense (esp. with the locked mask).

(VMA_LOCKONFAULT_BIT when used for lock-on-fault is only ever set with
VMA_LOCKED_BIT set too, we track the folio operation by it being set alone so it
doesn't trigger lock-on-fault behaviour).

>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>

Thanks!

>
> --
> Cheers,
>
> David

--
Cheers, Lorenzo


WARNING: multiple messages have this Message-ID (diff)
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>, Jann Horn <jannh@google.com>,
	Pedro Falcato <pfalcato@suse.de>, Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Jonathan Corbet <corbet@lwn.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Paul Moore <paul@paul-moore.com>,
	Stephen Smalley <stephen.smalley.work@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Zi Yan <ziy@nvidia.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Nico Pache <nico.pache@linux.dev>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
	Usama Arif <usama.arif@linux.dev>,
	Kiryl Shutsemau <kas@kernel.org>,
	Doug Gilbert <dgilbert@interlog.com>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <mkp@kernel.org>,
	Simona Vetter <simona@ffwll.ch>, Helge Deller <deller@gmx.de>,
	Sebastian Reichel <sre@kernel.org>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Rik van Riel <riel@surriel.com>, Harry Yoo <harry@kernel.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Will Deacon <will@kernel.org>,
	"Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
	Nick Piggin <npiggin@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
	Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Jan Kara <jack@suse.cz>, Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oupton@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Anup Patel <anup@brainfault.org>, Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Andreas Larsson <andreas@gaisler.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>,
	Matthew Brost <matthew.brost@intel.com>,
	Joshua Hahn <joshua.hahnjy@gmail.com>,
	Rakie Kim <rakie.kim@sk.com>, Byungchul Park <byungchul@sk.com>,
	Gregory Price <gourry@gourry.net>,
	Ying Huang <ying.huang@linux.alibaba.com>,
	Alistair Popple <apopple@nvidia.com>,
	Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
	Kemeng Shi <shikemeng@huaweicloud.com>,
	Nhat Pham <nphamcs@gmail.com>, Baoquan He <baoquan.he@linux.dev>,
	Youngjun Park <youngjun.park@lge.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	Chengming Zhou <chengming.zhou@linux.dev>,
	Michal Hocko <mhocko@kernel.org>,
	Miklos Szeredi <miklos@szeredi.hu>, Xu Xin <xu.xin@linux.dev>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-rdma@vger.kernel.org, selinux@vger.kernel.org,
	linux-sound@vger.kernel.org, bpf@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-fbdev@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	linux-trace-kernel@vger.kernel.org,
	linux-perf-users@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
	kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org,
	linux-s390@vger.kernel.org, sparclinux@vger.kernel.org,
	fuse-devel@lists.linux.dev,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	Bert Karwatzki <spasswolf@web.de>
Subject: Re: [PATCH v5 23/38] mm/mlock: eliminate weird VMA_IO_BIT abuse and simplify
Date: Mon, 12 Oct 2026 19:38:21 +0100	[thread overview]
Message-ID: <as0osndioe9xxoG1@gremlin> (raw)
In-Reply-To: <50c967fb-b6de-4189-9430-5455c26a5385@kernel.org>

On Mon, Oct 12, 2026 at 08:23:15PM +0200, David Hildenbrand (Arm) wrote:
> On 10/9/26 20:04, Lorenzo Stoakes (ARM) wrote:
> > When performing mlock() or munlock() otherwise normal VMAs have VMA_IO_BIT
> > solely to fix a race with migration which might otherwise double-count
> > mlock VMAs.
> >
> > This is unnecessary - at the point of applying folio mlock state, whether
> > setting or clearing PG_mlocked, we know whether or not we are locking.
> >
> > Solve this in two ways - thread a boolean through the page table walk
> > indicating whether a lock or unlock is being performed, and run a locking
> > walk with VMA_LOCKONFAULT_BIT set and VMA_LOCKED_BIT cleared.
> >
> > This state never occurs otherwise, as VMA_LOCKONFAULT_BIT always implies
> > VMA_LOCKED_BIT. These are also always cleared together.
> >
> > Then, update folio_add_lru_vma() and mlock_folio() to check only for
> > VMA_LOCKED_BIT, and update try_to_unmap_one() to check for VMA_LOCKED_MASK
> > instead.
> >
> > Also remove the useless invocation of allow_mlock_munlock() which simply
> > returns true if unlocking and instead rename it to allow_mlock() and only
> > call it when locking.
> >
> > With the other mlock abuse of VMA_IO_BIT addressed, update
> > mlock_vma_folio() and folio_add_lru_vma() to simply test for
> > VMA_LOCKED_BIT.
> >
> > The munlock_vma_folio() function tests VMA_LOCKED_MASK instead, as an
> > unmap racing with the locking walk must still munlock folios the walk has
> > already counted.
> >
> > Additionally, in order to ensure a racing unmap/migration releases the
> > reference munlock_folio() took (whose put was batched), check
> > VMA_LOCKED_MASK before calling mlock_drain_local() in try_to_unmap_one()
> > and try_to_migrate_one().
> >
> > While here, also replace some deprecated VMA flag predicates.
> >
> > Reviewed-by: Zi Yan <ziy@nvidia.com>
> > Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> > ---
> >  mm/folio.c    |  2 +-
> >  mm/internal.h | 10 +++++++---
> >  mm/mlock.c    | 51 +++++++++++++++++++--------------------------------
> >  mm/rmap.c     |  8 +++++---
> >  4 files changed, 32 insertions(+), 39 deletions(-)
> >
> > diff --git a/mm/folio.c b/mm/folio.c
> > index 47a437e0f7fd..35e242b48870 100644
> > --- a/mm/folio.c
> > +++ b/mm/folio.c
> > @@ -505,7 +505,7 @@ void folio_add_lru_vma(struct folio *folio, struct vm_area_struct *vma)
> >  {
> >  	VM_BUG_ON_FOLIO(folio_test_lru(folio), folio);
> >
> > -	if (unlikely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) == VM_LOCKED))
> > +	if (vma_test(vma, VMA_LOCKED_BIT))
> >  		mlock_new_folio(folio);
> >  	else
> >  		folio_add_lru(folio);
> > diff --git a/mm/internal.h b/mm/internal.h
> > index 4ae08fedffff..ea8fa94ebe1b 100644
> > --- a/mm/internal.h
> > +++ b/mm/internal.h
> > @@ -970,8 +970,7 @@ void mlock_folio(struct folio *folio);
> >  static inline void mlock_vma_folio(struct folio *folio,
> >  				struct vm_area_struct *vma)
> >  {
> > -	/* The VM_IO check prevents migration from double-counting during mlock. */
> > -	if (unlikely((vma->vm_flags & (VM_LOCKED|VM_SPECIAL)) == VM_LOCKED))
> > +	if (vma_test(vma, VMA_LOCKED_BIT))
> >  		mlock_folio(folio);
> >  }
> >
> > @@ -988,7 +987,12 @@ static inline void munlock_vma_folio(struct folio *folio,
> >  	 * always munlock the folio and page reclaim will correct it
> >  	 * if it's wrong.
> >  	 */
> > -	if (unlikely(vma->vm_flags & VM_LOCKED))
> > +	/*
> > +	 * VMA_LOCKONFAULT_BIT alone marks an mlock walk in progress, see
> > +	 * mlock_vma_pages_range(). An unmap racing with the walk must still
> > +	 * munlock folios the walk has already counted.
> > +	 */
> > +	if (unlikely(vma_test_any_mask(vma, VMA_LOCKED_MASK)))
> >  		munlock_folio(folio);
> >  }
> >
> > diff --git a/mm/mlock.c b/mm/mlock.c
> > index 39215a3eab1f..4235a1518fc9 100644
> > --- a/mm/mlock.c
> > +++ b/mm/mlock.c
> > @@ -316,22 +316,10 @@ static inline unsigned int folio_mlock_step(struct folio *folio,
> >  	return folio_pte_batch(folio, pte, ptent, count);
> >  }
> >
> > -static inline bool allow_mlock_munlock(struct folio *folio,
> > +static inline bool allow_mlock(struct folio *folio,
> >  		struct vm_area_struct *vma, unsigned long start,
> >  		unsigned long end, unsigned int step)
> >  {
> > -	/*
> > -	 * For unlock, allow munlock large folio which is partially
> > -	 * mapped to VMA. As it's possible that large folio is
> > -	 * mlocked and VMA is split later.
> > -	 *
> > -	 * During memory pressure, such kind of large folio can
> > -	 * be split. And the pages are not in VM_LOCKed VMA
> > -	 * can be reclaimed.
> > -	 */
> > -	if (!vma_test(vma, VMA_LOCKED_BIT))
> > -		return true;
> > -
> >  	/* folio_within_range() cannot take KSM, but any small folio is OK */
> >  	if (!folio_test_large(folio))
> >  		return true;
> > @@ -352,6 +340,7 @@ static int mlock_pte_range(pmd_t *pmd, unsigned long addr,
> >
> >  {
> >  	struct vm_area_struct *vma = walk->vma;
> > +	const bool lock = walk->private;
> >  	spinlock_t *ptl;
> >  	pte_t *start_pte, *pte;
> >  	pte_t ptent;
> > @@ -368,7 +357,7 @@ static int mlock_pte_range(pmd_t *pmd, unsigned long addr,
> >  		folio = pmd_folio(*pmd);
> >  		if (folio_is_zone_device(folio))
> >  			goto out;
> > -		if (vma_test(vma, VMA_LOCKED_BIT))
> > +		if (lock)
> >  			mlock_folio(folio);
> >  		else
> >  			munlock_folio(folio);
> > @@ -390,10 +379,10 @@ static int mlock_pte_range(pmd_t *pmd, unsigned long addr,
> >  			continue;
> >
> >  		step = folio_mlock_step(folio, pte, addr, end);
> > -		if (!allow_mlock_munlock(folio, vma, start, end, step))
> > +		if (lock && !allow_mlock(folio, vma, start, end, step))
> >  			goto next_entry;
> >
> > -		if (vma_test(vma, VMA_LOCKED_BIT))
> > +		if (lock)
> >  			mlock_folio(folio);
> >  		else
> >  			munlock_folio(folio);
> > @@ -428,31 +417,29 @@ static void mlock_vma_pages_range(struct vm_area_struct *vma,
> >  		.pmd_entry = mlock_pte_range,
> >  		.walk_lock = PGWALK_WRLOCK_VERIFY,
> >  	};
> > +	const bool lock = vma_flags_test(new_vma_flags, VMA_LOCKED_BIT);
> > +	vma_flags_t walk_flags = *new_vma_flags;
> >
> >  	/*
> > -	 * There is a slight chance that concurrent page migration,
> > -	 * or page reclaim finding a page of this now-VMA_LOCKED_BIT vma,
> > -	 * will call mlock_vma_folio() and raise page's mlock_count:
> > -	 * double counting, leaving the page unevictable indefinitely.
> > -	 * Communicate this danger to mlock_vma_folio() with VMA_IO_BIT,
> > -	 * which is a VMA_SPECIAL_FLAGS flag not allowed on VMA_LOCKED_BIT vmas.
> > -	 * mmap_lock is held in write mode here, so this weird
> > -	 * combination should not be visible to other mmap_lock users;
> > -	 * but WRITE_ONCE so rmap walkers must see VMA_IO_BIT if VMA_LOCKED_BIT.
> > +	 * LOCKONFAULT without LOCKED never otherwise occurs: it marks a walk in
> > +	 * progress so that rmap-side callers, which test VMA_LOCKED_BIT, do not
> > +	 * count folios, while try_to_unmap_one(), which tests VMA_LOCKED_MASK,
> > +	 * still refuses to unmap them.
> >  	 */
> > -	if (vma_flags_test(new_vma_flags, VMA_LOCKED_BIT))
> > -		vma_flags_set(new_vma_flags, VMA_IO_BIT);
> > +	if (lock) {
> > +		vma_flags_clear(&walk_flags, VMA_LOCKED_BIT);
> > +		vma_flags_set(&walk_flags, VMA_LOCKONFAULT_BIT);
> > +	}
> > +
> >  	vma_start_write(vma);
> > -	vma_flags_reset_once(vma, new_vma_flags);
> > +	vma_flags_reset_once(vma, &walk_flags);
> >
> >  	lru_add_drain();
> > -	walk_page_range_vma(vma, start, end, &mlock_walk_ops, NULL);
> > +	walk_page_range_vma(vma, start, end, &mlock_walk_ops, (void *)lock);
> >  	lru_add_drain();
> >
> > -	if (vma_flags_test(new_vma_flags, VMA_IO_BIT)) {
> > -		vma_flags_clear(new_vma_flags, VMA_IO_BIT);
> > +	if (lock)
> >  		vma_flags_reset_once(vma, new_vma_flags);
> > -	}
> >  }
> >
> >  /*
> > diff --git a/mm/rmap.c b/mm/rmap.c
> > index 5332c52909be..b4a4b3929044 100644
> > --- a/mm/rmap.c
> > +++ b/mm/rmap.c
> > @@ -2239,9 +2239,11 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
> >
> >  		/*
> >  		 * If the folio is in an mlock()d vma, we must not swap it out.
> > +		 * VMA_LOCKONFAULT_BIT alone marks an mlock walk in progress, see
> > +		 * mlock_vma_pages_range().
> >  		 */
> >  		if (!(flags & TTU_IGNORE_MLOCK) &&
> > -		    (vma->vm_flags & VM_LOCKED)) {
> > +		    vma_test_any_mask(vma, VMA_LOCKED_MASK)) {
> >  			ptes++;
> >
> >  			/*
> > @@ -2395,7 +2397,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
> >  		}
> >  finish_unmap:
> >  		folio_remove_rmap_ptes(folio, page, nr_pages, vma);
> > -		if (vma->vm_flags & VM_LOCKED)
> > +		if (vma_test_any_mask(vma, VMA_LOCKED_MASK))
> >  			mlock_drain_local();
> >  		folio_put_refs(folio, nr_pages);
> >
> > @@ -2770,7 +2772,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma,
> >  			hugetlb_remove_rmap(folio);
> >  		else
> >  			folio_remove_rmap_pte(folio, subpage, vma);
> > -		if (vma->vm_flags & VM_LOCKED)
> > +		if (vma_test_any_mask(vma, VMA_LOCKED_MASK))
> >  			mlock_drain_local();
> >  		folio_put(folio);
> >  	}
> >
>
> The mlock.c changes are a bit over my head (mostly the old VM_IO handling ...),
> but it looks good from what I can tell (hoping Hugh could review ...)

If it helps, Lance tested thoroughly and found 1 place I forgot to update, now
addressed, and Zi has carefully gone through too.

Essentially it's doing the same thing VMA_IO_BIT did only with
VMA_LOCKONFAULT_BIT, which is still pretty gross but much much less so and makes
it all make a lot more sense (esp. with the locked mask).

(VMA_LOCKONFAULT_BIT when used for lock-on-fault is only ever set with
VMA_LOCKED_BIT set too, we track the folio operation by it being set alone so it
doesn't trigger lock-on-fault behaviour).

>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>

Thanks!

>
> --
> Cheers,
>
> David

--
Cheers, Lorenzo

-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

  reply	other threads:[~2026-10-12 18:39 UTC|newest]

Thread overview: 201+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 18:03 [PATCH v5 00/38] mm: make VMA flag semantics explicit, eliminate VM_SPECIAL Lorenzo Stoakes (ARM)
2026-10-09 18:03 ` Lorenzo Stoakes (ARM)
2026-10-09 18:03 ` [PATCH v5 01/38] mm/vma: fix mmap_prepare file handling, remove file_doesnt_need_get Lorenzo Stoakes (ARM)
2026-10-09 18:03   ` Lorenzo Stoakes (ARM)
2026-10-09 18:24   ` sashiko-bot
2026-10-09 18:03 ` [PATCH v5 02/38] mm/vma: introduce and use vma_[flags_]can_merge() Lorenzo Stoakes (ARM)
2026-10-09 18:03   ` Lorenzo Stoakes (ARM)
2026-10-09 18:21   ` sashiko-bot
2026-10-09 18:03 ` [PATCH v5 03/38] mm: consistently validate VMA state after mmap[_prepare] hooks Lorenzo Stoakes (ARM)
2026-10-09 18:03   ` Lorenzo Stoakes (ARM)
2026-10-09 18:33   ` sashiko-bot
2026-10-09 18:03 ` [PATCH v5 04/38] mm/vma: ensure mmap_prepare doesn't set actions on a mergeable vma Lorenzo Stoakes (ARM)
2026-10-09 18:03   ` Lorenzo Stoakes (ARM)
2026-10-09 18:22   ` sashiko-bot
2026-10-09 18:03 ` [PATCH v5 05/38] mm: make map_kernel_pages_[prepare,complete] internal and unexported Lorenzo Stoakes (ARM)
2026-10-09 18:03   ` Lorenzo Stoakes (ARM)
2026-10-09 18:20   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 06/38] mm/vma: tidy up map kernel pages enum values Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:20   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 07/38] mm: add mmap action for discontiguous kernel page mapping Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:29   ` sashiko-bot
2026-10-12 15:03   ` David Hildenbrand (Arm)
2026-10-12 15:03     ` David Hildenbrand (Arm)
2026-10-12 17:46     ` Lorenzo Stoakes (ARM)
2026-10-12 17:46       ` Lorenzo Stoakes (ARM)
2026-10-12 19:02       ` David Hildenbrand (Arm)
2026-10-12 19:02         ` David Hildenbrand (Arm)
2026-10-09 18:04 ` [PATCH v5 08/38] docs: filesystems: update mmap_prepare docs for discontig kernel pgs Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:19   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 09/38] drivers/usb/mon: update to use mmap_prepare + map kernel pages Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:32   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 10/38] infiniband: update hfi1 to use remap_vmalloc_range() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:30   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 11/38] selinux: reject writable opens of policy file, drop mmap shared/write check Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:26   ` sashiko-bot
2026-10-12 15:06   ` David Hildenbrand (Arm)
2026-10-12 15:06     ` David Hildenbrand (Arm)
2026-10-09 18:04 ` [PATCH v5 12/38] ALSA: pcm: use vm_insert_page() to map PCM status page Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:38   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 13/38] bpf: arena: mark arena_map_mmap() mappings VM_MIXEDMAP Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:30   ` sashiko-bot
2026-10-12 15:08   ` David Hildenbrand (Arm)
2026-10-12 15:08     ` David Hildenbrand (Arm)
2026-10-12 15:55     ` Lorenzo Stoakes (ARM)
2026-10-12 15:55       ` Lorenzo Stoakes (ARM)
2026-10-12 18:56       ` David Hildenbrand (Arm)
2026-10-12 18:56         ` David Hildenbrand (Arm)
2026-10-12 19:11         ` Lorenzo Stoakes (ARM)
2026-10-12 19:11           ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 14/38] mm/vma: add vma[_flags]_is_mm_managed() predicates Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:26   ` sashiko-bot
2026-10-12 18:06   ` David Hildenbrand (Arm)
2026-10-12 18:06     ` David Hildenbrand (Arm)
2026-10-12 18:15     ` Lorenzo Stoakes (ARM)
2026-10-12 18:15       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 15/38] mm/vma: only allow mmap to clear VMA_MAYWRITE_BIT if not mm-managed Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:25   ` sashiko-bot
2026-10-12 18:07   ` David Hildenbrand (Arm)
2026-10-12 18:07     ` David Hildenbrand (Arm)
2026-10-09 18:04 ` [PATCH v5 16/38] mm/vma: add and use vma_[flags]_is_fixed_mapping Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:29   ` sashiko-bot
2026-10-12 18:11   ` David Hildenbrand (Arm)
2026-10-12 18:11     ` David Hildenbrand (Arm)
2026-10-09 18:04 ` [PATCH v5 17/38] scsi: sg: convert mmap hook to mmap_prepare and rework Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:44   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 18/38] fbdev: defio: assert FBINFO_VIRTFB, drop VM_IO, add VM_MIXEDMAP Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:36   ` sashiko-bot
2026-10-12 18:12   ` David Hildenbrand (Arm)
2026-10-12 18:12     ` David Hildenbrand (Arm)
2026-10-12 18:12     ` David Hildenbrand (Arm)
2026-10-09 18:04 ` [PATCH v5 19/38] HSI: cmt_speech: convert mmap hook to mmap_prepare, refactor Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:39   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 20/38] mm/gup: error out early on !VMA_MAYREAD_BIT VMAs Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:34   ` sashiko-bot
2026-10-12 18:15   ` David Hildenbrand (Arm)
2026-10-12 18:15     ` David Hildenbrand (Arm)
2026-10-09 18:04 ` [PATCH v5 21/38] uprobes: remove VM_IO, set VM_MIXEDMAP for mapped kernel pages Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:41   ` sashiko-bot
2026-10-12 18:16   ` David Hildenbrand (Arm)
2026-10-12 18:16     ` David Hildenbrand (Arm)
2026-10-12 18:20     ` Lorenzo Stoakes (ARM)
2026-10-12 18:20       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 22/38] mm/mlock: clear VMA_LOCKED_MASK over mmap callback Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:40   ` sashiko-bot
2026-10-12 18:19   ` David Hildenbrand (Arm)
2026-10-12 18:19     ` David Hildenbrand (Arm)
2026-10-12 18:23     ` Lorenzo Stoakes (ARM)
2026-10-12 18:23       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 23/38] mm/mlock: eliminate weird VMA_IO_BIT abuse and simplify Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:49   ` sashiko-bot
2026-10-12 18:23   ` David Hildenbrand (Arm)
2026-10-12 18:23     ` David Hildenbrand (Arm)
2026-10-12 18:38     ` Lorenzo Stoakes (ARM) [this message]
2026-10-12 18:38       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 24/38] mm/vma: enforce that mm-managed mappings may not set VMA_IO_BIT Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:36   ` sashiko-bot
2026-10-12 18:25   ` David Hildenbrand (Arm)
2026-10-12 18:25     ` David Hildenbrand (Arm)
2026-10-12 18:35     ` Lorenzo Stoakes (ARM)
2026-10-12 18:35       ` Lorenzo Stoakes (ARM)
2026-10-12 18:39       ` David Hildenbrand (Arm)
2026-10-12 18:39         ` David Hildenbrand (Arm)
2026-10-12 18:48         ` Lorenzo Stoakes (ARM)
2026-10-12 18:48           ` Lorenzo Stoakes (ARM)
2026-10-12 18:51           ` David Hildenbrand (Arm)
2026-10-12 18:51             ` David Hildenbrand (Arm)
2026-10-12 18:57             ` Lorenzo Stoakes (ARM)
2026-10-12 18:57               ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 25/38] mm: remove VMA_IO_BIT check in vma[_flags]_is_mm_managed() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:43   ` sashiko-bot
2026-10-12 18:31   ` David Hildenbrand (Arm)
2026-10-12 18:31     ` David Hildenbrand (Arm)
2026-10-12 18:42     ` Lorenzo Stoakes (ARM)
2026-10-12 18:42       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 26/38] mm: remove hugetlb_inline.h Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:38   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 27/38] mm: rename is_vm_hugetlb_page() to vma_is_hugetlb() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:40   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 28/38] mm: drop some redundant checks around hugetlb VMAs Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:43   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 29/38] mm/madvise: update is_valid_guard_vma() to use vma_can_merge() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:44   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 30/38] mm/vma: introduce vma[_flags]_is_mm_backed() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:48   ` sashiko-bot
2026-10-12 18:45   ` David Hildenbrand (Arm)
2026-10-12 18:45     ` David Hildenbrand (Arm)
2026-10-12 18:46     ` David Hildenbrand (Arm)
2026-10-12 18:46       ` David Hildenbrand (Arm)
2026-10-13 10:57     ` Lorenzo Stoakes (ARM)
2026-10-13 10:57       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 31/38] mm/uffd: use predicates for userfaultfd checks Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:46   ` sashiko-bot
2026-10-12 18:48   ` David Hildenbrand (Arm)
2026-10-12 18:48     ` David Hildenbrand (Arm)
2026-10-13 11:29     ` Lorenzo Stoakes (ARM)
2026-10-13 11:29       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 32/38] mm/madvise: use predicates for madvise(..., MADV_DOFORK) Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:47   ` sashiko-bot
2026-10-12 18:48   ` David Hildenbrand (Arm)
2026-10-12 18:48     ` David Hildenbrand (Arm)
2026-10-09 18:04 ` [PATCH v5 33/38] mm: eliminate VMA_SPECIAL_FLAGS usage when hugetlb explicitly tested Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:47   ` sashiko-bot
2026-10-12 18:49   ` David Hildenbrand (Arm)
2026-10-12 18:49     ` David Hildenbrand (Arm)
2026-10-13 11:43     ` Lorenzo Stoakes (ARM)
2026-10-13 11:43       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 34/38] mm: eliminate VMA_SPECIAL_FLAGS check in lru_gen_look_around() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:49   ` sashiko-bot
2026-10-12 18:50   ` David Hildenbrand (Arm)
2026-10-12 18:50     ` David Hildenbrand (Arm)
2026-10-13 11:45     ` Lorenzo Stoakes (ARM)
2026-10-13 11:45       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 35/38] mm: avoid use of VMA_SPECIAL_FLAGS in migrate_vma_setup() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:50   ` sashiko-bot
2026-10-12 18:52   ` David Hildenbrand (Arm)
2026-10-12 18:52     ` David Hildenbrand (Arm)
2026-10-13 11:46     ` Lorenzo Stoakes (ARM)
2026-10-13 11:46       ` Lorenzo Stoakes (ARM)
2026-10-09 18:04 ` [PATCH v5 36/38] mm: eliminate VM_SPECIAL, VMA_SPECIAL_FLAGS Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:48   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 37/38] fuse: dax: do not set VM_MIXEDMAP Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:56   ` sashiko-bot
2026-10-09 18:04 ` [PATCH v5 38/38] mm/huge_memory: remove vma_is_special_huge() Lorenzo Stoakes (ARM)
2026-10-09 18:04   ` Lorenzo Stoakes (ARM)
2026-10-09 18:52   ` sashiko-bot
2026-10-12 18:53   ` David Hildenbrand (Arm)
2026-10-12 18:53     ` David Hildenbrand (Arm)
2026-10-10 22:00 ` [PATCH v5 00/38] mm: make VMA flag semantics explicit, eliminate VM_SPECIAL Andrew Morton
2026-10-10 22:00   ` Andrew Morton

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=as0osndioe9xxoG1@gremlin \
    --to=ljs@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=acme@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreas@gaisler.com \
    --cc=andrii@kernel.org \
    --cc=aneesh.kumar@kernel.org \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=apopple@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=borntraeger@linux.ibm.com \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=byungchul@sk.com \
    --cc=catalin.marinas@arm.com \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=deller@gmx.de \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=dev.jain@arm.com \
    --cc=dgilbert@interlog.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eddyz87@gmail.com \
    --cc=frankja@linux.ibm.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gourry@gourry.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=harry@kernel.org \
    --cc=hca@linux.ibm.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=imbrenda@linux.ibm.com \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=juri.lelli@redhat.com \
    --cc=kas@kernel.org \
    --cc=kasong@tencent.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=lance.yang@linux.dev \
    --cc=leon@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maddy@linux.ibm.com \
    --cc=mark.rutland@arm.com \
    --cc=matthew.brost@intel.com \
    --cc=maz@kernel.org \
    --cc=memxor@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=miklos@szeredi.hu \
    --cc=mingo@redhat.com \
    --cc=mkp@kernel.org \
    --cc=mripard@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=namhyung@kernel.org \
    --cc=nico.pache@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=oleg@redhat.com \
    --cc=osalvador@suse.de \
    --cc=oupton@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul@paul-moore.com \
    --cc=perex@perex.cz \
    --cc=peterx@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pfalcato@suse.de \
    --cc=pjw@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=rakie.kim@sk.com \
    --cc=riel@surriel.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=selinux@vger.kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=simona@ffwll.ch \
    --cc=sparclinux@vger.kernel.org \
    --cc=spasswolf@web.de \
    --cc=sre@kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=surenb@google.com \
    --cc=tglx@kernel.org \
    --cc=tiwai@suse.com \
    --cc=tzimmermann@suse.de \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=weixugc@google.com \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    --cc=x86@kernel.org \
    --cc=xu.xin@linux.dev \
    --cc=ying.huang@linux.alibaba.com \
    --cc=youngjun.park@lge.com \
    --cc=yuanchu@google.com \
    --cc=ziy@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.