Re: [PATCH v3 5/5] mm/mglru: reschedule between memcg reclaim attempts

From: Barry Song

Date: Sun Nov 22 2026 - 21:24:43 EST


On Mon, Nov 16, 2026 at 4:14 PM Max Kellermann <max.kellermann@xxxxxxxxx> wrote:
>
> shrink_one() can return immediately for empty or protected memcgs, and
> try_to_shrink_lruvec() can break out before reaching its
> cond_resched(). A scan through many memcgs can repeatedly rotate
> entries without giving other runnable tasks a scheduling opportunity.
>
> Call cond_resched_tasks_rcu_qs() (as the existing shrink_lruvec() loop
> does) after shrink_one(), while the memcg reference still pins the
> cursor and before reacquiring the RCU read lock. Also call it between
> bins and nulls-marker retries, covering scans that skip every entry.
>
> Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
> ---

Reviewed-by: Barry Song <baohua@xxxxxxxxxx>