From: Huaisheng Ye <yehs1@lenovo.com>
To: akpm@linux-foundation.org, linux-mm@kvack.org
Cc: mhocko@suse.com, willy@infradead.org, vbabka@suse.cz,
mgorman@techsingularity.net, pasha.tatashin@oracle.com,
alexander.levin@verizon.com, hannes@cmpxchg.org,
penguin-kernel@I-love.SAKURA.ne.jp, colyli@suse.de,
chengnt@lenovo.com, hehy1@lenovo.com,
linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org,
Huaisheng Ye <yehs1@lenovo.com>
Subject: [RFC PATCH v1 4/6] arch/x86/kernel: mark NVDIMM regions from e820_table
Date: Tue, 8 May 2018 10:30:26 +0800 [thread overview]
Message-ID: <1525746628-114136-5-git-send-email-yehs1@lenovo.com> (raw)
In-Reply-To: <1525746628-114136-1-git-send-email-yehs1@lenovo.com>
During e820__memblock_setup memblock gets entries with type
E820_TYPE_RAM, E820_TYPE_RESERVED_KERN and E820_TYPE_PMEM from
e820_table, then marks NVDIMM regions with flag MEMBLOCK_NVDIMM.
Create function as e820__end_of_nvm_pfn to calculate max_pfn with
NVDIMM region, while zone_sizes_init needs max_pfn to get
arch_zone_lowest/highest_possible_pfn. During free_area_init_nodes,
the possible pfns need to be recalculated for ZONE_NVM.
Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
Signed-off-by: Ocean He <hehy1@lenovo.com>
---
arch/x86/include/asm/e820/api.h | 3 +++
arch/x86/kernel/e820.c | 20 +++++++++++++++++++-
arch/x86/kernel/setup.c | 8 ++++++++
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h
index 62be73b..b8006c3 100644
--- a/arch/x86/include/asm/e820/api.h
+++ b/arch/x86/include/asm/e820/api.h
@@ -22,6 +22,9 @@
extern void e820__update_table_print(void);
extern unsigned long e820__end_of_ram_pfn(void);
+#ifdef CONFIG_ZONE_NVM
+extern unsigned long e820__end_of_nvm_pfn(void);
+#endif
extern unsigned long e820__end_of_low_ram_pfn(void);
extern u64 e820__memblock_alloc_reserved(u64 size, u64 align);
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 71c11ad..c1dc1cc 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -840,6 +840,13 @@ unsigned long __init e820__end_of_ram_pfn(void)
return e820_end_pfn(MAX_ARCH_PFN, E820_TYPE_RAM);
}
+#ifdef CONFIG_ZONE_NVM
+unsigned long __init e820__end_of_nvm_pfn(void)
+{
+ return e820_end_pfn(MAX_ARCH_PFN, E820_TYPE_PMEM);
+}
+#endif
+
unsigned long __init e820__end_of_low_ram_pfn(void)
{
return e820_end_pfn(1UL << (32 - PAGE_SHIFT), E820_TYPE_RAM);
@@ -1246,11 +1253,22 @@ void __init e820__memblock_setup(void)
end = entry->addr + entry->size;
if (end != (resource_size_t)end)
continue;
-
+#ifdef CONFIG_ZONE_NVM
+ if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN &&
+ entry->type != E820_TYPE_PMEM)
+#else
if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN)
+#endif
continue;
memblock_add(entry->addr, entry->size);
+
+#ifdef CONFIG_ZONE_NVM
+ if (entry->type == E820_TYPE_PMEM) {
+ /* Mark this region with PMEM flags */
+ memblock_mark_nvdimm(entry->addr, entry->size);
+ }
+#endif
}
/* Throw away partial pages: */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 4c616be..84c4ddb 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1032,7 +1032,15 @@ void __init setup_arch(char **cmdline_p)
* partially used pages are not usable - thus
* we are rounding upwards:
*/
+#ifdef CONFIG_ZONE_NVM
+ max_pfn = e820__end_of_nvm_pfn();
+ if (!max_pfn) {
+ printk(KERN_INFO "No physical NVDIMM has been found\n");
+ max_pfn = e820__end_of_ram_pfn();
+ }
+#else
max_pfn = e820__end_of_ram_pfn();
+#endif
/* update e820 for memory not covered by WB MTRRs */
mtrr_bp_init();
--
1.8.3.1
next prev parent reply other threads:[~2018-05-08 2:18 UTC|newest]
Thread overview: 17+ 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 ` Huaisheng Ye [this message]
[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 ` [External] [RFC PATCH v1 5/6] mm: get zone spanned pages separately for DRAM and NVDIMM Huaisheng HS1 Ye
[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
-- strict thread matches above, loose matches on Subject: below --
2018-05-08 2:00 Huaisheng Ye
2018-05-08 2:00 ` [RFC PATCH v1 4/6] arch/x86/kernel: mark NVDIMM regions from e820_table Huaisheng Ye
2018-05-07 14:50 [RFC PATCH v1 0/6] use mm to manage NVDIMM (pmem) zone Huaisheng Ye
2018-05-07 14:50 ` [RFC PATCH v1 4/6] arch/x86/kernel: mark NVDIMM regions from e820_table Huaisheng Ye
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=1525746628-114136-5-git-send-email-yehs1@lenovo.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