mm: mincore: refactor mincore_page()

Use early returns to reduce indentation and improve readability.

Link: https://lore.kernel.org/[email protected]
Signed-off-by: Kefeng Wang <[email protected]>
Acked-by: David Hildenbrand (Arm) <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Liam R. Howlett <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Pedro Falcato <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zi Yan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
Kefeng Wang authored and Andrew Morton committed 2026-08-06 18:57:15 -07:00
1 parent 751a1f061a
commit 557f842e25
1 file changed
+10 -11
+10 -11
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;
}