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: add folio_test_lazyfree helper

Add folio_test_lazyfree() function to identify lazy-free folios to improve
code readability.

Link: https://lkml.kernel.org/r/20260221093918.1456187-4-vernon2gm@gmail.com
Signed-off-by: Vernon Yang <yanglincheng@kylinos.cn>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam Howlett <Liam.Howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Vernon Yang and committed by
Andrew Morton
6cc153f9 34c1f77e

+8 -4
+5
include/linux/page-flags.h
··· 724 724 return ((unsigned long)folio->mapping & FOLIO_MAPPING_ANON) != 0; 725 725 } 726 726 727 + static __always_inline bool folio_test_lazyfree(const struct folio *folio) 728 + { 729 + return folio_test_anon(folio) && !folio_test_swapbacked(folio); 730 + } 731 + 727 732 static __always_inline bool PageAnonNotKsm(const struct page *page) 728 733 { 729 734 unsigned long flags = (unsigned long)page_folio(page)->mapping;
+1 -1
mm/rmap.c
··· 2060 2060 } 2061 2061 2062 2062 if (!pvmw.pte) { 2063 - if (folio_test_anon(folio) && !folio_test_swapbacked(folio)) { 2063 + if (folio_test_lazyfree(folio)) { 2064 2064 if (unmap_huge_pmd_locked(vma, pvmw.address, pvmw.pmd, folio)) 2065 2065 goto walk_done; 2066 2066 /*
+2 -3
mm/vmscan.c
··· 963 963 * They could be mistakenly treated as file lru. So further anon 964 964 * test is needed. 965 965 */ 966 - if (!folio_is_file_lru(folio) || 967 - (folio_test_anon(folio) && !folio_test_swapbacked(folio))) { 966 + if (!folio_is_file_lru(folio) || folio_test_lazyfree(folio)) { 968 967 *dirty = false; 969 968 *writeback = false; 970 969 return; ··· 1507 1508 } 1508 1509 } 1509 1510 1510 - if (folio_test_anon(folio) && !folio_test_swapbacked(folio)) { 1511 + if (folio_test_lazyfree(folio)) { 1511 1512 /* follow __remove_mapping for reference */ 1512 1513 if (!folio_ref_freeze(folio, 1)) 1513 1514 goto keep_locked;