Re: [PATCH v2 2/4] mm: drop stale folio_ref_count()==1 check in do_swap_page reuse logic
From: David Hildenbrand (Arm)
Date: Wed Jun 24 2026 - 11:19:21 EST
On 6/24/26 01:16, Barry Song (Xiaomi) wrote:
> The "we just allocated them without exposing them to the swapcache"
> case no longer exists, as Kairui has routed synchronous I/O through
> the swapcache as well in his series "unify swapin use swap cache and
> cleanup flags"[1]. As a result, folio_ref_count() should never be 1
> in this path, since at least two references are held (base ref plus
> swapcache). Remove the folio_ref_count()==1 check and update the
> comment accordingly.
>
> [1] https://lore.kernel.org/all/20251220-swap-table-p2-v5-0-8862a265a033@xxxxxxxxxxx/
>
> Acked-by: Usama Arif <usama.arif@xxxxxxxxx>
> Reviewed-by: Kairui Song <kasong@xxxxxxxxxxx>
> Reviewed-by: Baoquan He <baoquan.he@xxxxxxxxx>
> Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
> ---
> mm/memory.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index f6848f4234a6..abd0adcf65f0 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -5049,12 +5049,9 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
>
> /*
> * Same logic as in do_wp_page(); however, optimize for pages that are
s/Same/Similar/ ?
> - * certainly not shared either because we just allocated them without
> - * exposing them to the swapcache or because the swap entry indicates
> - * exclusivity.
> + * certainly not because the swap entry indicates exclusivity.
> */
> - if (!folio_test_ksm(folio) &&
> - (exclusive || folio_ref_count(folio) == 1)) {
> + if (!folio_test_ksm(folio) && exclusive) {
Hmm, but KSM folios should never have "exclusive" set. So I think you can drop
that as well (was only relevant with folio_ref_count==1 check IIRC).
--
Cheers,
David