diff options
| author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2026-07-17 17:13:47 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-07-27 18:33:27 -0700 |
| commit | 4ead2d16530d71d8d161c51f1f97f1b3d0f0e1cb (patch) | |
| tree | 0ed8121c6c502f52ac4b333e3d89b6a80b6c5202 /mm | |
| parent | c634266e233f3a38f86e3a88d699cc59dafaa1b7 (diff) | |
| download | linux-next-4ead2d16530d71d8d161c51f1f97f1b3d0f0e1cb.tar.gz linux-next-4ead2d16530d71d8d161c51f1f97f1b3d0f0e1cb.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>
Diffstat (limited to 'mm')
| -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; } |
