* [PATCH v2 1/2] mm: introduce prepare_node_data
2021-05-18 9:24 [PATCH v2 0/2] mm: unify the allocation of pglist_data instances Miles Chen
@ 2021-05-18 9:24 ` Miles Chen
2021-05-18 9:24 ` [PATCH v2 2/2] mm: replace contig_page_data with node_data Miles Chen
2021-05-18 16:09 ` [PATCH v2 0/2] mm: unify the allocation of pglist_data instances Mike Rapoport
2 siblings, 0 replies; 7+ messages in thread
From: Miles Chen @ 2021-05-18 9:24 UTC (permalink / raw)
To: Dave Young, Baoquan He, Vivek Goyal, Jonathan Corbet,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Andrew Morton, Mike Rapoport
Cc: kexec, linux-doc, linuxppc-dev, linux-mm, linux-arm-kernel,
linux-mediatek, Miles Chen, Kazu
When CONFIG_NEED_MULTIPLE_NODES=y (CONFIG_NUMA=y),
the pglist_data is allocated by a memblock API and stored in an array
named node_data[].
When CONFIG_NEED_MULTIPLE_NODES=n (CONFIG_NUMA=n), the pglist_data
is defined as global variable contig_page_data. The difference
causes problems when we enable CONFIG_DEBUG_VIRTUAL and use __pa()
to get the physical address of NODE_DATA.
To solve the issue, introduce prepare_node_data() to allocate
pglist_data when CONFIG_NUMA=n and stored it to node_data.
i.e., Use the same way to allocate node_data[] when CONFIG_NUMA=y
or CONFIG_NUMA=n.
prepare_node_data() is called in sparer_init() and
free_area_init().
This is the first step to replace contig_page_data with allocated
pglist_data.
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Kazu <k-hagio-ab@nec.com>
Signed-off-by: Miles Chen <miles.chen@mediatek.com>
---
include/linux/mm.h | 2 ++
include/linux/mmzone.h | 1 +
mm/memblock.c | 1 +
mm/page_alloc.c | 16 ++++++++++++++++
mm/sparse.c | 2 ++
5 files changed, 22 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c274f75efcf9..3052eeb87455 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2462,9 +2462,11 @@ static inline int early_pfn_to_nid(unsigned long pfn)
{
return 0;
}
+extern void prepare_node_data(void);
#else
/* please see mm/page_alloc.c */
extern int __meminit early_pfn_to_nid(unsigned long pfn);
+static inline void prepare_node_data(void) {};
#endif
extern void set_dma_reserve(unsigned long new_dma_reserve);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0d53eba1c383..557918dcc755 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1045,6 +1045,7 @@ extern char numa_zonelist_order[];
extern struct pglist_data contig_page_data;
#define NODE_DATA(nid) (&contig_page_data)
+extern struct pglist_data *node_data[];
#define NODE_MEM_MAP(nid) mem_map
#else /* CONFIG_NEED_MULTIPLE_NODES */
diff --git a/mm/memblock.c b/mm/memblock.c
index afaefa8fc6ab..ebddb57ea62d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -95,6 +95,7 @@
#ifndef CONFIG_NEED_MULTIPLE_NODES
struct pglist_data __refdata contig_page_data;
EXPORT_SYMBOL(contig_page_data);
+struct pglist_data *node_data[MAX_NUMNODES];
#endif
unsigned long max_low_pfn;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index aaa1655cf682..0c6d421f4cfb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1659,6 +1659,20 @@ int __meminit early_pfn_to_nid(unsigned long pfn)
return nid;
}
+#else
+void __init prepare_node_data(void)
+{
+ if (node_data[0])
+ return;
+
+ node_data[0] = memblock_alloc(sizeof(struct pglist_data),
+ SMP_CACHE_BYTES);
+
+ if (!node_data[0])
+ panic("Cannot allocate node_data\n");
+
+ memset(node_data[0], 0, sizeof(struct pglist_data));
+}
#endif /* CONFIG_NEED_MULTIPLE_NODES */
void __init memblock_free_pages(struct page *page, unsigned long pfn,
@@ -7697,6 +7711,8 @@ void __init free_area_init(unsigned long *max_zone_pfn)
int i, nid, zone;
bool descending;
+ prepare_node_data();
+
/* Record where the zone boundaries are */
memset(arch_zone_lowest_possible_pfn, 0,
sizeof(arch_zone_lowest_possible_pfn));
diff --git a/mm/sparse.c b/mm/sparse.c
index b2ada9dc00cb..afcfe7463b4a 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -580,6 +580,8 @@ void __init sparse_init(void)
memblocks_present();
+ prepare_node_data();
+
pnum_begin = first_present_section_nr();
nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] mm: replace contig_page_data with node_data
2021-05-18 9:24 [PATCH v2 0/2] mm: unify the allocation of pglist_data instances Miles Chen
2021-05-18 9:24 ` [PATCH v2 1/2] mm: introduce prepare_node_data Miles Chen
@ 2021-05-18 9:24 ` Miles Chen
2021-05-18 16:09 ` [PATCH v2 0/2] mm: unify the allocation of pglist_data instances Mike Rapoport
2 siblings, 0 replies; 7+ messages in thread
From: Miles Chen @ 2021-05-18 9:24 UTC (permalink / raw)
To: Dave Young, Baoquan He, Vivek Goyal, Jonathan Corbet,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Andrew Morton, Mike Rapoport
Cc: kexec, linux-doc, linuxppc-dev, linux-mm, linux-arm-kernel,
linux-mediatek, Miles Chen, Kazu
Replace contig_page_data with node_data. Change the definition
of NODE_DATA(nid) from (&contig_page_data) to (node_data[0]).
Remove contig_page_data from the tree.
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Kazu <k-hagio-ab@nec.com>
Signed-off-by: Miles Chen <miles.chen@mediatek.com>
---
Documentation/admin-guide/kdump/vmcoreinfo.rst | 13 -------------
arch/powerpc/kexec/core.c | 5 -----
include/linux/gfp.h | 3 ---
include/linux/mmzone.h | 3 +--
kernel/crash_core.c | 1 -
mm/memblock.c | 2 --
6 files changed, 1 insertion(+), 26 deletions(-)
diff --git a/Documentation/admin-guide/kdump/vmcoreinfo.rst b/Documentation/admin-guide/kdump/vmcoreinfo.rst
index 3861a25faae1..74185245c580 100644
--- a/Documentation/admin-guide/kdump/vmcoreinfo.rst
+++ b/Documentation/admin-guide/kdump/vmcoreinfo.rst
@@ -81,14 +81,6 @@ into that mem_map array.
Used to map an address to the corresponding struct page.
-contig_page_data
-----------------
-
-Makedumpfile gets the pglist_data structure from this symbol, which is
-used to describe the memory layout.
-
-User-space tools use this to exclude free pages when dumping memory.
-
mem_section|(mem_section, NR_SECTION_ROOTS)|(mem_section, section_mem_map)
--------------------------------------------------------------------------
@@ -531,11 +523,6 @@ node_data|(node_data, MAX_NUMNODES)
See above.
-contig_page_data
-----------------
-
-See above.
-
vmemmap_list
------------
diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c
index 56da5eb2b923..41f31dfb540c 100644
--- a/arch/powerpc/kexec/core.c
+++ b/arch/powerpc/kexec/core.c
@@ -68,13 +68,8 @@ void machine_kexec_cleanup(struct kimage *image)
void arch_crash_save_vmcoreinfo(void)
{
-#ifdef CONFIG_NEED_MULTIPLE_NODES
VMCOREINFO_SYMBOL(node_data);
VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
-#endif
-#ifndef CONFIG_NEED_MULTIPLE_NODES
- VMCOREINFO_SYMBOL(contig_page_data);
-#endif
#if defined(CONFIG_PPC64) && defined(CONFIG_SPARSEMEM_VMEMMAP)
VMCOREINFO_SYMBOL(vmemmap_list);
VMCOREINFO_SYMBOL(mmu_vmemmap_psize);
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 11da8af06704..ba8c511c402f 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -493,9 +493,6 @@ static inline int gfp_zonelist(gfp_t flags)
* This zone list contains a maximum of MAX_NUMNODES*MAX_NR_ZONES zones.
* There are two zonelists per node, one for all zones with memory and
* one containing just zones from the node the zonelist belongs to.
- *
- * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets
- * optimized to &contig_page_data at compile-time.
*/
static inline struct zonelist *node_zonelist(int nid, gfp_t flags)
{
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 557918dcc755..c0769292187c 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1043,9 +1043,8 @@ extern char numa_zonelist_order[];
#ifndef CONFIG_NEED_MULTIPLE_NODES
-extern struct pglist_data contig_page_data;
-#define NODE_DATA(nid) (&contig_page_data)
extern struct pglist_data *node_data[];
+#define NODE_DATA(nid) (node_data[0])
#define NODE_MEM_MAP(nid) mem_map
#else /* CONFIG_NEED_MULTIPLE_NODES */
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 825284baaf46..d1e324be67f9 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -457,7 +457,6 @@ static int __init crash_save_vmcoreinfo_init(void)
#ifndef CONFIG_NEED_MULTIPLE_NODES
VMCOREINFO_SYMBOL(mem_map);
- VMCOREINFO_SYMBOL(contig_page_data);
#endif
#ifdef CONFIG_SPARSEMEM
VMCOREINFO_SYMBOL_ARRAY(mem_section);
diff --git a/mm/memblock.c b/mm/memblock.c
index ebddb57ea62d..7cfc9a9d6243 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -93,8 +93,6 @@
*/
#ifndef CONFIG_NEED_MULTIPLE_NODES
-struct pglist_data __refdata contig_page_data;
-EXPORT_SYMBOL(contig_page_data);
struct pglist_data *node_data[MAX_NUMNODES];
#endif
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances
2021-05-18 9:24 [PATCH v2 0/2] mm: unify the allocation of pglist_data instances Miles Chen
2021-05-18 9:24 ` [PATCH v2 1/2] mm: introduce prepare_node_data Miles Chen
2021-05-18 9:24 ` [PATCH v2 2/2] mm: replace contig_page_data with node_data Miles Chen
@ 2021-05-18 16:09 ` Mike Rapoport
2021-05-19 0:12 ` Miles Chen
2 siblings, 1 reply; 7+ messages in thread
From: Mike Rapoport @ 2021-05-18 16:09 UTC (permalink / raw)
To: Miles Chen
Cc: Dave Young, Baoquan He, Vivek Goyal, Jonathan Corbet,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Andrew Morton, kexec, linux-doc, linuxppc-dev, linux-mm,
linux-arm-kernel, linux-mediatek
Hello Miles,
On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote:
> This patches is created to fix the __pa() warning messages when
> CONFIG_DEBUG_VIRTUAL=y by unifying the allocation of pglist_data
> instances.
>
> In current implementation of node_data, if CONFIG_NEED_MULTIPLE_NODES=y,
> pglist_data is allocated by a memblock API. If CONFIG_NEED_MULTIPLE_NODES=n,
> we use a global variable named "contig_page_data".
>
> If CONFIG_DEBUG_VIRTUAL is not enabled. __pa() can handle both
> allocation and symbol cases. But if CONFIG_DEBUG_VIRTUAL is set,
> we will have the "virt_to_phys used for non-linear address" warning
> when booting.
>
> To fix the warning, always allocate pglist_data by memblock APIs and
> remove the usage of contig_page_data.
Somehow I was sure that we can allocate pglist_data before it is accessed
in sparse_init() somewhere outside mm/sparse.c. It's really not the case
and having two places that may allocated this structure is surely worth
than your previous suggestion.
Sorry about that.
> Warning message:
> [ 0.000000] ------------[ cut here ]------------
> [ 0.000000] virt_to_phys used for non-linear address: (____ptrval____) (contig_page_data+0x0/0x1c00)
> [ 0.000000] WARNING: CPU: 0 PID: 0 at arch/arm64/mm/physaddr.c:15 __virt_to_phys+0x58/0x68
> [ 0.000000] Modules linked in:
> [ 0.000000] CPU: 0 PID: 0 Comm: swapper Tainted: G W 5.13.0-rc1-00074-g1140ab592e2e #3
> [ 0.000000] Hardware name: linux,dummy-virt (DT)
> [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO BTYPE=--)
> [ 0.000000] pc : __virt_to_phys+0x58/0x68
> [ 0.000000] lr : __virt_to_phys+0x54/0x68
> [ 0.000000] sp : ffff800011833e70
> [ 0.000000] x29: ffff800011833e70 x28: 00000000418a0018 x27: 0000000000000000
> [ 0.000000] x26: 000000000000000a x25: ffff800011b70000 x24: ffff800011b70000
> [ 0.000000] x23: fffffc0001c00000 x22: ffff800011b70000 x21: 0000000047ffffb0
> [ 0.000000] x20: 0000000000000008 x19: ffff800011b082c0 x18: ffffffffffffffff
> [ 0.000000] x17: 0000000000000000 x16: ffff800011833bf9 x15: 0000000000000004
> [ 0.000000] x14: 0000000000000fff x13: ffff80001186a548 x12: 0000000000000000
> [ 0.000000] x11: 0000000000000000 x10: 00000000ffffffff x9 : 0000000000000000
> [ 0.000000] x8 : ffff8000115c9000 x7 : 737520737968705f x6 : ffff800011b62ef8
> [ 0.000000] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000000
> [ 0.000000] x2 : 0000000000000000 x1 : ffff80001159585e x0 : 0000000000000058
> [ 0.000000] Call trace:
> [ 0.000000] __virt_to_phys+0x58/0x68
> [ 0.000000] check_usemap_section_nr+0x50/0xfc
> [ 0.000000] sparse_init_nid+0x1ac/0x28c
> [ 0.000000] sparse_init+0x1c4/0x1e0
> [ 0.000000] bootmem_init+0x60/0x90
> [ 0.000000] setup_arch+0x184/0x1f0
> [ 0.000000] start_kernel+0x78/0x488
> [ 0.000000] ---[ end trace f68728a0d3053b60 ]---
>
> [1] https://lore.kernel.org/patchwork/patch/1425110/
>
> Change since v1:
> - use memblock_alloc() to create pglist_data when CONFIG_NUMA=n
>
> Miles Chen (2):
> mm: introduce prepare_node_data
> mm: replace contig_page_data with node_data
>
> Documentation/admin-guide/kdump/vmcoreinfo.rst | 13 -------------
> arch/powerpc/kexec/core.c | 5 -----
> include/linux/gfp.h | 3 ---
> include/linux/mm.h | 2 ++
> include/linux/mmzone.h | 4 ++--
> kernel/crash_core.c | 1 -
> mm/memblock.c | 3 +--
> mm/page_alloc.c | 16 ++++++++++++++++
> mm/sparse.c | 2 ++
> 9 files changed, 23 insertions(+), 26 deletions(-)
>
>
> base-commit: 8ac91e6c6033ebc12c5c1e4aa171b81a662bd70f
> --
> 2.18.0
>
--
Sincerely yours,
Mike.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances
2021-05-18 16:09 ` [PATCH v2 0/2] mm: unify the allocation of pglist_data instances Mike Rapoport
@ 2021-05-19 0:12 ` Miles Chen
2021-05-19 3:48 ` Mike Rapoport
0 siblings, 1 reply; 7+ messages in thread
From: Miles Chen @ 2021-05-19 0:12 UTC (permalink / raw)
To: Mike Rapoport
Cc: Dave Young, Baoquan He, Vivek Goyal, Jonathan Corbet,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Andrew Morton, kexec, linux-doc, linuxppc-dev, linux-mm,
linux-arm-kernel, linux-mediatek
On Tue, 2021-05-18 at 19:09 +0300, Mike Rapoport wrote:
> Hello Miles,
>
> On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote:
> > This patches is created to fix the __pa() warning messages when
> > CONFIG_DEBUG_VIRTUAL=y by unifying the allocation of pglist_data
> > instances.
> >
> > In current implementation of node_data, if CONFIG_NEED_MULTIPLE_NODES=y,
> > pglist_data is allocated by a memblock API. If CONFIG_NEED_MULTIPLE_NODES=n,
> > we use a global variable named "contig_page_data".
> >
> > If CONFIG_DEBUG_VIRTUAL is not enabled. __pa() can handle both
> > allocation and symbol cases. But if CONFIG_DEBUG_VIRTUAL is set,
> > we will have the "virt_to_phys used for non-linear address" warning
> > when booting.
> >
> > To fix the warning, always allocate pglist_data by memblock APIs and
> > remove the usage of contig_page_data.
>
> Somehow I was sure that we can allocate pglist_data before it is accessed
> in sparse_init() somewhere outside mm/sparse.c. It's really not the case
> and having two places that may allocated this structure is surely worth
> than your previous suggestion.
>
> Sorry about that.
Do you mean taht to call allocation function arch/*, somewhere after
paging_init() (so we can access pglist_data) and before sparse_init()
and free_area_init()?
Miles
>
> > Warning message:
> > [ 0.000000] ------------[ cut here ]------------
> > [ 0.000000] virt_to_phys used for non-linear address: (____ptrval____) (contig_page_data+0x0/0x1c00)
> > [ 0.000000] WARNING: CPU: 0 PID: 0 at arch/arm64/mm/physaddr.c:15 __virt_to_phys+0x58/0x68
> > [ 0.000000] Modules linked in:
> > [ 0.000000] CPU: 0 PID: 0 Comm: swapper Tainted: G W 5.13.0-rc1-00074-g1140ab592e2e #3
> > [ 0.000000] Hardware name: linux,dummy-virt (DT)
> > [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO BTYPE=--)
> > [ 0.000000] pc : __virt_to_phys+0x58/0x68
> > [ 0.000000] lr : __virt_to_phys+0x54/0x68
> > [ 0.000000] sp : ffff800011833e70
> > [ 0.000000] x29: ffff800011833e70 x28: 00000000418a0018 x27: 0000000000000000
> > [ 0.000000] x26: 000000000000000a x25: ffff800011b70000 x24: ffff800011b70000
> > [ 0.000000] x23: fffffc0001c00000 x22: ffff800011b70000 x21: 0000000047ffffb0
> > [ 0.000000] x20: 0000000000000008 x19: ffff800011b082c0 x18: ffffffffffffffff
> > [ 0.000000] x17: 0000000000000000 x16: ffff800011833bf9 x15: 0000000000000004
> > [ 0.000000] x14: 0000000000000fff x13: ffff80001186a548 x12: 0000000000000000
> > [ 0.000000] x11: 0000000000000000 x10: 00000000ffffffff x9 : 0000000000000000
> > [ 0.000000] x8 : ffff8000115c9000 x7 : 737520737968705f x6 : ffff800011b62ef8
> > [ 0.000000] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000000
> > [ 0.000000] x2 : 0000000000000000 x1 : ffff80001159585e x0 : 0000000000000058
> > [ 0.000000] Call trace:
> > [ 0.000000] __virt_to_phys+0x58/0x68
> > [ 0.000000] check_usemap_section_nr+0x50/0xfc
> > [ 0.000000] sparse_init_nid+0x1ac/0x28c
> > [ 0.000000] sparse_init+0x1c4/0x1e0
> > [ 0.000000] bootmem_init+0x60/0x90
> > [ 0.000000] setup_arch+0x184/0x1f0
> > [ 0.000000] start_kernel+0x78/0x488
> > [ 0.000000] ---[ end trace f68728a0d3053b60 ]---
> >
> > [1] https://urldefense.com/v3/__https://lore.kernel.org/patchwork/patch/1425110/__;!!CTRNKA9wMg0ARbw!x-wGFEC1wLzXho2kI1CrC2fjXNaQm5f-n0ADQyJDckCOKZHAP_q055DCSWYcQ7Zdcw$
> >
> > Change since v1:
> > - use memblock_alloc() to create pglist_data when CONFIG_NUMA=n
> >
> > Miles Chen (2):
> > mm: introduce prepare_node_data
> > mm: replace contig_page_data with node_data
> >
> > Documentation/admin-guide/kdump/vmcoreinfo.rst | 13 -------------
> > arch/powerpc/kexec/core.c | 5 -----
> > include/linux/gfp.h | 3 ---
> > include/linux/mm.h | 2 ++
> > include/linux/mmzone.h | 4 ++--
> > kernel/crash_core.c | 1 -
> > mm/memblock.c | 3 +--
> > mm/page_alloc.c | 16 ++++++++++++++++
> > mm/sparse.c | 2 ++
> > 9 files changed, 23 insertions(+), 26 deletions(-)
> >
> >
> > base-commit: 8ac91e6c6033ebc12c5c1e4aa171b81a662bd70f
> > --
> > 2.18.0
> >
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances
2021-05-19 0:12 ` Miles Chen
@ 2021-05-19 3:48 ` Mike Rapoport
2021-05-19 3:55 ` Miles Chen
0 siblings, 1 reply; 7+ messages in thread
From: Mike Rapoport @ 2021-05-19 3:48 UTC (permalink / raw)
To: Miles Chen
Cc: Dave Young, Baoquan He, Vivek Goyal, Jonathan Corbet,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Andrew Morton, kexec, linux-doc, linuxppc-dev, linux-mm,
linux-arm-kernel, linux-mediatek
On Wed, May 19, 2021 at 08:12:06AM +0800, Miles Chen wrote:
> On Tue, 2021-05-18 at 19:09 +0300, Mike Rapoport wrote:
> > Hello Miles,
> >
> > On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote:
> > > This patches is created to fix the __pa() warning messages when
> > > CONFIG_DEBUG_VIRTUAL=y by unifying the allocation of pglist_data
> > > instances.
> > >
> > > In current implementation of node_data, if CONFIG_NEED_MULTIPLE_NODES=y,
> > > pglist_data is allocated by a memblock API. If CONFIG_NEED_MULTIPLE_NODES=n,
> > > we use a global variable named "contig_page_data".
> > >
> > > If CONFIG_DEBUG_VIRTUAL is not enabled. __pa() can handle both
> > > allocation and symbol cases. But if CONFIG_DEBUG_VIRTUAL is set,
> > > we will have the "virt_to_phys used for non-linear address" warning
> > > when booting.
> > >
> > > To fix the warning, always allocate pglist_data by memblock APIs and
> > > remove the usage of contig_page_data.
> >
> > Somehow I was sure that we can allocate pglist_data before it is accessed
> > in sparse_init() somewhere outside mm/sparse.c. It's really not the case
> > and having two places that may allocated this structure is surely worth
> > than your previous suggestion.
> >
> > Sorry about that.
>
> Do you mean taht to call allocation function arch/*, somewhere after
> paging_init() (so we can access pglist_data) and before sparse_init()
> and free_area_init()?
No, I meant that your original patch is better than adding allocation of
NODE_DATA(0) in two places.
> Miles
>
> >
> > > Warning message:
> > > [ 0.000000] ------------[ cut here ]------------
> > > [ 0.000000] virt_to_phys used for non-linear address: (____ptrval____) (contig_page_data+0x0/0x1c00)
> > > [ 0.000000] WARNING: CPU: 0 PID: 0 at arch/arm64/mm/physaddr.c:15 __virt_to_phys+0x58/0x68
> > > [ 0.000000] Modules linked in:
> > > [ 0.000000] CPU: 0 PID: 0 Comm: swapper Tainted: G W 5.13.0-rc1-00074-g1140ab592e2e #3
> > > [ 0.000000] Hardware name: linux,dummy-virt (DT)
> > > [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO BTYPE=--)
> > > [ 0.000000] pc : __virt_to_phys+0x58/0x68
> > > [ 0.000000] lr : __virt_to_phys+0x54/0x68
> > > [ 0.000000] sp : ffff800011833e70
> > > [ 0.000000] x29: ffff800011833e70 x28: 00000000418a0018 x27: 0000000000000000
> > > [ 0.000000] x26: 000000000000000a x25: ffff800011b70000 x24: ffff800011b70000
> > > [ 0.000000] x23: fffffc0001c00000 x22: ffff800011b70000 x21: 0000000047ffffb0
> > > [ 0.000000] x20: 0000000000000008 x19: ffff800011b082c0 x18: ffffffffffffffff
> > > [ 0.000000] x17: 0000000000000000 x16: ffff800011833bf9 x15: 0000000000000004
> > > [ 0.000000] x14: 0000000000000fff x13: ffff80001186a548 x12: 0000000000000000
> > > [ 0.000000] x11: 0000000000000000 x10: 00000000ffffffff x9 : 0000000000000000
> > > [ 0.000000] x8 : ffff8000115c9000 x7 : 737520737968705f x6 : ffff800011b62ef8
> > > [ 0.000000] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000000
> > > [ 0.000000] x2 : 0000000000000000 x1 : ffff80001159585e x0 : 0000000000000058
> > > [ 0.000000] Call trace:
> > > [ 0.000000] __virt_to_phys+0x58/0x68
> > > [ 0.000000] check_usemap_section_nr+0x50/0xfc
> > > [ 0.000000] sparse_init_nid+0x1ac/0x28c
> > > [ 0.000000] sparse_init+0x1c4/0x1e0
> > > [ 0.000000] bootmem_init+0x60/0x90
> > > [ 0.000000] setup_arch+0x184/0x1f0
> > > [ 0.000000] start_kernel+0x78/0x488
> > > [ 0.000000] ---[ end trace f68728a0d3053b60 ]---
> > >
> > > [1] https://urldefense.com/v3/__https://lore.kernel.org/patchwork/patch/1425110/__;!!CTRNKA9wMg0ARbw!x-wGFEC1wLzXho2kI1CrC2fjXNaQm5f-n0ADQyJDckCOKZHAP_q055DCSWYcQ7Zdcw$
> > >
> > > Change since v1:
> > > - use memblock_alloc() to create pglist_data when CONFIG_NUMA=n
> > >
> > > Miles Chen (2):
> > > mm: introduce prepare_node_data
> > > mm: replace contig_page_data with node_data
> > >
> > > Documentation/admin-guide/kdump/vmcoreinfo.rst | 13 -------------
> > > arch/powerpc/kexec/core.c | 5 -----
> > > include/linux/gfp.h | 3 ---
> > > include/linux/mm.h | 2 ++
> > > include/linux/mmzone.h | 4 ++--
> > > kernel/crash_core.c | 1 -
> > > mm/memblock.c | 3 +--
> > > mm/page_alloc.c | 16 ++++++++++++++++
> > > mm/sparse.c | 2 ++
> > > 9 files changed, 23 insertions(+), 26 deletions(-)
> > >
> > >
> > > base-commit: 8ac91e6c6033ebc12c5c1e4aa171b81a662bd70f
> > > --
> > > 2.18.0
> > >
> >
>
--
Sincerely yours,
Mike.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances
2021-05-19 3:48 ` Mike Rapoport
@ 2021-05-19 3:55 ` Miles Chen
0 siblings, 0 replies; 7+ messages in thread
From: Miles Chen @ 2021-05-19 3:55 UTC (permalink / raw)
To: Mike Rapoport
Cc: Dave Young, Baoquan He, Vivek Goyal, Jonathan Corbet,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Andrew Morton, kexec, linux-doc, linuxppc-dev, linux-mm,
linux-arm-kernel, linux-mediatek
On Wed, 2021-05-19 at 06:48 +0300, Mike Rapoport wrote:
> On Wed, May 19, 2021 at 08:12:06AM +0800, Miles Chen wrote:
> > On Tue, 2021-05-18 at 19:09 +0300, Mike Rapoport wrote:
> > > Hello Miles,
> > >
> > > On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote:
> > > > This patches is created to fix the __pa() warning messages when
> > > > CONFIG_DEBUG_VIRTUAL=y by unifying the allocation of pglist_data
> > > > instances.
> > > >
> > > > In current implementation of node_data, if CONFIG_NEED_MULTIPLE_NODES=y,
> > > > pglist_data is allocated by a memblock API. If CONFIG_NEED_MULTIPLE_NODES=n,
> > > > we use a global variable named "contig_page_data".
> > > >
> > > > If CONFIG_DEBUG_VIRTUAL is not enabled. __pa() can handle both
> > > > allocation and symbol cases. But if CONFIG_DEBUG_VIRTUAL is set,
> > > > we will have the "virt_to_phys used for non-linear address" warning
> > > > when booting.
> > > >
> > > > To fix the warning, always allocate pglist_data by memblock APIs and
> > > > remove the usage of contig_page_data.
> > >
> > > Somehow I was sure that we can allocate pglist_data before it is accessed
> > > in sparse_init() somewhere outside mm/sparse.c. It's really not the case
> > > and having two places that may allocated this structure is surely worth
> > > than your previous suggestion.
> > >
> > > Sorry about that.
> >
> > Do you mean taht to call allocation function arch/*, somewhere after
> > paging_init() (so we can access pglist_data) and before sparse_init()
> > and free_area_init()?
>
> No, I meant that your original patch is better than adding allocation of
> NODE_DATA(0) in two places.
Got it. will you re-review the original patch?
>
> > Miles
> >
> > >
> > > > Warning message:
> > > > [ 0.000000] ------------[ cut here ]------------
> > > > [ 0.000000] virt_to_phys used for non-linear address: (____ptrval____) (contig_page_data+0x0/0x1c00)
> > > > [ 0.000000] WARNING: CPU: 0 PID: 0 at arch/arm64/mm/physaddr.c:15 __virt_to_phys+0x58/0x68
> > > > [ 0.000000] Modules linked in:
> > > > [ 0.000000] CPU: 0 PID: 0 Comm: swapper Tainted: G W 5.13.0-rc1-00074-g1140ab592e2e #3
> > > > [ 0.000000] Hardware name: linux,dummy-virt (DT)
> > > > [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO BTYPE=--)
> > > > [ 0.000000] pc : __virt_to_phys+0x58/0x68
> > > > [ 0.000000] lr : __virt_to_phys+0x54/0x68
> > > > [ 0.000000] sp : ffff800011833e70
> > > > [ 0.000000] x29: ffff800011833e70 x28: 00000000418a0018 x27: 0000000000000000
> > > > [ 0.000000] x26: 000000000000000a x25: ffff800011b70000 x24: ffff800011b70000
> > > > [ 0.000000] x23: fffffc0001c00000 x22: ffff800011b70000 x21: 0000000047ffffb0
> > > > [ 0.000000] x20: 0000000000000008 x19: ffff800011b082c0 x18: ffffffffffffffff
> > > > [ 0.000000] x17: 0000000000000000 x16: ffff800011833bf9 x15: 0000000000000004
> > > > [ 0.000000] x14: 0000000000000fff x13: ffff80001186a548 x12: 0000000000000000
> > > > [ 0.000000] x11: 0000000000000000 x10: 00000000ffffffff x9 : 0000000000000000
> > > > [ 0.000000] x8 : ffff8000115c9000 x7 : 737520737968705f x6 : ffff800011b62ef8
> > > > [ 0.000000] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000000
> > > > [ 0.000000] x2 : 0000000000000000 x1 : ffff80001159585e x0 : 0000000000000058
> > > > [ 0.000000] Call trace:
> > > > [ 0.000000] __virt_to_phys+0x58/0x68
> > > > [ 0.000000] check_usemap_section_nr+0x50/0xfc
> > > > [ 0.000000] sparse_init_nid+0x1ac/0x28c
> > > > [ 0.000000] sparse_init+0x1c4/0x1e0
> > > > [ 0.000000] bootmem_init+0x60/0x90
> > > > [ 0.000000] setup_arch+0x184/0x1f0
> > > > [ 0.000000] start_kernel+0x78/0x488
> > > > [ 0.000000] ---[ end trace f68728a0d3053b60 ]---
> > > >
> > > > [1] https://urldefense.com/v3/__https://lore.kernel.org/patchwork/patch/1425110/__;!!CTRNKA9wMg0ARbw!x-wGFEC1wLzXho2kI1CrC2fjXNaQm5f-n0ADQyJDckCOKZHAP_q055DCSWYcQ7Zdcw$
> > > >
> > > > Change since v1:
> > > > - use memblock_alloc() to create pglist_data when CONFIG_NUMA=n
> > > >
> > > > Miles Chen (2):
> > > > mm: introduce prepare_node_data
> > > > mm: replace contig_page_data with node_data
> > > >
> > > > Documentation/admin-guide/kdump/vmcoreinfo.rst | 13 -------------
> > > > arch/powerpc/kexec/core.c | 5 -----
> > > > include/linux/gfp.h | 3 ---
> > > > include/linux/mm.h | 2 ++
> > > > include/linux/mmzone.h | 4 ++--
> > > > kernel/crash_core.c | 1 -
> > > > mm/memblock.c | 3 +--
> > > > mm/page_alloc.c | 16 ++++++++++++++++
> > > > mm/sparse.c | 2 ++
> > > > 9 files changed, 23 insertions(+), 26 deletions(-)
> > > >
> > > >
> > > > base-commit: 8ac91e6c6033ebc12c5c1e4aa171b81a662bd70f
> > > > --
> > > > 2.18.0
> > > >
> > >
> >
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread