All of lore.kernel.org
 help / color / mirror / Atom feed
From: qiwuchen55@gmail.com
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, chenqiwu <chenqiwu@xiaomi.com>
Subject: [PATCH] mm/sparse: remove duplicated pfn_to_section_nr()
Date: Mon, 16 Mar 2020 15:48:20 +0800	[thread overview]
Message-ID: <1584344900-16593-1-git-send-email-qiwuchen55@gmail.com> (raw)

From: chenqiwu <chenqiwu@xiaomi.com>

Remove duplicated pfn_to_section_nr() in pfn_valid() and pfn_present()
to increase executing efficiency of code.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 include/linux/mmzone.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 462f687..c2b7868 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1358,10 +1358,11 @@ static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
 static inline int pfn_valid(unsigned long pfn)
 {
 	struct mem_section *ms;
+	unsigned long sec_nr = pfn_to_section_nr(pfn);
 
-	if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
+	if (pfn >= NR_MEM_SECTIONS)
 		return 0;
-	ms = __nr_to_section(pfn_to_section_nr(pfn));
+	ms = __nr_to_section(sec_nr);
 	if (!valid_section(ms))
 		return 0;
 	/*
@@ -1374,9 +1375,11 @@ static inline int pfn_valid(unsigned long pfn)
 
 static inline int pfn_present(unsigned long pfn)
 {
-	if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
+	unsigned long sec_nr = pfn_to_section_nr(pfn);
+
+	if (sec_nr >= NR_MEM_SECTIONS)
 		return 0;
-	return present_section(__nr_to_section(pfn_to_section_nr(pfn)));
+	return present_section(__nr_to_section(sec_nr));
 }
 
 static inline unsigned long next_present_section_nr(unsigned long section_nr)
-- 
1.9.1



                 reply	other threads:[~2020-03-16  7:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1584344900-16593-1-git-send-email-qiwuchen55@gmail.com \
    --to=qiwuchen55@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenqiwu@xiaomi.com \
    --cc=linux-mm@kvack.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.