From: Wei Yang <richard.weiyang@gmail.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, mgorman@techsingularity.net,
mhocko@suse.com, osalvador@suse.de,
Wei Yang <richard.weiyang@gmail.com>
Subject: [PATCH] mm, page_alloc: clear zone_movable_pfn if the node doesn't have ZONE_MOVABLE
Date: Sun, 16 Dec 2018 20:56:24 +0800 [thread overview]
Message-ID: <20181216125624.3416-1-richard.weiyang@gmail.com> (raw)
A non-zero zone_movable_pfn indicates this node has ZONE_MOVABLE, while
current implementation doesn't comply with this rule when kernel
parameter "kernelcore=" is used.
Current implementation doesn't harm the system, since the value in
zone_movable_pfn is out of the range of current zone. While user would
see this message during bootup, even that node doesn't has ZONE_MOVABLE.
Movable zone start for each node
Node 0: 0x0000000080000000
This fix takes advantage of the highest bit of a pfn to indicate it is
used for the calculation instead of the final result. And clear those
pfn whose highest bit is set after entire calculation.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
include/linux/mm.h | 1 +
mm/page_alloc.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5411de93a363..c3d8a3346dd1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2141,6 +2141,7 @@ static inline unsigned long get_num_physpages(void)
* See mm/page_alloc.c for more information on each function exposed by
* CONFIG_HAVE_MEMBLOCK_NODE_MAP.
*/
+#define zone_movable_pfn_highestbit (1UL << (BITS_PER_LONG - 1))
extern void free_area_init_nodes(unsigned long *max_zone_pfn);
unsigned long node_map_pfn_alignment(void);
unsigned long __absent_pages_in_range(int nid, unsigned long start_pfn,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index eb4df3f63f5e..cd3a77b9cb95 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6841,6 +6841,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)
for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) {
unsigned long size_pages;
+ zone_movable_pfn[nid] &= ~zone_movable_pfn_highestbit;
start_pfn = max(start_pfn, zone_movable_pfn[nid]);
if (start_pfn >= end_pfn)
continue;
@@ -6866,6 +6867,13 @@ static void __init find_zone_movable_pfns_for_nodes(void)
* not double account here
*/
zone_movable_pfn[nid] = end_pfn;
+
+ /*
+ * Set highest bit to indicate it is
+ * used for calculation.
+ */
+ zone_movable_pfn[nid] |=
+ zone_movable_pfn_highestbit;
continue;
}
start_pfn = usable_startpfn;
@@ -6904,6 +6912,13 @@ static void __init find_zone_movable_pfns_for_nodes(void)
if (usable_nodes && required_kernelcore > usable_nodes)
goto restart;
+ /*
+ * clear zone_movable_pfn if its highest bit is set
+ */
+ for_each_node_state(nid, N_MEMORY)
+ if (zone_movable_pfn[nid] & zone_movable_pfn_highestbit)
+ zone_movable_pfn[nid] = 0;
+
out2:
/* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */
for (nid = 0; nid < MAX_NUMNODES; nid++)
--
2.15.1
next reply other threads:[~2018-12-16 12:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-16 12:56 Wei Yang [this message]
2018-12-17 10:25 ` Michal Hocko
2018-12-17 14:18 ` Wei Yang
2018-12-18 12:14 ` Michal Hocko
2018-12-18 14:39 ` Wei Yang
2018-12-18 14:47 ` Michal Hocko
2018-12-18 20:27 ` Wei Yang
2018-12-19 6:56 ` Michal Hocko
2018-12-19 12:56 ` 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=20181216125624.3416-1-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=osalvador@suse.de \
/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