Re: [PATCH v2 08/26] mm/fbatch: replace mlock_new_folio() by __folio_add_lru(,mlockit)
From: Vlastimil Babka (SUSE)
Date: Thu Sep 10 2026 - 13:55:01 EST
On 9/9/26 11:57, Hugh Dickins wrote:
> Replace mlock_new_folio(), working on mm/mlock.c's mlock_fbatch, by
> __folio_add_lru(,mlockit), working on mm/folio.c's lru_add fbatch:
> folio moved to lruvec by lru_add(), with its mlocking incidental.
>
> Remove old comment about not needing smp_mb__after_atomic() from
> lru_add(): but that is a detail which will need to be reconsidered.
>
> Initialize mlock_count earlier, when adding to fbatch rather than when
> adding to lruvec. mlock_count count in 2s, with the low bit set to
> distinguish it from lru.prev. This helps when an mlocked folio is put
> back early by compaction, but will enable further optimization next.
>
> Change mlock_count from unsigned int to long: long to match pointer
> without endian concerns, signed for better treatment of those rare
> cases when final munlocks precede their still batched mlocks.
>
> This is an intermediate, poorly tested review stage: mlock_new_folio()
> code removed from mm/mlock.c, remaining code there updated to respect
> the new mlock_count accounting, but not considered beyond that.
>
> Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>