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>
This commit is contained in:
Kefeng Wang
2026-07-17 17:13:47 +08:00
committed by Andrew Morton
parent 751a1f061a
commit 557f842e25

View File

@@ -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;
}