Skip to contentSkip to conversation

Reduce MAX_NR_ZONES and remove useless zones.

RFC In review Christoph Lameter 7 participants 32 messages Jul 3, 2006 – Jul 5, 2006

Subsystems (11)
lore
Share & tools
lore
#0 lore raw

cover Reduce MAX_NR_ZONES and remove useless zones.

I keep seeing zones on various platforms that are never used and wonder why we compile support for them into the kernel.

IA64 on SGI for example only uses ZONE_DMA other IA64 platforms can also use ZONE_NORMAL. So we have 50% useless zones. Large amounts of memory go to waste with systems with a few hundred nodes and a few hundred processors.

My x86_64 system seems to only use ZONE_DMA and ZONE_DMA32. I never see pages in ZONE_NORMAL (probably because I have less than 4G memory).

And ZONE_HIGHMEM on a 64 bit system? We can address all memory. I keep seeing all the highmem counters as zero on ia64 and x86_64 and even on i386 systems.

Then it seems that ZONE_DMA32 is only used on x86_64 but we compile it into the kernel for all platforms.

This patch makes ZONE_DMA32 and ZONE_HIGHMEM support optional. MAX_NR_ZONES will be 2 for most non i386 platforms and even for i386 without CONFIG_HIGHMEM set.

I tested this on IA64 and x86_64. Compiles fine on i386 with and without CONFIG_HIGHMEM set.

The patchset consists of 8 patches that are following this message.

One could go even further than this patchset and also make ZONE_DMA optional because some platforms do not need a separate DMA zone and can do DMA to all of memory. This could reduce MAX_NR_ZONES to 1.

#1 lore raw

RFC 1/8 Rework mmzone.h: Make DMA32 and HIGHMEM optional

Get rid of ZONE_HIGHMEM and ZONE_DMA32 for arches that do not need them.

This patch gets rid of both zones if an arch does not use them. Most 64 bit arches do not use ZONE_HIGHMEM and only x86_64 uses ZONE_DMA32. So 64 bit arches other than x86_64 will only need 2 zones instead of 4.

With this patch both zones will not be defined. Test operations on the zones will not do anything but simply return false so that code is not compiled that first checks if a zone is of this type.

This patch introduces CONFIG_ZONE_DMA32 that must be defined by an arch to get the ZONE_DMA32 zone defined. The CONFIG_DMA_IS_DMA32 and the CONFIG_DMA_IS_NORMAL hack used by IA64 to sort out what DMA32 means if there is no DMA32 zone is removed.

