Re: [PATCH v2] mm: skip folio_activate() for mlocked folios

From: Dmitry Ilvokhin

Date: Wed Oct 15 2025 - 16:09:04 EST


On Wed, Oct 15, 2025 at 12:59:11PM -0700, Andrew Morton wrote:
> On Wed, 8 Oct 2025 18:06:07 +0000 Dmitry Ilvokhin <d@xxxxxxxxxxxx> wrote:
>
> > > > + * They might be still in mlock_fbatch waiting to be processed
> > > > + * and activating it here might interfere with
> > > > + * mlock_folio_batch(). __mlock_folio() will fail
> > > > + * folio_test_clear_lru() check and give up. It happens because
> > > > + * __folio_batch_add_and_move() clears LRU flag, when adding
> > > > + * folio to activate batch.
> > > > + */
> > >
> > > This makes sense as activating an mlocked folio should be a noop but I
> > > am wondering why we are seeing this now. By this, I mean mlock()ed
> > > memory being delayed to get to unevictable LRU. Also I remember Hugh
> > > recently [1] removed the difference betwen mlock percpu cache and other
> > > percpu caches of clearing LRU bit on entry. Does you repro work even
> > > with Hugh's changes or without it?
> > >
> >
> > Thanks Shakeel for mentioning Hugh's patch, I was not aware of it.
> > Indeed, I could not reproduce problem on top of Hugh's patch anymore,
> > which totally make sense, because folio_test_clear_lru() is gone from
> > __folio_batch_add_and_move().
> >
> > Now I wonder does folio_test_mlocked() check still make sense in the
> > current codebase?
> >
> > > [1] https://lore.kernel.org/all/05905d7b-ed14-68b1-79d8-bdec30367eba@xxxxxxxxxx/
>
> So I take it that this patch ("mm: skip folio_activate() for mlocked
> folios") is no longer needed?

Yes, this is my understanding as well. Hugh's patch addressed initial
problem and this patch is no longer needed.