Skip to contentSkip to conversation

max_mapnr config option

PATCH In review Andy Whitcroft 3 participants 12 messages Apr 10, 2008 – Jun 2, 2008 4 messages not in the archive

Subsystems (7)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · Dave Hansen

Hey Andy,

Take a look at include/linux/mm.h:

Quoted 8 lines

#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */
extern unsigned long max_mapnr;
#endif

Shouldn't that be #ifdef CONFIG_FLATMEM?

I don't think it is causing any problems since all references to max_mapnr are under FLATMEM ifdefs, but for correctness...

Ok, I did a comprehensive review of all the references, both to max_mapnr and to mem_map which are both inherently FLATMEM specific variables. It seems that there are actually a fair number of references which are under inappropriate defines. Generally this is the use of !DISCONTIGMEM on architectures which only support FLATMEM and DISCONTIGMEM. There are also a number of unused constructs which can just go.

The biggest offenders of this are the show_mem implementations, but it seems that Johannes (copied) is sorting that mess out; clearly one implemenation is needed. Johannes, I have some changes to that series which came out of my implementation of the same which I will send your way separatly.

Following this email is a set of patches which fix the problems I have found. Obviously these are all over the architecture map, and so will probabally need feeding back via those trees individually.

-apw

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

#2 lore raw

PATCH 1/8 alpha: mem_map/max_mapnr -- init is FLATMEM use correct defines

The alpha init.c implementation of mem_init is specifically a FLATMEM implementation, use the correct config option.

---
 arch/alpha/mm/init.c        |    4 ++--
 include/asm-alpha/mmzone.h  |    2 --
 include/asm-alpha/pgtable.h |    4 ++--
 3 files changed, 4 insertions(+), 6 deletions(-)
arch/alpha/mm/init.c +2 -2
index 234e42b..9a4e669 100644
@@ -277,7 +277,7 @@ srm_paging_stop (void)
 }
 #endif
 
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_FLATMEM
 static void __init
 printk_memory_info(void)
 {
@@ -317,7 +317,7 @@ mem_init(void)
 
 	printk_memory_info();
 }
-#endif /* CONFIG_DISCONTIGMEM */
+#endif /* CONFIG_FLATMEM */
 
 void
 free_reserved_mem(void *start, void *end)
include/asm-alpha/mmzone.h +0 -2
index 8af56ce..8bfb3b2 100644
@@ -72,8 +72,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
 
 #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
 
-#define VALID_PAGE(page)	(((page) - mem_map) < max_mapnr)
-
 #define pmd_page(pmd)		(pfn_to_page(pmd_val(pmd) >> 32))
 #define pgd_page(pgd)		(pfn_to_page(pgd_val(pgd) >> 32))
 #define pte_pfn(pte)		(pte_val(pte) >> 32)
include/asm-alpha/pgtable.h +2 -2
index 99037b0..665ba5c 100644
@@ -202,7 +202,7 @@ extern unsigned long __zero_page(void);
  * Conversion functions:  convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
  */
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_FLATMEM
 #define page_to_pa(page)	(((page) - mem_map) << PAGE_SHIFT)
 
 #define pte_pfn(pte)	(pte_val(pte) >> 32)
@@ -235,7 +235,7 @@ pmd_page_vaddr(pmd_t pmd)
 	return ((pmd_val(pmd) & _PFN_MASK) >> (32-PAGE_SHIFT)) + PAGE_OFFSET;
 }
 
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_FLATMEM
 #define pmd_page(pmd)	(mem_map + ((pmd_val(pmd) & _PFN_MASK) >> 32))
 #define pgd_page(pgd)	(mem_map + ((pgd_val(pgd) & _PFN_MASK) >> 32))
 #endif

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

#3 lore raw

PATCH 2/8 arm: mem_map/max_mapnr -- init is FLATMEM use correct defines

In reply to Andy Whitcroft

The initialisation of max_mapnr is only valid if the memory model is FLATMEM, use the appropriate define.

---
 arch/arm/mm/init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mm/init.c +1 -1
index b657f17..e414e83 100644
@@ -426,7 +426,7 @@ void __init mem_init(void)
 	datapages = &_end - &__data_start;
 	initpages = &__init_end - &__init_begin;
 
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_FLATMEM
 	max_mapnr   = virt_to_page(high_memory) - mem_map;
 #endif
 

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

#4 lore raw

PATCH 3/8 m32r: mem_map/max_mapnr -- definition is specific to FLATMEM

In reply to Andy Whitcroft

The max_mapnr variable is only used FLATMEM memory model, use the appropriate defines.

