Re: [PATCH v3 1/4] mm: avoid unnecessary lru drain for wp_can_reuse_anon_folio()
From: Barry Song
Date: Mon Jul 06 2026 - 04:34:54 EST
On Thu, Jul 2, 2026 at 4:05 PM David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> On 7/2/26 01:59, Barry Song (Xiaomi) wrote:
> > There is a case where `folio_ref_count(folio) == 3` and
> > `!folio_test_swapcache(folio)`. In that case, both
> > `folio_ref_count(folio) > 3` and
> > `folio_ref_count(folio) > 1 + folio_test_swapcache(folio)` evaluate
> > false, causing an unnecessary local LRU drain.
> >
> > During an Ubuntu boot, I observed over 5,000 redundant local LRU
> > drains. For a kernel build with a minimal configuration, I observed
> > more than 20,000 redundant drains.
> >
> > Fix this by checking against: `1 + in_swapcache + in_lrucache`
> > instead of hardcoding `folio_ref_count(folio) > 3`.
> >
> > Suggested-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> > Reviewed-by: Kairui Song <kasong@xxxxxxxxxxx>
> > Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> > Reviewed-by: Baoquan He <baoquan.he@xxxxxxxxx>
> > Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
> > ---
> The other folks should probably re-review this patch that changed quite a bit :)
>
>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Thanks!
Hi Baoquan, Shakeel, and Kairui,
Would you like to re-review the patches so I can re-collect your
tags? If not, are you okay with me removing your tags when I
send v4?
The concept hasn't changed since v2, but the code readability has
improved quite a bit based on David's suggestions.
Best Regards
Barry