include/linux/mmzone.h +60 -16
Index: linux-2.6.17-mm6/include/linux/mmzone.h
===================================================================
@@ -87,15 +87,57 @@ struct per_cpu_pageset {
 #define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)])
 #endif
 
-#define ZONE_DMA		0
-#define ZONE_DMA32		1
-#define ZONE_NORMAL		2
-#define ZONE_HIGHMEM		3
+typedef enum {
+	/*
+	 * ZONE_DMA is used when there are devices that are not able
+	 * to do DMA to all of addressable memory (ZONE_NORMAL). Then we
+	 * carve out the portion of memory that is needed for these devices.
+	 * The range is arch specific.
+	 *
+	 * Some examples
+	 *
+	 * Architecture		Limit
+	 * ---------------------------
+	 * parisc, ia64, sparc	<4G
+	 * s390			<2G
+	 * arm26		<48M
+	 * arm			Various
+	 * alpha		Unlimited or 0-16MB.
+	 *
+	 * i386, x86_64 and multiple other arches
+	 * 			<16M.
+	 */
+	ZONE_DMA,
+#ifdef CONFIG_ZONE_DMA32
+	/*
+	 * x86_64 needs two ZONE_DMAs because it supports devices that are
+	 * only able to do DMA to the lower 16M but also 32 bit devices that
+	 * can only do DMA to the lower 4G.
+	 */
+	ZONE_DMA32,
+#endif
+	/*
+	 * Normal addressable memory is in ZONE_NORMAL. DMA operations can be
+	 * performed on pages in ZONE_NORMAL if the DMA devices support
+	 * transfers to all addressable memory.
+	 */
+	ZONE_NORMAL,
+#ifdef CONFIG_HIGHMEM
+	/*
+	 * A memory area that is only addressable by the kernel through
+	 * mapping portions into its own address space. This is for example
+	 * used by i386 to allow the kernel to address the memory beyond
+	 * 4G. The kernel will set up special mappings (page
+	 * table entries on i386) for each page that the kernel needs to
+	 * access.
+	 */
+	ZONE_HIGHMEM,
+#endif
+	MAX_NR_ZONES
+} zones_t;
 
-#define MAX_NR_ZONES		4	/* Sync this with ZONES_SHIFT */
 #define ZONES_SHIFT		2	/* ceil(log2(MAX_NR_ZONES)) */
 
-
 /*
  * When a memory allocation must conform to specific limitations (such
  * as being suitable for DMA) the caller will pass in hints to the
@@ -125,16 +167,6 @@ struct per_cpu_pageset {
 /* #define GFP_ZONETYPES       (GFP_ZONEMASK + 1) */           /* Non-loner */
 #define GFP_ZONETYPES  ((GFP_ZONEMASK + 1) / 2 + 1)            /* Loner */
 
-/*
- * On machines where it is needed (eg PCs) we divide physical memory
- * into multiple physical zones. On a 32bit PC we have 4 zones:
- *
- * ZONE_DMA	  < 16 MB	ISA DMA capable memory
- * ZONE_DMA32	     0 MB 	Empty
- * ZONE_NORMAL	16-896 MB	direct mapped by the kernel
- * ZONE_HIGHMEM	 > 896 MB	only page cache and user processes
- */
-
 struct zone {
 	/* Fields commonly accessed by the page allocator */
 	unsigned long		free_pages;
@@ -380,7 +412,11 @@ static inline int populated_zone(struct 
 
 static inline int is_highmem_idx(int idx)
 {
+#ifdef CONFIG_HIGHMEM
 	return (idx == ZONE_HIGHMEM);
+#else
+	return 0;
+#endif
 }
 
 static inline int is_normal_idx(int idx)
@@ -396,7 +432,11 @@ static inline int is_normal_idx(int idx)
  */
 static inline int is_highmem(struct zone *zone)
 {
+#ifdef CONFIG_HIGHMEM
 	return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM;
+#else
+	return 0;
+#endif
 }
 
 static inline int is_normal(struct zone *zone)
@@ -406,7 +446,11 @@ static inline int is_normal(struct zone 
 
 static inline int is_dma32(struct zone *zone)
 {
+#ifdef CONFIG_ZONE_DMA32
 	return zone == zone->zone_pgdat->node_zones + ZONE_DMA32;
+#else
+	return 0;
+#endif
 }
 
 static inline int is_dma(struct zone *zone)
mm/page_alloc.c +37 -13

94 lines not on this page · raw message

include/linux/gfp.h +4 -3
Index: linux-2.6.17-mm6/include/linux/gfp.h
===================================================================
@@ -13,12 +13,13 @@ struct vm_area_struct;
 /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */
 #define __GFP_DMA	((__force gfp_t)0x01u)
 #define __GFP_HIGHMEM	((__force gfp_t)0x02u)
-#ifdef CONFIG_DMA_IS_DMA32
-#define __GFP_DMA32	((__force gfp_t)0x01)	/* ZONE_DMA is ZONE_DMA32 */
+
+#ifdef CONFIG_ZONE_DMA32
+#define __GFP_DMA32	((__force gfp_t)0x04)	/* Has own ZONE_DMA32 */
 #elif BITS_PER_LONG < 64
 #define __GFP_DMA32	((__force gfp_t)0x00)	/* ZONE_NORMAL is ZONE_DMA32 */
 #else
-#define __GFP_DMA32	((__force gfp_t)0x04)	/* Has own ZONE_DMA32 */
+#define __GFP_DMA32	((__force gfp_t)0x01)	/* ZONE_DMA is ZONE_DMA32 */
 #endif
 
 /*
arch/x86_64/Kconfig +4 -0
Index: linux-2.6.17-mm6/arch/x86_64/Kconfig
===================================================================
@@ -73,6 +73,10 @@ config GENERIC_ISA_DMA
 	bool
 	default y
 
+config ZONE_DMA32
+	bool
+	default y
+
 config GENERIC_IOMAP
 	bool
 	default y
arch/ia64/Kconfig +0 -9
Index: linux-2.6.17-mm6/arch/ia64/Kconfig
===================================================================
@@ -66,15 +66,6 @@ config IA64_UNCACHED_ALLOCATOR
 	bool
 	select GENERIC_ALLOCATOR
 
-config DMA_IS_DMA32
-	bool
-	default y
-
-config DMA_IS_NORMAL
-	bool
-	depends on IA64_SGI_SN2
-	default y
-
 choice
 	prompt "System type"
 	default IA64_GENERIC
include/linux/vmstat.h +3 -5
Index: linux-2.6.17-mm6/include/linux/vmstat.h
===================================================================
@@ -124,16 +124,14 @@ static inline unsigned long node_page_st
 	struct zone *zones = NODE_DATA(node)->node_zones;
 
 	return
-#ifndef CONFIG_DMA_IS_NORMAL
-#if !defined(CONFIG_DMA_IS_DMA32) && BITS_PER_LONG >= 64
+		zone_page_state(&zones[ZONE_DMA], item) +
+#ifdef CONFIG_ZONE_DMA32
 		zone_page_state(&zones[ZONE_DMA32], item) +
 #endif
-		zone_page_state(&zones[ZONE_NORMAL], item) +
-#endif
 #ifdef CONFIG_HIGHMEM
 		zone_page_state(&zones[ZONE_HIGHMEM], item) +
 #endif
-		zone_page_state(&zones[ZONE_DMA], item);
+		zone_page_state(&zones[ZONE_NORMAL], item);
 }
 
 extern void zone_statistics(struct zonelist *, struct zone *);
#2 lore raw

Re: [RFC 1/8] Rework mmzone.h: Make DMA32 and HIGHMEM optional

include/linux/mmzone.h struct per_cpu_pageset {

Quoted 6 lines · Christoph Lameter
include/linux/mmzone.h +6 -0
+#ifdef CONFIG_HIGHMEM
+	/*
+	 * A memory area that is only addressable by the kernel through
+	 * mapping portions into its own address space. This is for example
+	 * used by i386 to allow the kernel to address the memory beyond
+	 * 4G. 

s/4G/900MB/

Rest of the patch looks fine.

-Andi

#3 lore raw

RFC 2/8 Make display of highmem counters conditional on CONFIG_HIGHMEM

In reply to Christoph Lameter

Change HIGHMEM dependent texts and make display of highmem counters optional

Some texts are depending on CONFIG_HIGHMEM.

Remove those strings and remove the display of zero highmem values if CONFIG_HIGHMEM is not set.

drivers/base/node.c +4 -0
Index: linux-2.6.17-mm6/drivers/base/node.c
===================================================================
@@ -54,10 +54,12 @@ static ssize_t node_read_meminfo(struct 
 		       "Node %d MemUsed:      %8lu kB\n"
 		       "Node %d Active:       %8lu kB\n"
 		       "Node %d Inactive:     %8lu kB\n"
+#ifdef CONFIG_HIGHMEM
 		       "Node %d HighTotal:    %8lu kB\n"
 		       "Node %d HighFree:     %8lu kB\n"
 		       "Node %d LowTotal:     %8lu kB\n"
 		       "Node %d LowFree:      %8lu kB\n"
+#endif
 		       "Node %d Dirty:        %8lu kB\n"
 		       "Node %d Writeback:    %8lu kB\n"
 		       "Node %d FilePages:    %8lu kB\n"
@@ -72,10 +74,12 @@ static ssize_t node_read_meminfo(struct 
 		       nid, K(i.totalram - i.freeram),
 		       nid, K(active),
 		       nid, K(inactive),
+#ifdef CONFIG_HIGHMEM
 		       nid, K(i.totalhigh),
 		       nid, K(i.freehigh),
 		       nid, K(i.totalram - i.totalhigh),
 		       nid, K(i.freeram - i.freehigh),
+#endif
 		       nid, K(node_page_state(nid, NR_FILE_DIRTY)),
 		       nid, K(node_page_state(nid, NR_WRITEBACK)),
 		       nid, K(node_page_state(nid, NR_FILE_PAGES)),
fs/proc/proc_misc.c +4 -0
Index: linux-2.6.17-mm6/fs/proc/proc_misc.c
===================================================================
@@ -157,10 +157,12 @@ static int meminfo_read_proc(char *page,
 		"SwapCached:   %8lu kB\n"
 		"Active:       %8lu kB\n"
 		"Inactive:     %8lu kB\n"
+#ifdef CONFIG_HIGHMEM
 		"HighTotal:    %8lu kB\n"
 		"HighFree:     %8lu kB\n"
 		"LowTotal:     %8lu kB\n"
 		"LowFree:      %8lu kB\n"
+#endif
 		"SwapTotal:    %8lu kB\n"
 		"SwapFree:     %8lu kB\n"
 		"Dirty:        %8lu kB\n"
@@ -183,10 +185,12 @@ static int meminfo_read_proc(char *page,
 		K(total_swapcache_pages),
 		K(active),
 		K(inactive),
+#ifdef CONFIG_HIGHMEM
 		K(i.totalhigh),
 		K(i.freehigh),
 		K(i.totalram-i.totalhigh),
 		K(i.freeram-i.freehigh),
+#endif
 		K(i.totalswap),
 		K(i.freeswap),
 		K(global_page_state(NR_FILE_DIRTY)),
mm/page_alloc.c +4 -0
Index: linux-2.6.17-mm6/mm/page_alloc.c
===================================================================
@@ -1394,9 +1394,13 @@ void show_free_areas(void)
 
 	get_zone_counts(&active, &inactive, &free);
 
+#ifdef CONFIG_HIGHMEM
 	printk("Free pages: %11ukB (%ukB HighMem)\n",
 		K(nr_free_pages()),
 		K(nr_free_highpages()));
+#else
+	printk("Free pages: %11ukB\n", K(nr_free_pages()));
+#endif
 
 	printk("Active:%lu inactive:%lu dirty:%lu writeback:%lu "
 		"unstable:%lu free:%u slab:%lu mapped:%lu pagetables:%lu\n",
#4 lore raw

RFC 3/8 Move HIGHMEM counter into highmem.c/.h

In reply to Christoph Lameter

Move highmem counters into highmem.c/.h

Move the totalhigh_pages definition into highmem.c/.h

include/linux/highmem.h +3 -0
Index: linux-2.6.17-mm6/include/linux/highmem.h
===================================================================
@@ -24,11 +24,14 @@ static inline void flush_kernel_dcache_p
 
 /* declarations for linux/mm/highmem.c */
 unsigned int nr_free_highpages(void);
+extern unsigned long totalhigh_pages;
 
 #else /* CONFIG_HIGHMEM */
 
 static inline unsigned int nr_free_highpages(void) { return 0; }
 
+#define totalhigh_pages 0
+
 static inline void *kmap(struct page *page)
 {
 	might_sleep();
include/linux/swap.h +0 -1
Index: linux-2.6.17-mm6/include/linux/swap.h
===================================================================
@@ -162,7 +162,6 @@ extern void swapin_readahead(swp_entry_t
 
 /* linux/mm/page_alloc.c */
 extern unsigned long totalram_pages;
-extern unsigned long totalhigh_pages;
 extern unsigned long totalreserve_pages;
 extern long nr_swap_pages;
 extern unsigned int nr_free_pages(void);
mm/page_alloc.c +0 -1
Index: linux-2.6.17-mm6/mm/page_alloc.c
===================================================================
@@ -51,7 +51,6 @@ EXPORT_SYMBOL(node_online_map);
 nodemask_t node_possible_map __read_mostly = NODE_MASK_ALL;
 EXPORT_SYMBOL(node_possible_map);
 unsigned long totalram_pages __read_mostly;
-unsigned long totalhigh_pages __read_mostly;
 unsigned long totalreserve_pages __read_mostly;
 long nr_swap_pages;
 int percpu_pagelist_fraction;
mm/shmem.c +1 -0
Index: linux-2.6.17-mm6/mm/shmem.c
===================================================================
@@ -45,6 +45,7 @@
 #include <linux/namei.h>
 #include <linux/ctype.h>
 #include <linux/migrate.h>
+#include <linux/highmem.h>
 
 #include <asm/uaccess.h>
 #include <asm/div64.h>
mm/highmem.c +1 -0
Index: linux-2.6.17-mm6/mm/highmem.c
===================================================================
@@ -46,6 +46,7 @@ static void *mempool_alloc_pages_isa(gfp
  */
 #ifdef CONFIG_HIGHMEM
 
+unsigned long totalhigh_pages __read_mostly;
 static int pkmap_count[LAST_PKMAP];
 static unsigned int last_pkmap_nr;
 static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(kmap_lock);
#5 lore raw

Re: [RFC 3/8] Move HIGHMEM counter into highmem.c/.h

Quoted 4 lines · On Mon, 3 Jul 2006 14:55:50 -0700 (PDT) Christoph Lameter <[email protected]>…

Move highmem counters into highmem.c/.h

Move the totalhigh_pages definition into highmem.c/.h

Hi, I love this patch series :)

I found this :
== arch/um/kernel/mem.c ==

void mem_init(void)
{
<snip>
totalhigh_pages = highmem >> PAGE_SHIFT;
....
==
this should be covered by CONFIG_HIGHMEM if you change totalhigh_pages to be #define.

Regards,
-Kame

Quoted 75 lines

Index: linux-2.6.17-mm6/include/linux/highmem.h
===================================================================

include/linux/highmem.h +3 -0
@@ -24,11 +24,14 @@ static inline void flush_kernel_dcache_p
 
 /* declarations for linux/mm/highmem.c */
 unsigned int nr_free_highpages(void);
+extern unsigned long totalhigh_pages;
 
 #else /* CONFIG_HIGHMEM */
 
 static inline unsigned int nr_free_highpages(void) { return 0; }
 
+#define totalhigh_pages 0
+
 static inline void *kmap(struct page *page)
 {
 	might_sleep();

Index: linux-2.6.17-mm6/include/linux/swap.h
===================================================================

include/linux/swap.h +0 -1
@@ -162,7 +162,6 @@ extern void swapin_readahead(swp_entry_t
 
 /* linux/mm/page_alloc.c */
 extern unsigned long totalram_pages;
-extern unsigned long totalhigh_pages;
 extern unsigned long totalreserve_pages;
 extern long nr_swap_pages;
 extern unsigned int nr_free_pages(void);

Index: linux-2.6.17-mm6/mm/page_alloc.c
===================================================================

mm/page_alloc.c +0 -1
@@ -51,7 +51,6 @@ EXPORT_SYMBOL(node_online_map);
 nodemask_t node_possible_map __read_mostly = NODE_MASK_ALL;
 EXPORT_SYMBOL(node_possible_map);
 unsigned long totalram_pages __read_mostly;
-unsigned long totalhigh_pages __read_mostly;
 unsigned long totalreserve_pages __read_mostly;
 long nr_swap_pages;
 int percpu_pagelist_fraction;

Index: linux-2.6.17-mm6/mm/shmem.c
===================================================================

mm/shmem.c +1 -0
@@ -45,6 +45,7 @@
 #include <linux/namei.h>
 #include <linux/ctype.h>
 #include <linux/migrate.h>
+#include <linux/highmem.h>
 
 #include <asm/uaccess.h>
 #include <asm/div64.h>

Index: linux-2.6.17-mm6/mm/highmem.c
===================================================================

mm/highmem.c +1 -1
@@ -46,6 +46,7 @@ static void *mempool_alloc_pages_isa(gfp
  */
 #ifdef CONFIG_HIGHMEM
 
+unsigned long totalhigh_pages __read_mostly;
 static int pkmap_count[LAST_PKMAP];
 static unsigned int last_pkmap_nr;
 static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(kmap_lock);
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#6 lore raw

Re: [RFC 3/8] Move HIGHMEM counter into highmem.c/.h

Quoted 1 line · KAMEZAWA Hiroyuki

Hi, I love this patch series :)

Thanks.

Quoted 11 lines

I found this :
== arch/um/kernel/mem.c ==

void mem_init(void)
{
<snip>
totalhigh_pages = highmem >> PAGE_SHIFT;
....
==
this should be covered by CONFIG_HIGHMEM if you change totalhigh_pages to be #define.

Ok. Will put a #ifdef CONFIG_HIGHMEM around that statement and the following one.

#7 lore raw

Re: [RFC 3/8] Move HIGHMEM counter into highmem.c/.h

Quoted 5 lines · On Mon, 3 Jul 2006 22:56:36 -0700 (PDT) Christoph Lameter <[email protected]>…
Quoted 2 lines

this should be covered by CONFIG_HIGHMEM if you change totalhigh_pages to be #define.

Ok. Will put a #ifdef CONFIG_HIGHMEM around that statement and the following one.

That will take the patchset up to 27 new ifdefs. Is there a way of improving that?

#8 lore raw

Re: [RFC 3/8] Move HIGHMEM counter into highmem.c/.h

Quoted 5 lines · Andrew Morton
Quoted 2 lines

Ok. Will put a #ifdef CONFIG_HIGHMEM around that statement and the following one.

That will take the patchset up to 27 new ifdefs. Is there a way of improving that?

Ideas are welcome. I can put some of the tests for zones together into one big #ifdef in mmzone.h but otherwise this is going to be difficult.

#9 lore raw

Re: [RFC 3/8] Move HIGHMEM counter into highmem.c/.h

Quoted 11 lines · Christoph Lameter
Quoted 4 lines · Andrew Morton
Quoted 1 line

Ok. Will put a #ifdef CONFIG_HIGHMEM around that statement and the following one.

That will take the patchset up to 27 new ifdefs. Is there a way of improving that?

Ideas are welcome. I can put some of the tests for zones together into one big #ifdef in mmzone.h but otherwise this is going to be difficult.

I don't think there's much point. They all look pretty straightforward, and if you try doing something fancy it might just make it more fragile or harder to read.

Signature · 2 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 
#10 lore raw

Re: [RFC 3/8] Move HIGHMEM counter into highmem.c/.h

Quoted 11 lines · On Wed, 05 Jul 2006 02:50:32 +1000 Nick Piggin <[email protected]> wrote:
Quoted 10 lines · Christoph Lameter
Quoted 5 lines · Andrew Morton
Quoted 2 lines

Ok. Will put a #ifdef CONFIG_HIGHMEM around that statement and the following one.

That will take the patchset up to 27 new ifdefs. Is there a way of improving that?

Quoted 7 lines
Quoted 2 lines

Ideas are welcome. I can put some of the tests for zones together into one big #ifdef in mmzone.h but otherwise this is going to be difficult.

I don't think there's much point. They all look pretty straightforward, and if you try doing something fancy it might just make it more fragile or harder to read.

just one point.
I'm not sure dropping "printing HIGHMEM statistics" stuff is good or not. It is shown in /proc/meminfo even if CONFIG_HIGHMEM=n now. this will change look of user interface a bit. but maybe not so important ....

-Kame

#11 lore raw

RFC 4/8 Remove display of counters for not available zones

In reply to Christoph Lameter

eventcounters: Do not display counters for zones that are not available on an arch

Remove the counter display for all zones that are not in use.

include/linux/vmstat.h +11 -1
Index: linux-2.6.17-mm6/include/linux/vmstat.h
===================================================================
@@ -18,7 +18,17 @@
  * generated will simply be the increment of a global address.
  */
 
-#define FOR_ALL_ZONES(x) x##_DMA, x##_DMA32, x##_NORMAL, x##_HIGH
+#ifdef CONFIG_DMA32
+#define FOR_ALL_LOWER_ZONES(xx) xx##_DMA, xx##_DMA32, xx##_NORMAL
+#else
+#define FOR_ALL_LOWER_ZONES(xx) xx##_DMA, xx##_NORMAL
+#endif
+
+#ifdef CONFIG_HIGHMEM
+#define FOR_ALL_ZONES(xx) FOR_ALL_LOWER_ZONES(xx), xx##_HIGH
+#else
+#define FOR_ALL_ZONES(xx) FOR_ALL_LOWER_ZONES(xx)
+#endif
 
 enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		FOR_ALL_ZONES(PGALLOC),
mm/vmstat.c +17 -23
Index: linux-2.6.17-mm6/mm/vmstat.c
===================================================================
@@ -381,6 +381,18 @@ struct seq_operations fragmentation_op =
 	.show	= frag_show,
 };
 
+#ifdef CONFIG_ZONE_DMA32
+#define TEXTS_FOR_LOWER_ZONES(xx) xx "_dma", xx "_dma32", xx "_normal"
+#else
+#define TEXTS_FOR_LOWER_ZONES(xx) xx "_dma", xx "_normal"
+#endif
+
+#ifdef CONFIG_HIGHMEM
+#define TEXTS_FOR_ZONES(xx) TEXTS_FOR_LOWER_ZONES(xx), xx "_high"
+#else
+#define TEXTS_FOR_ZONES(xx) TEXTS_FOR_LOWER_ZONES(xx)
+#endif
+
 static char *vmstat_text[] = {
 	/* Zoned VM counters */
 	"nr_anon_pages",
@@ -408,10 +420,7 @@ static char *vmstat_text[] = {
 	"pswpin",
 	"pswpout",
 
-	"pgalloc_dma",
-	"pgalloc_dma32",
-	"pgalloc_normal",
-	"pgalloc_high",
+	TEXTS_FOR_ZONES("pgalloc"),
 
 	"pgfree",
 	"pgactivate",
@@ -420,25 +429,10 @@ static char *vmstat_text[] = {
 	"pgfault",
 	"pgmajfault",
 
-	"pgrefill_dma",
-	"pgrefill_dma32",
-	"pgrefill_normal",
-	"pgrefill_high",
-
-	"pgsteal_dma",
-	"pgsteal_dma32",
-	"pgsteal_normal",
-	"pgsteal_high",
-
-	"pgscan_kswapd_dma",
-	"pgscan_kswapd_dma32",
-	"pgscan_kswapd_normal",
-	"pgscan_kswapd_high",
-
-	"pgscan_direct_dma",
-	"pgscan_direct_dma32",
-	"pgscan_direct_normal",
-	"pgscan_direct_high",
+	TEXTS_FOR_ZONES("pgrefill"),
+	TEXTS_FOR_ZONES("pgsteal"),
+	TEXTS_FOR_ZONES("pgscan_kswapd"),
+	TEXTS_FOR_ZONES("pgscan_direct"),
 
 	"pginodesteal",
 	"slabs_scanned",
#12 lore raw

RFC 5/8 swap_prefetch: Make use of ZONE_HIGHMEM dependend on CONFIG_HIGHMEM

In reply to Christoph Lameter

swap_prefetch: Make use of ZONE_HIGHMEM conditional

swap prefetch uses ZONE_HIGHMEM even if CONFIG_HIGHMEM is off. Make that use conditional.

mm/swap_prefetch.c +4 -2
Index: linux-2.6.17/mm/swap_prefetch.c
===================================================================
@@ -277,8 +277,10 @@
 
 		ns = &sp_stat.node[z->zone_pgdat->node_id];
 		idx = zone_idx(z);
-		ns->lowfree[idx] = z->pages_high * 3 +
-			z->lowmem_reserve[ZONE_HIGHMEM];
+		ns->lowfree[idx] = z->pages_high * 3;
+#ifdef CONFIG_HIGHMEM
+		ns->lowfree[idx] += z->lowmem_reserve[ZONE_HIGHMEM];
+#endif
 		ns->highfree[idx] = ns->lowfree[idx] + z->pages_high;
 
 		if (z->free_pages > ns->highfree[idx]) {
#13 lore raw

RFC 6/8 Fix MAX_NR_ZONES array initializations in various arches

In reply to Christoph Lameter

Fix array initialization in lots of arches

The number of zones may now be reduced from 4 to 2 for many arches. Fix the array initialization so that it is not initializing 3 elements.

arch/sh64/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/sh64/mm/init.c
===================================================================
@@ -110,7 +110,7 @@ void show_mem(void)
  */
 void __init paging_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long zones_size[MAX_NR_ZONES] = {0, };
 
 	pgd_init((unsigned long)swapper_pg_dir);
 	pgd_init((unsigned long)swapper_pg_dir +
arch/m32r/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/m32r/mm/init.c
===================================================================
@@ -100,7 +100,7 @@ void free_initrd_mem(unsigned long, unsi
 #ifndef CONFIG_DISCONTIGMEM
 unsigned long __init zone_sizes_init(void)
 {
-	unsigned long  zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long  zones_size[MAX_NR_ZONES] = {0, };
 	unsigned long  max_dma;
 	unsigned long  low;
 	unsigned long  start_pfn;
arch/parisc/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/parisc/mm/init.c
===================================================================
@@ -809,7 +809,7 @@ void __init paging_init(void)
 	flush_tlb_all_local(NULL);
 
 	for (i = 0; i < npmem_ranges; i++) {
-		unsigned long zones_size[MAX_NR_ZONES] = { 0, 0, 0 };
+		unsigned long zones_size[MAX_NR_ZONES] = { 0, };
 
 		/* We have an IOMMU, so all memory can go into a single
 		   ZONE_DMA zone. */
arch/i386/kernel/setup.c +1 -1
Index: linux-2.6.17-mm6/arch/i386/kernel/setup.c
===================================================================
@@ -1201,7 +1201,7 @@ static unsigned long __init setup_memory
 
 void __init zone_sizes_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
 	unsigned int max_dma, low;
 
 	max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
arch/m68knommu/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/m68knommu/mm/init.c
===================================================================
@@ -136,7 +136,7 @@ void paging_init(void)
 #endif
 
 	{
-		unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+		unsigned long zones_size[MAX_NR_ZONES] = {0, };
 
 		zones_size[ZONE_DMA] = 0 >> PAGE_SHIFT;
 		zones_size[ZONE_NORMAL] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
arch/mips/sgi-ip27/ip27-memory.c +1 -1
Index: linux-2.6.17-mm6/arch/mips/sgi-ip27/ip27-memory.c
===================================================================
@@ -508,7 +508,7 @@ extern unsigned long setup_zero_pages(vo
 
 void __init paging_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long zones_size[MAX_NR_ZONES] = {0, };
 	unsigned node;
 
 	pagetable_init();
arch/frv/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/frv/mm/init.c
===================================================================
@@ -98,7 +98,7 @@ void show_mem(void)
  */
 void __init paging_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long zones_size[MAX_NR_ZONES] = {0, };
 
 	/* allocate some pages for kernel housekeeping tasks */
 	empty_bad_page_table	= (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
arch/h8300/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/h8300/mm/init.c
===================================================================
@@ -138,7 +138,7 @@ void paging_init(void)
 #endif
 
 	{
-		unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+		unsigned long zones_size[MAX_NR_ZONES] = {0, };
 
 		zones_size[ZONE_DMA]     = 0 >> PAGE_SHIFT;
 		zones_size[ZONE_NORMAL]  = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
arch/mips/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/mips/mm/init.c
===================================================================
@@ -141,7 +141,7 @@ extern void pagetable_init(void);
 
 void __init paging_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long zones_size[MAX_NR_ZONES] = {0, };
 	unsigned long max_dma, high, low;
 
 	pagetable_init();
arch/alpha/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/alpha/mm/init.c
===================================================================
@@ -270,7 +270,7 @@ callback_init(void * kernel_end)
 void
 paging_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+	unsigned long zones_size[MAX_NR_ZONES] = {0, };
 	unsigned long dma_pfn, high_pfn;
 
 	dma_pfn = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
arch/i386/mm/discontig.c +1 -1
Index: linux-2.6.17-mm6/arch/i386/mm/discontig.c
===================================================================
@@ -354,7 +354,7 @@ void __init zone_sizes_init(void)
 
 
 	for_each_online_node(nid) {
-		unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+		unsigned long zones_size[MAX_NR_ZONES] = {0, };
 		unsigned long *zholes_size;
 		unsigned int max_dma;
 
#14 lore raw

RFC 7/8 Fix strange uses of MAX_NR_ZONES

In reply to Christoph Lameter

Fix strange uses of MAX_NR_ZONES

Sometimes we use MAX_NR_ZONES - x to refer to a zone. Make that explicit.

arch/x86_64/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/x86_64/mm/init.c
===================================================================
@@ -536,7 +536,7 @@ int memory_add_physaddr_to_nid(u64 start
 int arch_add_memory(int nid, u64 start, u64 size)
 {
 	struct pglist_data *pgdat = NODE_DATA(nid);
-	struct zone *zone = pgdat->node_zones + MAX_NR_ZONES-2;
+	struct zone *zone = pgdat->node_zones + ZONE_NORMAL;
 	unsigned long start_pfn = start >> PAGE_SHIFT;
 	unsigned long nr_pages = size >> PAGE_SHIFT;
 	int ret;
arch/i386/mm/init.c +1 -1
Index: linux-2.6.17-mm6/arch/i386/mm/init.c
===================================================================
@@ -657,7 +657,7 @@ void __init mem_init(void)
 int arch_add_memory(int nid, u64 start, u64 size)
 {
 	struct pglist_data *pgdata = &contig_page_data;
-	struct zone *zone = pgdata->node_zones + MAX_NR_ZONES-1;
+	struct zone *zone = pgdata->node_zones + ZONE_HIGHMEM;
 	unsigned long start_pfn = start >> PAGE_SHIFT;
 	unsigned long nr_pages = size >> PAGE_SHIFT;
 
#15 lore raw

RFC 8/8 Fix i386 SRAT check for MAX_NR_ZONES

In reply to Christoph Lameter

swap_prefetch: Make use of ZONE_HIGHMEM conditional

swap prefetch uses ZONE_HIGHMEM even if CONFIG_HIGHMEM is off. Make that use conditional.

mm/swap_prefetch.c +4 -2
Index: linux-2.6.17/mm/swap_prefetch.c
===================================================================
@@ -277,8 +277,10 @@
 
 		ns = &sp_stat.node[z->zone_pgdat->node_id];
 		idx = zone_idx(z);
-		ns->lowfree[idx] = z->pages_high * 3 +
-			z->lowmem_reserve[ZONE_HIGHMEM];
+		ns->lowfree[idx] = z->pages_high * 3;
+#ifdef CONFIG_HIGHMEM
+		ns->lowfree[idx] += z->lowmem_reserve[ZONE_HIGHMEM];
+#endif
 		ns->highfree[idx] = ns->lowfree[idx] + z->pages_high;
 
 		if (z->free_pages > ns->highfree[idx]) {
#16 lore raw

Re: [RFC 8/8] Fix i386 SRAT check for MAX_NR_ZONES

Quoted 2 lines · On Mon, 3 Jul 2006 14:56:16 -0700 (PDT) Christoph Lameter <[email protected]>…

swap_prefetch: Make use of ZONE_HIGHMEM conditional

This patch is same to
[RFC 5/8] swap_prefetch: Make use of ZONE_HIGHMEM dependend on CONFIG_HIGHMEM

please check. I think what you intended was patch against chunk_to_zones().

-Kame

#17 lore raw

Re: [RFC 8/8] Fix i386 SRAT check for MAX_NR_ZONES

Quoted 4 lines · KAMEZAWA Hiroyuki

This patch is same to
[RFC 5/8] swap_prefetch: Make use of ZONE_HIGHMEM dependend on CONFIG_HIGHMEM

please check. I think what you intended was patch against chunk_to_zones().

Right. Wrong filename.

#18 lore raw
In reply to Christoph Lameter
Quoted 5 lines · Christoph Lameter

I keep seeing zones on various platforms that are never used and wonder why we compile support for them into the kernel.

IA64 on SGI for example only uses ZONE_DMA other IA64 platforms can also use ZONE_NORMAL.

Which btw is utterly wrong. It should have a 4GB ZONE_DMA32 and everything else in ZONE_NORMAL.

That doesn't mean I want to discourage this patchset, quite contrary. But please fix this oddity aswell.

#19 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Christoph Lameter

I keep seeing zones on various platforms that are never used and wonder why we compile support for them into the kernel.

IA64 on SGI for example only uses ZONE_DMA other IA64 platforms can also use ZONE_NORMAL.

Which btw is utterly wrong. It should have a 4GB ZONE_DMA32 and everything else in ZONE_NORMAL.

So we want to change the definition of ZONE_DMA to refer to the first 16MB only? ZONE_DMA32 is always a 4GB border? (Andy disagrees about DMA32 see his message!).

It seems to me that DMA can be run on ZONE_NORMAL. ZONE_DMAxx is used for situations in which DMA cannot be done to all of memory. ZONE_DMA allows an architecture to define a single exception zone that ends at MAX_DMA_ADDRESS (which is arch specific).

#20 lore raw
Quoted 4 lines

So we want to change the definition of ZONE_DMA to refer to the first 16MB only? ZONE_DMA32 is always a 4GB border? (Andy disagrees about DMA32 see his message!).

Hmm? I didn't write anything about DMA32. Just noted a minor comment thinko about highmem.

Quoted 4 lines

It seems to me that DMA can be run on ZONE_NORMAL. ZONE_DMAxx is used for situations in which DMA cannot be done to all of memory. ZONE_DMA allows an architecture to define a single exception zone that ends at MAX_DMA_ADDRESS (which is arch specific).

It's really architecture dependent. The portable interfaces are dma_alloc_* and suitable device masks and the architecture should sort out then what zone to use.

I would say nearly everybody who uses GFP_DMA directly outside {arch,asm}/* is wrong.

-Andi

#21 lore raw
Quoted 7 lines · Andi Kleen
Quoted 4 lines

So we want to change the definition of ZONE_DMA to refer to the first 16MB only? ZONE_DMA32 is always a 4GB border? (Andy disagrees about DMA32 see his message!).

Hmm? I didn't write anything about DMA32. Just noted a minor comment thinko about highmem.

The message was addressed to Christoph. You were only CCed. I fixed the issue you mentioined before. Thanks.

#22 lore raw
In reply to Andi Kleen
Quoted 3 lines · Andi Kleen

It's really architecture dependent. The portable interfaces are dma_alloc_* and suitable device masks and the architecture should sort out then what zone to use.

Well, there's some cases where you don't want coherent mappings but rather alloc_page + dma_map_*. And having a ZONE_DMA32 that is valid on all architectures is very valueable for that.

I remember James promised a kmalloc_mask a last Kernel Summit that would many things easier, but even than having predictable memory zone layouts overy different architectures is a win.

#23 lore raw
In reply to Christoph Lameter
Quoted 5 lines · Christoph Lameter
Quoted 2 lines

Which btw is utterly wrong. It should have a 4GB ZONE_DMA32 and everything else in ZONE_NORMAL.

So we want to change the definition of ZONE_DMA to refer to the first 16MB only? ZONE_DMA32 is always a 4GB border?

The definition of ZONE_DMA32 is to be te 32bit border. I think we should implement it wherever possible but at least on all architectures that maybe have non-iommu implementations. ZONE_DMA should be an arch-specific low memory zone.

#24 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Christoph Lameter
Quoted 2 lines

Which btw is utterly wrong. It should have a 4GB ZONE_DMA32 and everything else in ZONE_NORMAL.

So we want to change the definition of ZONE_DMA to refer to the first 16MB only? ZONE_DMA32 is always a 4GB border?

The definition of ZONE_DMA32 is to be te 32bit border. I think we should implement it wherever possible but at least on all architectures that maybe have non-iommu implementations. ZONE_DMA should be an arch-specific low memory zone.

I guess then we should drop ZONE_DMA (its a misnoner anyways since it seems to indicate that DMA is only possible in this zone). Instead use

ZONE_ISA_DMA -> ISA DMA Area (16 MB boundary)
ZONE_32BIT_DMA -> 32bit DMA area (well 900 MB on x86_64 but somewhere in that area)
only used for 64 bit platforms with 32 bit devices.
<and maybe define new ones in the future?>

Some arches seem to make ZONE_DMA their default zone instead of ZONE_NORMAL if DMA is possible to all of memory. I think in that case we should have no ZONE_DMA at all.

#25 lore raw
Quoted 6 lines

I guess then we should drop ZONE_DMA (its a misnoner anyways since it seems to indicate that DMA is only possible in this zone). Instead use

ZONE_ISA_DMA -> ISA DMA Area (16 MB boundary)
ZONE_32BIT_DMA -> 32bit DMA area (well 900 MB on x86_64 but somewhere in that area)

It's 4GB on x86-64.

The 900MB refered to the boundary between NORMAL and HIGHMEM on i386.

-Andi

#26 lore raw
Quoted 1 line · Andi Kleen

The 900MB refered to the boundary between NORMAL and HIGHMEM on i386.

Yikes. So any system with 1MB will need to have highmem? I guess the 2G/2G config option changes that?

#27 lore raw
Quoted 5 lines · Christoph Lameter
Quoted 1 line · Andi Kleen

The 900MB refered to the boundary between NORMAL and HIGHMEM on i386.

Yikes. So any system with 1MB

1G, but yes.

Quoted 2 lines

will need to have highmem? I guess the 2G/2G
config option changes that?

but that breaks userspace ABI and things that really want a lot of memory ;)

Thankfully x86-64 is there, and just about all systems sold today do 64 bit..

(and highmem is not that bad.. you make it sound as if it's a dirty word. It's not pretty but it's not THAT evil either)

#28 lore raw
Quoted 5 lines · Arjan van de Ven
Quoted 2 lines

will need to have highmem? I guess the 2G/2G
config option changes that?

but that breaks userspace ABI and things that really want a lot of memory ;)

Really? What things does it break? Sorry about my i386 ignorance.

Quoted 2 lines

Thankfully x86-64 is there, and just about all systems sold today do 64 bit..

Right but then some binary stuff is only available for 32 bit.

#29 lore raw
Quoted 9 lines · Christoph Lameter
Quoted 5 lines · Arjan van de Ven
Quoted 2 lines

will need to have highmem? I guess the 2G/2G
config option changes that?

but that breaks userspace ABI and things that really want a lot of memory ;)

Really? What things does it break? Sorry about my i386 ignorance.

things that assume you can malloc a 2gb area for example, or use a 2Gb stack. Yes fortran apps do that..

Quoted 5 lines
Quoted 3 lines

Thankfully x86-64 is there, and just about all systems sold today do 64 bit..

Right but then some binary stuff is only available for 32 bit.

the good news is that x86-64 has a pretty good 32 bit emulation... so that's not an actual problem...

#30 lore raw
In reply to Christoph Lameter
Quoted 9 lines · Christoph Lameter
Quoted 5 lines · Arjan van de Ven
Quoted 2 lines

will need to have highmem? I guess the 2G/2G
config option changes that?

but that breaks userspace ABI and things that really want a lot of memory ;)

Really? What things does it break? Sorry about my i386 ignorance.

There are programs who make address space assumptions for whatever reason.

When you only have 3GB it is precious space.

e.g. old Java also breaks when the AS is larger as on x86-64. That is why there is a 3GB personality.

Quoted 5 lines
Quoted 3 lines

Thankfully x86-64 is there, and just about all systems sold today do 64 bit..

Right but then some binary stuff is only available for 32 bit.

That's fine - the x86-64 kernel runs 32bit programs.

-Andi

#31 lore raw
In reply to Christoph Lameter
Quoted 5 lines · Christoph Lameter
Quoted 1 line · Andi Kleen

The 900MB refered to the boundary between NORMAL and HIGHMEM on i386.

Yikes. So any system with 1MB will need to have highmem?

No. But a 1GB system will.

Quoted 1 line

I guess the 2G/2G config option changes that?

Yes, but it also breaks a lot of software.

-Andi