---
 arch/m32r/mm/init.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/m32r/mm/init.c +2 -2
index 2a3e8b5..f4a614f 100644
@@ -148,9 +148,9 @@ void __init mem_init(void)
 
 	num_physpages -= hole_pages;
 
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_FLATMEM
 	max_mapnr = num_physpages;
-#endif	/* CONFIG_DISCONTIGMEM */
+#endif	/* CONFIG_FLATMEM */
 
 #ifdef CONFIG_MMU
 	high_memory = (void *)__va(PFN_PHYS(MAX_LOW_PFN(0)));

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

#5 lore raw

PATCH 4/8 mips: mem_map/max_mapnr -- definition is specific to FLATMEM

In reply to Andy Whitcroft

The max_mapnr variable is only used FLATMEM memory model, use the appropriate defines.

---
 arch/mips/mm/init.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
arch/mips/mm/init.c +6 -3
index c7aed13..68c90b5 100644
@@ -389,19 +389,22 @@ static struct kcore_list kcore_mem, kcore_vmalloc;
 static struct kcore_list kcore_kseg0;
 #endif
 
+#if defined(CONFIG_HIGHMEM) && defined(CONFIG_DISCONTIGMEM)
+#error "CONFIG_HIGHMEM and CONFIG_DISCONTIGMEM dont work together yet"
+#endif
+
 void __init mem_init(void)
 {
 	unsigned long codesize, reservedpages, datasize, initsize;
 	unsigned long tmp, ram;
 
+#ifdef CONFIG_FLATMEM
 #ifdef CONFIG_HIGHMEM
-#ifdef CONFIG_DISCONTIGMEM
-#error "CONFIG_HIGHMEM and CONFIG_DISCONTIGMEM dont work together yet"
-#endif
 	max_mapnr = highend_pfn;
 #else
 	max_mapnr = max_low_pfn;
 #endif
+#endif
 	high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 
 	totalram_pages += free_all_bootmem();

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

#6 lore raw

PATCH 5/8 parisc: mem_map/max_mapnr -- definition is specific to FLATMEM

In reply to Andy Whitcroft

The max_mapnr variable is only used FLATMEM memory model, use the appropriate defines.

---
 arch/parisc/mm/init.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
arch/parisc/mm/init.c +3 -2
index 2c721e1..bd300d1 100644
@@ -461,10 +461,11 @@ void __init mem_init(void)
 
 	high_memory = __va((max_pfn << PAGE_SHIFT));
 
-#ifndef CONFIG_DISCONTIGMEM
+#ifdef CONFIG_FLATMEM
 	max_mapnr = page_to_pfn(virt_to_page(high_memory - 1)) + 1;
 	totalram_pages += free_all_bootmem();
-#else
+#endif
+#ifdef CONFIG_DISCONTIGMEM
 	{
 		int i;
 

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

#7 lore raw

PATCH 6/8 powerpc: mem_map/max_mapnr -- definition is specific to FLATMEM

In reply to Andy Whitcroft

The max_mapnr variable is only used FLATMEM memory model, use the appropriate defines. Note that HIGHMEM is only valid on PPC32, and that only supports FLATMEM.

---
 arch/powerpc/mm/mem.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/mm/mem.c +5 -3
index fcbae37..09d275e 100644
@@ -319,9 +319,11 @@ void __init mem_init(void)
 		}
 	}
 #else
-	max_mapnr = max_pfn;
 	totalram_pages += free_all_bootmem();
 #endif
