linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: akpm@linux-foundation.org, mhocko@suse.com, rientjes@google.com
Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com,
	bob.picco@hp.com, Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH 3/3] mm/sparse: use __highest_present_section_nr as the boundary for pfn check
Date: Thu, 23 Aug 2018 21:07:32 +0800	[thread overview]
Message-ID: <20180823130732.9489-4-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20180823130732.9489-1-richard.weiyang@gmail.com>

And it is known, __highest_present_section_nr is a more strict boundary
than NR_MEM_SECTIONS.

This patch uses a __highest_present_section_nr to check a valid pfn.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 include/linux/mmzone.h | 4 ++--
 mm/sparse.c            | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 33086f86d1a7..5138efde11ae 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1237,7 +1237,7 @@ extern int __highest_present_section_nr;
 #ifndef CONFIG_HAVE_ARCH_PFN_VALID
 static inline int pfn_valid(unsigned long pfn)
 {
-	if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
+	if (pfn_to_section_nr(pfn) > __highest_present_section_nr)
 		return 0;
 	return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));
 }
@@ -1245,7 +1245,7 @@ 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)
+	if (pfn_to_section_nr(pfn) > __highest_present_section_nr)
 		return 0;
 	return present_section(__nr_to_section(pfn_to_section_nr(pfn)));
 }
diff --git a/mm/sparse.c b/mm/sparse.c
index 90bab7f03757..a9c55c8da11f 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -174,6 +174,7 @@ void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn,
  * those loops early.
  */
 int __highest_present_section_nr;
+EXPORT_SYMBOL(__highest_present_section_nr);
 static void section_mark_present(struct mem_section *ms)
 {
 	int section_nr = __section_nr(ms);
-- 
2.15.1

  parent reply	other threads:[~2018-08-23 13:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23 13:07 [PATCH 0/3] trivial code refine for sparsemem Wei Yang
2018-08-23 13:07 ` [PATCH 1/3] mm/sparse: add likely to mem_section[root] check in sparse_index_init() Wei Yang
2018-08-23 13:13   ` Michal Hocko
2018-08-23 22:57     ` Wei Yang
2018-08-24  7:31       ` Michal Hocko
2018-08-24  0:11   ` Dave Hansen
2018-08-24 15:07     ` Wei Yang
2018-09-03 22:27       ` Wei Yang
2018-09-09  1:38         ` Wei Yang
2018-09-10 20:30           ` Dave Hansen
2018-09-11 15:00             ` Wei Yang
2018-08-23 13:07 ` [PATCH 2/3] mm/sparse: expand the CONFIG_SPARSEMEM_EXTREME range in __nr_to_section() Wei Yang
2018-08-23 13:21   ` Michal Hocko
2018-08-23 23:03     ` Wei Yang
2018-08-24  0:09     ` Dave Hansen
2018-08-24 15:24       ` Wei Yang
2018-08-23 13:07 ` Wei Yang [this message]
2018-08-23 13:25   ` [PATCH 3/3] mm/sparse: use __highest_present_section_nr as the boundary for pfn check Michal Hocko
2018-08-23 14:00     ` Oscar Salvador
2018-08-23 19:17       ` Michal Hocko
2018-08-23 20:52         ` Oscar Salvador
2018-08-24  0:15   ` Dave Hansen
2018-08-24 18:11     ` Wei Yang

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=20180823130732.9489-4-richard.weiyang@gmail.com \
    --to=richard.weiyang@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bob.picco@hp.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.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;
as well as URLs for NNTP newsgroup(s).