Re: [PATCH v3] mm/mglru: use a smaller batch in fill/drain_evictable()
From: Baolin Wang
Date: Mon Nov 16 2026 - 02:29:41 EST
On 11/16/26 2:11 PM, Hui Zhu wrote:
From: Hui Zhu <zhuhui@xxxxxxxxxx>
lru_gen_change_state() migrates folios in batches of up to
MAX_LRU_BATCH (4096) folios under lruvec_lock_irq(). A full batch
keeps local interrupts off for up to about a millisecond, and CPUs
contending for the same lru_lock spin with interrupts disabled for
that long.
The caller already drops the lock and reschedules between batches,
and the restart protocol does not depend on the batch size: both
functions make monotone progress, so a smaller batch only shortens
the irq-off section. Use MIN_LRU_BATCH (64) instead, bounding it to
about 15us. This is a cold path that runs once per kill-switch
toggle; the extra unlock/resched/relock round trips cost a few
percent of wall time on an otherwise idle machine.
Same change as commit 6e9be217a3ce ("mm/mglru: use a smaller batch
for reclaim") made for try_to_shrink_lruvec().
Signed-off-by: Hui Zhu <zhuhui@xxxxxxxxxx>
---
I'm fine if the small change can fix your issue in this cold path. Let's also see others' input. Feel free to add:
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>