+#ifdef CONFIG_FLATMEM
+	max_mapnr = max_pfn;
+#endif
 	for_each_online_pgdat(pgdat) {
 		for (i = 0; i < pgdat->node_spanned_pages; i++) {
 			if (!pfn_valid(pgdat->node_start_pfn + i))
@@ -337,7 +339,7 @@ void __init mem_init(void)
 	initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
 	bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
 
-#ifdef CONFIG_HIGHMEM
+#if defined(CONFIG_FLATMEM) && defined(CONFIG_HIGHMEM)
 	{
 		unsigned long pfn, highmem_mapnr;
 
@@ -356,7 +358,7 @@ void __init mem_init(void)
 		printk(KERN_DEBUG "High memory: %luk\n",
 		       totalhigh_pages << (PAGE_SHIFT-10));
 	}
-#endif /* CONFIG_HIGHMEM */
+#endif /* CONFIG_FLATMEM/CONFIG_HIGHMEM */
 
 	printk(KERN_INFO "Memory: %luk/%luk available (%luk kernel code, "
 	       "%luk reserved, %luk data, %luk bss, %luk init)\n",

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

#8 lore raw

PATCH 7/8 sparc64: mem_map/max_mapnr -- definition is specific to FLATMEM

In reply to Andy Whitcroft

The max_mapnr variable is only used FLATMEM memory model, as sparc64 only supports SPARSEMEM this variable is redundant.

---
 arch/sparc64/mm/init.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
arch/sparc64/mm/init.c +0 -2
index f6a86a2..c218134 100644
@@ -1330,8 +1330,6 @@ void __init paging_init(void)
 	pages_avail = 0;
 	last_valid_pfn = end_pfn = bootmem_init(&pages_avail, phys_base);
 
-	max_mapnr = last_valid_pfn;
-
 	kernel_physical_mapping_init();
 
 	real_setup_per_cpu_areas();

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

#9 lore raw

PATCH 8/8 mem_map/max_mapnr are specific to the FLATMEM memory model

In reply to Andy Whitcroft

mem_map and max_mapnr are variables used in the FLATMEM memory model only. Ensure they are only defined when that memory model is enabled.

---
 mm/memory.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
mm/memory.c +1 -2
index 0d14d1e..091324e 100644
@@ -61,8 +61,7 @@
 #include <linux/swapops.h>
 #include <linux/elf.h>
 
-#ifndef CONFIG_NEED_MULTIPLE_NODES
-/* use the per-pgdat data instead for discontigmem - mbligh */
+#ifdef CONFIG_FLATMEM
 unsigned long max_mapnr;
 struct page *mem_map;
 

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

#10 lore raw

Re: [PATCH 8/8] mem_map/max_mapnr are specific to the FLATMEM memory model

Quoted 3 lines · Andy Whitcroft

mem_map and max_mapnr are variables used in the FLATMEM memory model only. Ensure they are only defined when that memory model is enabled.

Is this series queued to be applied?

BTW, how does max_mapnr differ from x86-64's end_pfn?

Quoted 4 lines
---
 mm/memory.c |    3 +--

I think you need to fix the declaration in linux/mm.h as well.

Quoted 7 lines
 1 files changed, 1 insertions(+), 2 deletions(-)
mm/memory.c +0 -0
index 0d14d1e..091324e 100644

mm/memory.c line 67

Quoted 9 lines
mm/memory.c +1 -2
@@ -61,8 +61,7 @@
 #include <linux/swapops.h>
 #include <linux/elf.h>
 
-#ifndef CONFIG_NEED_MULTIPLE_NODES
-/* use the per-pgdat data instead for discontigmem - mbligh */
+#ifdef CONFIG_FLATMEM
 unsigned long max_mapnr;
 struct page *mem_map;
 

Thanks,
J

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw
Quoted 11 lines · Andy Whitcroft
Quoted 10 lines · Johannes Weiner

Hi,

Quoted 5 lines · Andy Whitcroft

BUT. Looking over the actual references, there is a lot of references occuring out of show_mem implementations in the arches which may well break unless they follow suit. We also don't have any show_mem implementation for sparsemem. I will have a look at what can be trivially cleaned up here.

Quoted 4 lines
Quoted 1 line

Perhaps you might be interested in http://lkml.org/lkml/2008/4/4/ .

How annoying is that, you have done the same thing I've just done. I'll look at your version and base off that.

Whatever happened to this series. I don't see it committed anywhere. Do you have a latest stack I could rebase my max_mapnr fixes off?

-apw

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

#15 lore raw

Hi,

Quoted 12 lines · [email protected] writes:
Quoted 11 lines · Andy Whitcroft
Quoted 10 lines · Johannes Weiner

Hi,

Quoted 5 lines · Andy Whitcroft

BUT. Looking over the actual references, there is a lot of references occuring out of show_mem implementations in the arches which may well break unless they follow suit. We also don't have any show_mem implementation for sparsemem. I will have a look at what can be trivially cleaned up here.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Perhaps you might be interested in http://lkml.org/lkml/2008/4/4/ .

How annoying is that, you have done the same thing I've just done. I'll look at your version and base off that.

Whatever happened to this series. I don't see it committed anywhere. Do you have a latest stack I could rebase my max_mapnr fixes off?

I rebased it against Linus' current tree. Not all parts of the `remove redundant output of free swap space' series have yet trickled into upstream, so what I give you includes that (it is minimal and should have been part of this series in the first place).

When all of the previous series hit mainline I will repost this one.

Here is the quilt series:

http://saeurebad.de/patches/generic-show_mem.tar

or unpacked without the `.tar'-suffix.

Hannes

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