From: Huaisheng HS1 Ye <yehs1@lenovo.com>
To: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: "mhocko@suse.com" <mhocko@suse.com>,
"willy@infradead.org" <willy@infradead.org>,
"vbabka@suse.cz" <vbabka@suse.cz>,
"mgorman@techsingularity.net" <mgorman@techsingularity.net>,
"pasha.tatashin@oracle.com" <pasha.tatashin@oracle.com>,
"alexander.levin@verizon.com" <alexander.levin@verizon.com>,
"hannes@cmpxchg.org" <hannes@cmpxchg.org>,
"penguin-kernel@I-love.SAKURA.ne.jp"
<penguin-kernel@I-love.SAKURA.ne.jp>,
"colyli@suse.de" <colyli@suse.de>,
NingTing Cheng <chengnt@lenovo.com>,
Ocean HY1 He <hehy1@lenovo.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: [External] [RFC PATCH v1 5/6] mm: get zone spanned pages separately for DRAM and NVDIMM
Date: Tue, 8 May 2018 02:34:17 +0000 [thread overview]
Message-ID: <HK2PR03MB16843F0A91E190ECDBB28F2F929A0@HK2PR03MB1684.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <1525746628-114136-6-git-send-email-yehs1@lenovo.com>
DRAM and NVDIMM are divided into separate zones, thus NVM
zone is dedicated for NVDIMMs.
During zone_spanned_pages_in_node, spanned pages of zones
are calculated separately for DRAM and NVDIMM by flags
MEMBLOCK_NONE and MEMBLOCK_NVDIMM.
Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
Signed-off-by: Ocean He <hehy1@lenovo.com>
---
mm/nobootmem.c | 5 +++--
mm/page_alloc.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 9b02fda..19b5291 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -143,8 +143,9 @@ static unsigned long __init free_low_memory_core_early(void)
* because in some case like Node0 doesn't have RAM installed
* low ram will be on Node1
*/
- for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end,
- NULL)
+ for_each_free_mem_range(i, NUMA_NO_NODE,
+ MEMBLOCK_NONE | MEMBLOCK_NVDIMM,
+ &start, &end, NULL)
count += __free_memory_core(start, end);
return count;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d8bd20d..3fd0d95 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4221,6 +4221,11 @@ static inline void finalise_ac(gfp_t gfp_mask,
* also used as the starting point for the zonelist iterator. It
* may get reset for allocations that ignore memory policies.
*/
+#ifdef CONFIG_ZONE_NVM
+ /* Bypass ZONE_NVM for Normal alloctions */
+ if (ac->high_zoneidx > ZONE_NVM)
+ ac->high_zoneidx = ZONE_NORMAL;
+#endif
ac->preferred_zoneref = first_zones_zonelist(ac->zonelist,
ac->high_zoneidx, ac->nodemask);
}
@@ -5808,6 +5813,10 @@ static unsigned long __meminit zone_spanned_pages_in_node(int nid,
unsigned long *zone_end_pfn,
unsigned long *ignored)
{
+#ifdef CONFIG_ZONE_NVM
+ unsigned long start_pfn, end_pfn;
+#endif
+
/* When hotadd a new node from cpu_up(), the node should be empty */
if (!node_start_pfn && !node_end_pfn)
return 0;
@@ -5815,6 +5824,26 @@ static unsigned long __meminit zone_spanned_pages_in_node(int nid,
/* Get the start and end of the zone */
*zone_start_pfn = arch_zone_lowest_possible_pfn[zone_type];
*zone_end_pfn = arch_zone_highest_possible_pfn[zone_type];
+
+#ifdef CONFIG_ZONE_NVM
+ /*
+ * Use zone_type to adjust zone size again.
+ */
+ if (zone_type == ZONE_NVM) {
+ get_pfn_range_for_nid_with_flags(nid, &start_pfn, &end_pfn,
+ MEMBLOCK_NVDIMM);
+ } else {
+ get_pfn_range_for_nid_with_flags(nid, &start_pfn, &end_pfn,
+ MEMBLOCK_NONE);
+ }
+
+ if (*zone_end_pfn < start_pfn || *zone_start_pfn > end_pfn)
+ return 0;
+ /* Move the zone boundaries inside the possile_pfn if necessary */
+ *zone_end_pfn = min(*zone_end_pfn, end_pfn);
+ *zone_start_pfn = max(*zone_start_pfn, start_pfn);
+#endif
+
adjust_zone_range_for_zone_movable(nid, zone_type,
node_start_pfn, node_end_pfn,
zone_start_pfn, zone_end_pfn);
@@ -6680,6 +6709,17 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
start_pfn = end_pfn;
}
+#ifdef CONFIG_ZONE_NVM
+ /*
+ * Adjust nvm zone included in normal zone
+ */
+ get_pfn_range_for_nid_with_flags(MAX_NUMNODES, &start_pfn, &end_pfn,
+ MEMBLOCK_NVDIMM);
+
+ arch_zone_lowest_possible_pfn[ZONE_NVM] = start_pfn;
+ arch_zone_highest_possible_pfn[ZONE_NVM] = end_pfn;
+#endif
+
/* Find the PFNs that ZONE_MOVABLE begins at in each node */
memset(zone_movable_pfn, 0, sizeof(zone_movable_pfn));
find_zone_movable_pfns_for_nodes();
--
1.8.3.1
next prev parent reply other threads:[~2018-05-08 2:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 2:30 [RFC PATCH v1 0/6] use mm to manage NVDIMM (pmem) zone Huaisheng Ye
[not found] ` <1525746628-114136-2-git-send-email-yehs1@lenovo.com>
2018-05-08 2:30 ` [External] [RFC PATCH v1 1/6] mm/memblock: Expand definition of flags to support NVDIMM Huaisheng HS1 Ye
2018-05-08 2:30 ` [RFC PATCH v1 4/6] arch/x86/kernel: mark NVDIMM regions from e820_table Huaisheng Ye
[not found] ` <1525746628-114136-3-git-send-email-yehs1@lenovo.com>
2018-05-08 2:32 ` [External] [RFC PATCH v1 2/6] mm/page_alloc.c: get pfn range with flags of memblock Huaisheng HS1 Ye
[not found] ` <1525746628-114136-4-git-send-email-yehs1@lenovo.com>
2018-05-08 2:33 ` [External] [RFC PATCH v1 3/6] mm, zone_type: create ZONE_NVM and fill into GFP_ZONE_TABLE Huaisheng HS1 Ye
2018-05-08 4:43 ` Randy Dunlap
2018-05-09 4:22 ` Huaisheng HS1 Ye
2018-05-09 11:47 ` Michal Hocko
2018-05-09 14:04 ` Huaisheng HS1 Ye
2018-05-09 20:56 ` Michal Hocko
2018-05-10 3:53 ` Huaisheng HS1 Ye
[not found] ` <1525746628-114136-6-git-send-email-yehs1@lenovo.com>
2018-05-08 2:34 ` Huaisheng HS1 Ye [this message]
[not found] ` <1525746628-114136-7-git-send-email-yehs1@lenovo.com>
2018-05-08 2:35 ` [External] [RFC PATCH v1 6/6] arch/x86/mm: create page table mapping for DRAM and NVDIMM both Huaisheng HS1 Ye
2018-05-10 7:57 ` [RFC PATCH v1 0/6] use mm to manage NVDIMM (pmem) zone Michal Hocko
2018-05-10 8:41 ` Michal Hocko
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=HK2PR03MB16843F0A91E190ECDBB28F2F929A0@HK2PR03MB1684.apcprd03.prod.outlook.com \
--to=yehs1@lenovo.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.levin@verizon.com \
--cc=chengnt@lenovo.com \
--cc=colyli@suse.de \
--cc=hannes@cmpxchg.org \
--cc=hehy1@lenovo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@lists.01.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=pasha.tatashin@oracle.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=vbabka@suse.cz \
--cc=willy@infradead.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 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).