]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: vmscan: simplify the folio refcount check in pageout()
authorBaolin Wang <baolin.wang@linux.alibaba.com>
Thu, 18 Sep 2025 03:46:54 +0000 (11:46 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 15 Oct 2025 04:28:22 +0000 (21:28 -0700)
Since we no longer attempt to write back filesystem folios in pageout()
(they will be filtered out by the following check in pageout()), and only
tmpfs/shmem folios and anonymous swapcache folios can be written back, we
can remove the redundant folio_test_private() when checking the folio's
refcount, as tmpfs/shmem and swapcache folios do not use the PG_private
flag.

While we're at it, we can open-code the folio refcount check instead of
adding a simple helper that has only one user.

Link: https://lkml.kernel.org/r/4cbbec5bb92397aa4597105f1f499aabf7a1901c.1758166683.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmscan.c

index 75225a54d5b159971d32e2ade838428a9032eff1..4907e255857a6cb02c9996051c2cdb9d7809dd0b 100644 (file)
@@ -477,17 +477,6 @@ static int reclaimer_offset(struct scan_control *sc)
        return PGSTEAL_DIRECT - PGSTEAL_KSWAPD;
 }
 
-static inline int is_page_cache_freeable(struct folio *folio)
-{
-       /*
-        * A freeable page cache folio is referenced only by the caller
-        * that isolated the folio, the page cache and optional filesystem
-        * private data at folio->private.
-        */
-       return folio_ref_count(folio) - folio_test_private(folio) ==
-               1 + folio_nr_pages(folio);
-}
-
 /*
  * We detected a synchronous write error writing a folio out.  Probably
  * -ENOSPC.  We need to propagate that into the address_space for a subsequent
@@ -696,8 +685,11 @@ static pageout_t pageout(struct folio *folio, struct address_space *mapping,
         * block, for some throttling. This happens by accident, because
         * swap_backing_dev_info is bust: it doesn't reflect the
         * congestion state of the swapdevs.  Easy to fix, if needed.
+        *
+        * A freeable shmem or swapcache folio is referenced only by the
+        * caller that isolated the folio and the page cache.
         */
-       if (!is_page_cache_freeable(folio))
+       if (folio_ref_count(folio) != 1 + folio_nr_pages(folio))
                return PAGE_KEEP;
        if (!mapping) {
                /*