linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] powerpc/mm: define TOP_ZONE as a constant
@ 2016-05-05  7:54 Oliver O'Halloran
  2016-05-05  7:54 ` [PATCH v2 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
  2016-05-10 21:48 ` [v2,1/2] powerpc/mm: define TOP_ZONE as a constant Michael Ellerman
  0 siblings, 2 replies; 7+ messages in thread
From: Oliver O'Halloran @ 2016-05-05  7:54 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Oliver O'Halloran, linux-mm

The zone that contains the top of memory will be either ZONE_NORMAL
or ZONE_HIGHMEM depending on the kernel config. There are two functions
that require this information and both of them use an #ifdef to set
a local variable (top_zone). This is a little silly so lets just make it
a constant.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Cc: linux-mm@kvack.org
---
 arch/powerpc/mm/mem.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index ac79dbde1015..8f4c19789a38 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -68,12 +68,15 @@ pte_t *kmap_pte;
 EXPORT_SYMBOL(kmap_pte);
 pgprot_t kmap_prot;
 EXPORT_SYMBOL(kmap_prot);
+#define TOP_ZONE ZONE_HIGHMEM
 
 static inline pte_t *virt_to_kpte(unsigned long vaddr)
 {
 	return pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr),
 			vaddr), vaddr), vaddr);
 }
+#else
+#define TOP_ZONE ZONE_NORMAL
 #endif
 
 int page_is_ram(unsigned long pfn)
@@ -267,14 +270,9 @@ void __init limit_zone_pfn(enum zone_type zone, unsigned long pfn_limit)
  */
 int dma_pfn_limit_to_zone(u64 pfn_limit)
 {
-	enum zone_type top_zone = ZONE_NORMAL;
 	int i;
 
-#ifdef CONFIG_HIGHMEM
-	top_zone = ZONE_HIGHMEM;
-#endif
-
-	for (i = top_zone; i >= 0; i--) {
+	for (i = TOP_ZONE; i >= 0; i--) {
 		if (max_zone_pfns[i] <= pfn_limit)
 			return i;
 	}
@@ -289,7 +287,6 @@ void __init paging_init(void)
 {
 	unsigned long long total_ram = memblock_phys_mem_size();
 	phys_addr_t top_of_ram = memblock_end_of_DRAM();
-	enum zone_type top_zone;
 
 #ifdef CONFIG_PPC32
 	unsigned long v = __fix_to_virt(__end_of_fixed_addresses - 1);
@@ -313,13 +310,9 @@ void __init paging_init(void)
 	       (long int)((top_of_ram - total_ram) >> 20));
 
 #ifdef CONFIG_HIGHMEM
-	top_zone = ZONE_HIGHMEM;
 	limit_zone_pfn(ZONE_NORMAL, lowmem_end_addr >> PAGE_SHIFT);
-#else
-	top_zone = ZONE_NORMAL;
 #endif
-
-	limit_zone_pfn(top_zone, top_of_ram >> PAGE_SHIFT);
+	limit_zone_pfn(TOP_ZONE, top_of_ram >> PAGE_SHIFT);
 	zone_limits_final = true;
 	free_area_init_nodes(max_zone_pfns);
 
-- 
2.5.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] powerpc/mm: Ensure "special" zones are empty
  2016-05-05  7:54 [PATCH v2 1/2] powerpc/mm: define TOP_ZONE as a constant Oliver O'Halloran
@ 2016-05-05  7:54 ` Oliver O'Halloran
  2016-05-09 23:55   ` [v2,2/2] " Michael Ellerman
  2016-05-10 21:48 ` [v2,1/2] powerpc/mm: define TOP_ZONE as a constant Michael Ellerman
  1 sibling, 1 reply; 7+ messages in thread
From: Oliver O'Halloran @ 2016-05-05  7:54 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Oliver O'Halloran, linux-mm

The mm zone mechanism was traditionally used by arch specific code to
partition memory into allocation zones. However there are several zones
that are managed by the mm subsystem rather than the architecture. Most
architectures set the max PFN of these special zones to zero, however on
powerpc we set them to ~0ul. This, in conjunction with a bug in
free_area_init_nodes() results in all of system memory being placed in
ZONE_DEVICE when enabled. Device memory cannot be used for regular kernel
memory allocations so this will cause a kernel panic at boot.

Given the planned addition of more mm managed zones (ZONE_CMA) we should
aim to be consistent with every other architecture and set the max PFN for
these zones to zero.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Cc: linux-mm@kvack.org
---
 arch/powerpc/mm/mem.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 8f4c19789a38..f0a058ebb6d7 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -239,8 +239,14 @@ static int __init mark_nonram_nosave(void)
 
 static bool zone_limits_final;
 
+/*
+ * The memory zones past TOP_ZONE are managed by generic mm code.
+ * These should be set to zero since that's what every other
+ * architecture does.
+ */
 static unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-	[0 ... MAX_NR_ZONES - 1] = ~0UL
+	[0        ... TOP_ZONE     - 1] = ~0UL,
+	[TOP_ZONE ... MAX_NR_ZONES - 1] = 0
 };
 
 /*
-- 
2.5.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [v2,2/2] powerpc/mm: Ensure "special" zones are empty
  2016-05-05  7:54 ` [PATCH v2 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
@ 2016-05-09 23:55   ` Michael Ellerman
  2016-05-11  7:11     ` Balbir Singh
  2016-05-11  9:22     ` [PATCH v2] " Oliver O'Halloran
  0 siblings, 2 replies; 7+ messages in thread
From: Michael Ellerman @ 2016-05-09 23:55 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev; +Cc: linux-mm

On Thu, 2016-05-05 at 07:54:09 UTC, Oliver O'Halloran wrote:
> The mm zone mechanism was traditionally used by arch specific code to
> partition memory into allocation zones. However there are several zones
> that are managed by the mm subsystem rather than the architecture. Most
> architectures set the max PFN of these special zones to zero, however on
> powerpc we set them to ~0ul. This, in conjunction with a bug in
> free_area_init_nodes() results in all of system memory being placed in
> ZONE_DEVICE when enabled. Device memory cannot be used for regular kernel
> memory allocations so this will cause a kernel panic at boot.

This is breaking my freescale machine:

  Sorting __ex_table...
  Unable to handle kernel paging request for data at address 0xc000000101e28020
  Faulting instruction address: 0xc0000000009ab698
  cpu 0x0: Vector: 300 (Data Access) at [c000000000acbb30]
      pc: c0000000009ab698: .reserve_bootmem_region+0x64/0x8c
      lr: c0000000009883d0: .free_all_bootmem+0x70/0x200
      sp: c000000000acbdb0
     msr: 80021000
     dar: c000000101e28020
   dsisr: 800000
    current = 0xc000000000a07640
    paca    = 0xc00000003fff5000	 softe: 0	 irq_happened: 0x01
      pid   = 0, comm = swapper
  Linux version 4.6.0-rc3-00160-gc09920947f23 (michael@ka1) (gcc version 5.3.0 (GCC) ) #5 SMP Tue May 10 09:44:11 AEST 2016
  enter ? for help
  [link register   ] c0000000009883d0 .free_all_bootmem+0x70/0x200
  [c000000000acbdb0] c000000000988398 .free_all_bootmem+0x38/0x200 (unreliable)
  [c000000000acbe80] c00000000097b700 .mem_init+0x5c/0x7c
  [c000000000acbef0] c000000000971a0c .start_kernel+0x28c/0x4e4
  [c000000000acbf90] c000000000000544 start_here_common+0x20/0x5c
  0:mon> ? 

I can give you access some time if you need to debug it.

cheers

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [v2,1/2] powerpc/mm: define TOP_ZONE as a constant
  2016-05-05  7:54 [PATCH v2 1/2] powerpc/mm: define TOP_ZONE as a constant Oliver O'Halloran
  2016-05-05  7:54 ` [PATCH v2 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
@ 2016-05-10 21:48 ` Michael Ellerman
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2016-05-10 21:48 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev; +Cc: linux-mm

On Thu, 2016-05-05 at 07:54:08 UTC, Oliver O'Halloran wrote:
> The zone that contains the top of memory will be either ZONE_NORMAL
> or ZONE_HIGHMEM depending on the kernel config. There are two functions
> that require this information and both of them use an #ifdef to set
> a local variable (top_zone). This is a little silly so lets just make it
> a constant.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> Cc: linux-mm@kvack.org

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/d69777dbefd707974aed91918d

cheers

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [v2,2/2] powerpc/mm: Ensure "special" zones are empty
  2016-05-09 23:55   ` [v2,2/2] " Michael Ellerman
@ 2016-05-11  7:11     ` Balbir Singh
  2016-05-11  9:22     ` [PATCH v2] " Oliver O'Halloran
  1 sibling, 0 replies; 7+ messages in thread
From: Balbir Singh @ 2016-05-11  7:11 UTC (permalink / raw)
  To: Michael Ellerman, Oliver O'Halloran, linuxppc-dev; +Cc: linux-mm

On Tue, 2016-05-10 at 09:55 +1000, Michael Ellerman wrote:
> On Thu, 2016-05-05 at 07:54:09 UTC, Oliver O'Halloran wrote:
> >A 
> > The mm zone mechanism was traditionally used by arch specific code to
> > partition memory into allocation zones. However there are several zones
> > that are managed by the mm subsystem rather than the architecture. Most
> > architectures set the max PFN of these special zones to zero, however on
> > powerpc we set them to ~0ul. This, in conjunction with a bug in
> > free_area_init_nodes() results in all of system memory being placed in
> > ZONE_DEVICE when enabled. Device memory cannot be used for regular kernel
> > memory allocations so this will cause a kernel panic at boot.
> This is breaking my freescale machine:
>A 
> A  Sorting __ex_table...
> A  Unable to handle kernel paging request for data at address 0xc000000101e28020
> A  Faulting instruction address: 0xc0000000009ab698
> A  cpu 0x0: Vector: 300 (Data Access) at [c000000000acbb30]
> A A A A A A pc: c0000000009ab698: .reserve_bootmem_region+0x64/0x8c
> A A A A A A lr: c0000000009883d0: .free_all_bootmem+0x70/0x200
> A A A A A A sp: c000000000acbdb0
> A A A A A msr: 80021000
> A A A A A dar: c000000101e28020
> A A A dsisr: 800000
> A A A A current = 0xc000000000a07640
> A A A A pacaA A A A = 0xc00000003fff5000	A softe: 0	A irq_happened: 0x01
> A A A A A A pidA A A = 0, comm = swapper
> A  Linux version 4.6.0-rc3-00160-gc09920947f23 (michael@ka1) (gcc version 5.3.0 (GCC) ) #5 SMP Tue May 10 09:44:11 AEST 2016
> A  enter ? for help
> A  [link registerA A A ] c0000000009883d0 .free_all_bootmem+0x70/0x200
> A  [c000000000acbdb0] c000000000988398 .free_all_bootmem+0x38/0x200 (unreliable)
> A  [c000000000acbe80] c00000000097b700 .mem_init+0x5c/0x7c
> A  [c000000000acbef0] c000000000971a0c .start_kernel+0x28c/0x4e4
> A  [c000000000acbf90] c000000000000544 start_here_common+0x20/0x5c
> A  0:mon> ?A 
>A 
> I can give you access some time if you need to debug it.
>A 


Could you also please post the bits on the boot containing the zone
and node information. That would provide some information about what
is broken. Or you could just send the whole dmesg

Thanks,
Balbir Singh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] powerpc/mm: Ensure "special" zones are empty
  2016-05-09 23:55   ` [v2,2/2] " Michael Ellerman
  2016-05-11  7:11     ` Balbir Singh
@ 2016-05-11  9:22     ` Oliver O'Halloran
  2016-06-21  0:40       ` [v2] " Michael Ellerman
  1 sibling, 1 reply; 7+ messages in thread
From: Oliver O'Halloran @ 2016-05-11  9:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: bsingharora, Oliver O'Halloran, linux-mm

The mm zone mechanism was traditionally used by arch specific code to
partition memory into allocation zones. However there are several zones
that are managed by the mm subsystem rather than the architecture. Most
architectures set the max PFN of these special zones to zero, however on
powerpc we set them to ~0ul. This, in conjunction with a bug in
free_area_init_nodes() results in all of system memory being placed in
ZONE_DEVICE when enabled. Device memory cannot be used for regular kernel
memory allocations so this will cause a kernel panic at boot. Given the
planned addition of more mm managed zones (ZONE_CMA) we should aim to be
consistent with every other architecture and set the max PFN for these
zones to zero.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Balbir Singh <bsingharora@gmail.com>
Cc: linux-mm@kvack.org
---
 arch/powerpc/mm/mem.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 879e0bc6f82e..f35e6605c422 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -239,8 +239,14 @@ static int __init mark_nonram_nosave(void)
 
 static bool zone_limits_final;
 
+/*
+ * The memory zones past TOP_ZONE are managed by generic mm code.
+ * These should be set to zero since that's what every other
+ * architecture does.
+ */
 static unsigned long max_zone_pfns[MAX_NR_ZONES] = {
-	[0 ... MAX_NR_ZONES - 1] = ~0UL
+	[0            ... TOP_ZONE        ] = ~0UL,
+	[TOP_ZONE + 1 ... MAX_NR_ZONES - 1] = 0
 };
 
 /*
-- 
2.5.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [v2] powerpc/mm: Ensure "special" zones are empty
  2016-05-11  9:22     ` [PATCH v2] " Oliver O'Halloran
@ 2016-06-21  0:40       ` Michael Ellerman
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2016-06-21  0:40 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev; +Cc: linux-mm

On Wed, 2016-11-05 at 09:22:18 UTC, Oliver O'Halloran wrote:
> The mm zone mechanism was traditionally used by arch specific code to
> partition memory into allocation zones. However there are several zones
> that are managed by the mm subsystem rather than the architecture. Most
> architectures set the max PFN of these special zones to zero, however on
> powerpc we set them to ~0ul. This, in conjunction with a bug in
> free_area_init_nodes() results in all of system memory being placed in
> ZONE_DEVICE when enabled. Device memory cannot be used for regular kernel
> memory allocations so this will cause a kernel panic at boot. Given the
> planned addition of more mm managed zones (ZONE_CMA) we should aim to be
> consistent with every other architecture and set the max PFN for these
> zones to zero.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> Reviewed-by: Balbir Singh <bsingharora@gmail.com>
> Cc: linux-mm@kvack.org

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/3079abe555511031e2ba5d1e21

cheers

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-21  0:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-05  7:54 [PATCH v2 1/2] powerpc/mm: define TOP_ZONE as a constant Oliver O'Halloran
2016-05-05  7:54 ` [PATCH v2 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
2016-05-09 23:55   ` [v2,2/2] " Michael Ellerman
2016-05-11  7:11     ` Balbir Singh
2016-05-11  9:22     ` [PATCH v2] " Oliver O'Halloran
2016-06-21  0:40       ` [v2] " Michael Ellerman
2016-05-10 21:48 ` [v2,1/2] powerpc/mm: define TOP_ZONE as a constant Michael Ellerman

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).