diff options
| author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2026-07-17 17:13:47 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-08-06 18:57:15 -0700 |
| commit | 557f842e25a9be7fc088818c308f5463c273a2bf (patch) | |
| tree | 86674265f11fef343e6bbc9d551ee605e6ea3593 | |
| parent | 751a1f061a7c412bf44e81782607b16866f4a6d6 (diff) | |
| download | linux-557f842e25a9be7fc088818c308f5463c273a2bf.tar.gz linux-557f842e25a9be7fc088818c308f5463c273a2bf.zip | |
mm: mincore: refactor mincore_page()
Use early returns to reduce indentation and improve readability.
Link: https://lore.kernel.org/20260717091347.1144789-7-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
| -rw-r--r-- | mm/mincore.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/mm/mincore.c b/mm/mincore.c index 40cffbc6f6fc..ff4ac8281768 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -93,7 +93,7 @@ static unsigned char mincore_swap(swp_entry_t entry, bool shmem) */ static unsigned char mincore_page(struct address_space *mapping, pgoff_t index) { - unsigned char present = 0; + unsigned char present; struct folio *folio; /* @@ -103,17 +103,16 @@ static unsigned char mincore_page(struct address_space *mapping, pgoff_t index) * tmpfs's .fault). So swapped out tmpfs mappings are tested here. */ folio = filemap_get_entry(mapping, index); - if (folio) { - if (xa_is_value(folio)) { - if (shmem_mapping(mapping)) - return mincore_swap(radix_to_swp_entry(folio), - true); - else - return 0; - } - present = folio_test_uptodate(folio); - folio_put(folio); + if (!folio) + return 0; + + if (xa_is_value(folio)) { + if (!shmem_mapping(mapping)) + return 0; + return mincore_swap(radix_to_swp_entry(folio), true); } + present = folio_test_uptodate(folio); + folio_put(folio); return present; } |
