Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: vmscan: simplify the folio refcount check in pageout()

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>

authored by

Baolin Wang and committed by
Andrew Morton
4f8961b2 d94d9293

+4 -12
+4 -12
mm/vmscan.c
··· 477 477 return PGSTEAL_DIRECT - PGSTEAL_KSWAPD; 478 478 } 479 479 480 - static inline int is_page_cache_freeable(struct folio *folio) 481 - { 482 - /* 483 - * A freeable page cache folio is referenced only by the caller 484 - * that isolated the folio, the page cache and optional filesystem 485 - * private data at folio->private. 486 - */ 487 - return folio_ref_count(folio) - folio_test_private(folio) == 488 - 1 + folio_nr_pages(folio); 489 - } 490 - 491 480 /* 492 481 * We detected a synchronous write error writing a folio out. Probably 493 482 * -ENOSPC. We need to propagate that into the address_space for a subsequent ··· 685 696 * block, for some throttling. This happens by accident, because 686 697 * swap_backing_dev_info is bust: it doesn't reflect the 687 698 * congestion state of the swapdevs. Easy to fix, if needed. 699 + * 700 + * A freeable shmem or swapcache folio is referenced only by the 701 + * caller that isolated the folio and the page cache. 688 702 */ 689 - if (!is_page_cache_freeable(folio) || !mapping) 703 + if (folio_ref_count(folio) != 1 + folio_nr_pages(folio) || !mapping) 690 704 return PAGE_KEEP; 691 705 if (!shmem_mapping(mapping) && !folio_test_anon(folio)) 692 706 return PAGE_ACTIVATE;