Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-mm@kvack.org>, David Hildenbrand <david@kernel.org>,
	"Liam R . Howlett" <liam@infradead.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>, Jann Horn <jannh@google.com>,
	Pedro Falcato <pfalcato@suse.de>, Zi Yan <ziy@nvidia.com>,
	Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [PATCH v2 5/5] mm: mincore: refactor mincore_page()
Date: Fri, 10 Jul 2026 20:00:51 +0800	[thread overview]
Message-ID: <20260710120052.103886-6-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20260710120052.103886-1-wangkefeng.wang@huawei.com>

Use early returns to reduce indentation and improve readability.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/mincore.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/mm/mincore.c b/mm/mincore.c
index 9952bc3edf76..30a3317082d1 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -94,7 +94,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;
 
 	/*
@@ -104,17 +104,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;
 }
-- 
2.55.0



  parent reply	other threads:[~2026-07-10 12:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 12:00 [PATCH v2 0/5] mm: mincore: misc cleanups Kefeng Wang
2026-07-10 12:00 ` [PATCH v2 1/5] mm: mincore: remove special handling for VM_PFNMAP Kefeng Wang
2026-07-10 12:07   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 2/5] mm: mincore: replace __get_free_page() with kmalloc() Kefeng Wang
2026-07-10 12:09   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 3/5] mm: mincore: remove xa_is_value() in mincore_swap() Kefeng Wang
2026-07-10 12:09   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` [PATCH v2 4/5] mm: mincore: improve mincore_hugetlb() Kefeng Wang
2026-07-10 12:17   ` David Hildenbrand (Arm)
2026-07-10 12:00 ` Kefeng Wang [this message]
2026-07-10 12:19   ` [PATCH v2 5/5] mm: mincore: refactor mincore_page() David Hildenbrand (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260710120052.103886-6-wangkefeng.wang@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=jannh@google.com \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=pfalcato@suse.de \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox