Skip to contentSkip to conversation

ARM: Only initialize max_mapnr when using flatmem

PATCH New Michael Spang 2 participants 3 messages Oct 22, 2012 – Apr 3, 2013 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: Only initialize max_mapnr when using flatmem

The expression used to initialize max_mapnr is not appropriate for sparsemem, since mem_map is NULL and pfn_to_page() only works on valid pages. This patch leaves max_mapnr uninitialized for sparsemem.

For flatmem, the expression simplifies to copying max_pfn.

---
 arch/arm/mm/init.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

I'm not sure we need this variable it all - it looks like there are no users.

arch/arm/mm/init.c +3 -1
index c21d06c..9b72e6f 100644
@@ -600,7 +600,9 @@ void __init mem_init(void)
 	extern u32 itcm_end;
 #endif
 
-	max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
+#ifdef CONFIG_FLATMEM
+	max_mapnr = max_pfn;
+#endif
 
 	/* this will put all unused low memory onto the freelists */
 	free_unused_memmap(&meminfo);
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 1/1 ARM: Only initialize max_mapnr when using flatmem

Quoted 6 lines · Michael Spang

The expression used to initialize max_mapnr is not appropriate for sparsemem, since mem_map is NULL and pfn_to_page() only works on valid pages. This patch leaves max_mapnr uninitialized for sparsemem.

For flatmem, the expression simplifies to copying max_pfn.

Quoted 7 lines
---
 arch/arm/mm/init.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

I'm not sure we need this variable it all - it looks like there are no users.

Indeed, I've just confirmed that. I suggest we just get rid of it instead, like this:

 arch/arm/mm/init.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
arch/arm/mm/init.c +5 -1
index ad722f1..bd93bdc 100644
@@ -600,7 +600,11 @@ void __init mem_init(void)
 	extern u32 itcm_end;
 #endif
 
-	max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
+	/*
+	 * We used to initialize max_mapnr here to be the same as max_pfn,
+	 * but as nothing uses it (we don't use the generic pfn_valid())
+	 * this has become unnecessary.
+	 */
 
 	/* this will put all unused low memory onto the freelists */
 	free_unused_memmap(&meminfo);
#2 lore raw

PATCH 1/1 ARM: Only initialize max_mapnr when using flatmem

Quoted 29 lines · Russell King - ARM Linux
Quoted 6 lines · Michael Spang

The expression used to initialize max_mapnr is not appropriate for sparsemem, since mem_map is NULL and pfn_to_page() only works on valid pages. This patch leaves max_mapnr uninitialized for sparsemem.

For flatmem, the expression simplifies to copying max_pfn.

Quoted 7 lines
---
 arch/arm/mm/init.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

I'm not sure we need this variable it all - it looks like there are no users.

Indeed, I've just confirmed that. I suggest we just get rid of it instead, like this:

 arch/arm/mm/init.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
arch/arm/mm/init.c +0 -0
index ad722f1..bd93bdc 100644
@@ -600,7 +600,11 @@ void __init mem_init(void)
 	extern u32 itcm_end;
 #endif

arch/arm/mm/init.c void __init mem_init(void) · line 610

Quoted 10 lines
arch/arm/mm/init.c +5 -1
 
-	max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
+	/*
+	 * We used to initialize max_mapnr here to be the same as max_pfn,
+	 * but as nothing uses it (we don't use the generic pfn_valid())
+	 * this has become unnecessary.
+	 */
 
 	/* this will put all unused low memory onto the freelists */
 	free_unused_memmap(&meminfo);

I notice there wasn't a response to this, and the patch is in the patch system. I'm going to discard that patch now, and assume that this issue is dead. Thanks.