linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering
@ 2007-07-21  7:00 KAMEZAWA Hiroyuki
  2007-07-21  7:03 ` [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE KAMEZAWA Hiroyuki
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-07-21  7:00 UTC (permalink / raw)
  To: linux-mm; +Cc: mel, apw, Andrew Morton, nickpiggin, Christoph Lameter

This patch set is for changing ZONE_MOVABLE as configurable.

This patch cleans up #ifdef used for zones to some extent.
But I noticed this will conflict witl Christoph's memory_less_node patch set.

If his set is ready to be merged to -mm(I hope so), I'll repost this after that.
For now, this post is just for review, again. If this patch looks danger, please
point out.

Patch is against 2.6.22-rc6-mm1. Tested on ia64/NUMA with and without setting CONFIG_ZONE_MOVABLE. both works well.

I'm sorry but my response will be delayed.

Thanks,
-Kame
==
zone_ifdef_cleanup_by_renumbering.patch

Now, this patch defines zone_idx for not-configured-zones.
like 
	enum_zone_type {
		(ZONE_DMA configured)
		(ZONE_DMA32 configured)
		ZONE_NORMAL
		(ZONE_HIGHMEM configured)
		ZONE_MOVABLE
		MAX_NR_ZONES,
		(ZONE_DMA not-configured)
		(ZONE_DMA32 not-configured)
		(ZONE_HIGHMEM not-configured)
		MAX_POSSIBLE_ZONES,
	};

By this, we can determine zone is configured or not by

	zone_idx < MAX_NR_ZONES.

By this, we can avoid #ifdef for CONFIG_ZONE_xxx to some extent.

This patch also replaces CONFIG_ZONE_DMA_FLAG by is_configured_zone(ZONE_DMA).

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

---
 include/linux/gfp.h    |   16 +++++-------
 include/linux/mmzone.h |   64 ++++++++++++++++++++++++++-----------------------
 include/linux/vmstat.h |   24 +++++++++---------
 mm/Kconfig             |    5 ---
 mm/page-writeback.c    |    7 ++---
 mm/page_alloc.c        |   37 ++++++++++++----------------
 mm/slab.c              |    4 +--
 7 files changed, 74 insertions(+), 83 deletions(-)

Index: linux-2.6.22-rc6-mm1/include/linux/mmzone.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/linux/mmzone.h
+++ linux-2.6.22-rc6-mm1/include/linux/mmzone.h
@@ -178,9 +178,24 @@ enum zone_type {
 	ZONE_HIGHMEM,
 #endif
 	ZONE_MOVABLE,
-	MAX_NR_ZONES
+	MAX_NR_ZONES,
+#ifndef CONFIG_ZONE_DMA
+	ZONE_DMA,
+#endif
+#ifndef CONFIG_ZONE_DMA32
+	ZONE_DMA32,
+#endif
+#ifndef CONFIG_HIGHMEM
+	ZONE_HIGHMEM,
+#endif
+	MAX_POSSIBLE_ZONES,
 };
 
+static inline int is_configured_zone(enum zone_type name)
+{
+	return (name < 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
@@ -543,28 +558,31 @@ static inline int populated_zone(struct 
 
 extern int movable_zone;
 
-static inline int zone_movable_is_highmem(void)
+static inline int zone_idx_is(enum zone_type idx, enum zone_type target)
 {
-#if defined(CONFIG_HIGHMEM) && defined(CONFIG_ARCH_POPULATES_NODE_MAP)
-	return movable_zone == ZONE_HIGHMEM;
-#else
+	if (is_configured_zone(target) && (idx == target))
+		return 1;
 	return 0;
+}
+
+static inline int zone_movable_is_highmem(void)
+{
+#if CONFIG_ARCH_POPULATES_NODE_MAP
+	if (is_configured_zone(ZONE_HIGHMEM))
+		return movable_zone == ZONE_HIGHMEM;
 #endif
+	return 0;
 }
 
 static inline int is_highmem_idx(enum zone_type idx)
 {
-#ifdef CONFIG_HIGHMEM
-	return (idx == ZONE_HIGHMEM ||
-		(idx == ZONE_MOVABLE && zone_movable_is_highmem()));
-#else
-	return 0;
-#endif
+	return (zone_idx_is(idx, ZONE_HIGHMEM) ||
+	       (zone_idx_is(idx, ZONE_MOVABLE) && zone_movable_is_highmem()));
 }
 
 static inline int is_normal_idx(enum zone_type idx)
 {
-	return (idx == ZONE_NORMAL);
+	return zone_idx_is(idx, ZONE_NORMAL);
 }
 
 /**
@@ -575,36 +593,22 @@ static inline int is_normal_idx(enum zon
  */
 static inline int is_highmem(struct zone *zone)
 {
-#ifdef CONFIG_HIGHMEM
-	int zone_idx = zone - zone->zone_pgdat->node_zones;
-	return zone_idx == ZONE_HIGHMEM ||
-		(zone_idx == ZONE_MOVABLE && zone_movable_is_highmem());
-#else
-	return 0;
-#endif
+	return is_highmem_idx(zone_idx(zone));
 }
 
 static inline int is_normal(struct zone *zone)
 {
-	return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
+	return zone_idx_is(zone_idx(zone), ZONE_NORMAL);
 }
 
 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
+	return zone_idx_is(zone_idx(zone), ZONE_DMA32);
 }
 
 static inline int is_dma(struct zone *zone)
 {
-#ifdef CONFIG_ZONE_DMA
-	return zone == zone->zone_pgdat->node_zones + ZONE_DMA;
-#else
-	return 0;
-#endif
+	return zone_idx_is(zone_idx(zone), ZONE_DMA);
 }
 
 /* These two functions are used to setup the per zone pages min values */
Index: linux-2.6.22-rc6-mm1/include/linux/vmstat.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/linux/vmstat.h
+++ linux-2.6.22-rc6-mm1/include/linux/vmstat.h
@@ -159,19 +159,19 @@ static inline unsigned long node_page_st
 				 enum zone_stat_item item)
 {
 	struct zone *zones = NODE_DATA(node)->node_zones;
+	unsigned long val = zone_page_state(&zones[ZONE_NORMAL],item);
 
-	return
-#ifdef CONFIG_ZONE_DMA
-		zone_page_state(&zones[ZONE_DMA], item) +
-#endif
-#ifdef CONFIG_ZONE_DMA32
-		zone_page_state(&zones[ZONE_DMA32], item) +
-#endif
-#ifdef CONFIG_HIGHMEM
-		zone_page_state(&zones[ZONE_HIGHMEM], item) +
-#endif
-		zone_page_state(&zones[ZONE_NORMAL], item) +
-		zone_page_state(&zones[ZONE_MOVABLE], item);
+	if (is_configured_zone(ZONE_DMA))
+		val += zone_page_state(&zones[ZONE_DMA], item);
+
+	if (is_configured_zone(ZONE_DMA32))
+		val += zone_page_state(&zones[ZONE_DMA32], item);
+
+	if (is_configured_zone(ZONE_HIGHMEM))
+		val += zone_page_state(&zones[ZONE_HIGHMEM], item);
+
+	val += zone_page_state(&zones[ZONE_MOVABLE], item);
+	return val;
 }
 
 extern void zone_statistics(struct zonelist *, struct zone *);
Index: linux-2.6.22-rc6-mm1/include/linux/gfp.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/linux/gfp.h
+++ linux-2.6.22-rc6-mm1/include/linux/gfp.h
@@ -116,21 +116,19 @@ static inline int allocflags_to_migratet
 
 static inline enum zone_type gfp_zone(gfp_t flags)
 {
-#ifdef CONFIG_ZONE_DMA
-	if (flags & __GFP_DMA)
+	if (is_configured_zone(ZONE_DMA) && (flags & __GFP_DMA))
 		return ZONE_DMA;
-#endif
-#ifdef CONFIG_ZONE_DMA32
-	if (flags & __GFP_DMA32)
+
+	if (is_configured_zone(ZONE_DMA32) && (flags & __GFP_DMA32))
 		return ZONE_DMA32;
-#endif
+
 	if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
 			(__GFP_HIGHMEM | __GFP_MOVABLE))
 		return ZONE_MOVABLE;
-#ifdef CONFIG_HIGHMEM
-	if (flags & __GFP_HIGHMEM)
+
+	if (is_configured_zone(ZONE_HIGHMEM) && (flags & __GFP_HIGHMEM))
 		return ZONE_HIGHMEM;
-#endif
+
 	return ZONE_NORMAL;
 }
 
Index: linux-2.6.22-rc6-mm1/mm/Kconfig
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/Kconfig
+++ linux-2.6.22-rc6-mm1/mm/Kconfig
@@ -158,11 +158,6 @@ config RESOURCES_64BIT
 	help
 	  This option allows memory and IO resources to be 64 bit.
 
-config ZONE_DMA_FLAG
-	int
-	default "0" if !ZONE_DMA
-	default "1"
-
 config BOUNCE
 	def_bool y
 	depends on BLOCK && MMU && (ZONE_DMA || HIGHMEM)
Index: linux-2.6.22-rc6-mm1/mm/page_alloc.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/page_alloc.c
+++ linux-2.6.22-rc6-mm1/mm/page_alloc.c
@@ -91,18 +91,12 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z
 
 EXPORT_SYMBOL(totalram_pages);
 
-static char * const zone_names[MAX_NR_ZONES] = {
-#ifdef CONFIG_ZONE_DMA
-	 "DMA",
-#endif
-#ifdef CONFIG_ZONE_DMA32
-	 "DMA32",
-#endif
-	 "Normal",
-#ifdef CONFIG_HIGHMEM
-	 "HighMem",
-#endif
-	 "Movable",
+static char * const zone_names[MAX_POSSIBLE_ZONES] = {
+	[ZONE_DMA] = "DMA",
+	[ZONE_DMA32] = "DMA32",
+	[ZONE_NORMAL] = "Normal",
+	[ZONE_HIGHMEM] = "HighMem",
+	[ZONE_MOVABLE] =  "Movable",
 };
 
 int min_free_kbytes = 1024;
@@ -134,8 +128,8 @@ static unsigned long __meminitdata dma_r
 
   static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
   static int __meminitdata nr_nodemap_entries;
-  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
-  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
+  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_POSSIBLE_ZONES];
+  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_POSSIBLE_ZONES];
 #ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
   static unsigned long __meminitdata node_boundary_start_pfn[MAX_NUMNODES];
   static unsigned long __meminitdata node_boundary_end_pfn[MAX_NUMNODES];
@@ -1834,14 +1828,15 @@ void si_meminfo_node(struct sysinfo *val
 
 	val->totalram = pgdat->node_present_pages;
 	val->freeram = node_page_state(nid, NR_FREE_PAGES);
-#ifdef CONFIG_HIGHMEM
-	val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].present_pages;
-	val->freehigh = zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
+	if (is_configured_zone(ZONE_HIGHMEM)) {
+		val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].present_pages;
+		val->freehigh =
+			zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
 			NR_FREE_PAGES);
-#else
-	val->totalhigh = 0;
-	val->freehigh = 0;
-#endif
+	} else {
+		val->totalhigh = 0;
+		val->freehigh = 0;
+	}
 	val->mem_unit = PAGE_SIZE;
 }
 #endif
Index: linux-2.6.22-rc6-mm1/mm/slab.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/slab.c
+++ linux-2.6.22-rc6-mm1/mm/slab.c
@@ -2328,7 +2328,7 @@ kmem_cache_create (const char *name, siz
 	cachep->slab_size = slab_size;
 	cachep->flags = flags;
 	cachep->gfpflags = 0;
-	if (CONFIG_ZONE_DMA_FLAG && (flags & SLAB_CACHE_DMA))
+	if (is_configured_zone(ZONE_DMA) && (flags & SLAB_CACHE_DMA))
 		cachep->gfpflags |= GFP_DMA;
 	cachep->buffer_size = size;
 	cachep->reciprocal_buffer_size = reciprocal_value(size);
@@ -2649,7 +2649,7 @@ static void cache_init_objs(struct kmem_
 
 static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
 {
-	if (CONFIG_ZONE_DMA_FLAG) {
+	if (is_configured_zone(ZONE_DMA)) {
 		if (flags & GFP_DMA)
 			BUG_ON(!(cachep->gfpflags & GFP_DMA));
 		else
Index: linux-2.6.22-rc6-mm1/mm/page-writeback.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/page-writeback.c
+++ linux-2.6.22-rc6-mm1/mm/page-writeback.c
@@ -122,10 +122,12 @@ static void background_writeout(unsigned
 
 static unsigned long highmem_dirtyable_memory(unsigned long total)
 {
-#ifdef CONFIG_HIGHMEM
 	int node;
 	unsigned long x = 0;
 
+	if (!is_configured_zone(ZONE_HIGHMEM))
+		return 0;
+
 	for_each_online_node(node) {
 		struct zone *z =
 			&NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
@@ -141,9 +143,6 @@ static unsigned long highmem_dirtyable_m
 	 * that this does not occur.
 	 */
 	return min(x, total);
-#else
-	return 0;
-#endif
 }
 
 static unsigned long determine_dirtyable_memory(void)

--
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] 8+ messages in thread

* [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE
  2007-07-21  7:00 [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering KAMEZAWA Hiroyuki
@ 2007-07-21  7:03 ` KAMEZAWA Hiroyuki
  2007-07-23  7:25   ` Nick Piggin
  2007-07-23 13:45   ` Mel Gorman
  2007-07-23  7:22 ` [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering Nick Piggin
  2007-07-23 13:16 ` Mel Gorman
  2 siblings, 2 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-07-21  7:03 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: linux-mm, mel, apw, Andrew Morton, nickpiggin, Christoph Lameter

Makes ZONE_MOVABLE as configurable

Based on "zone_ifdef_cleanup_by_renumbering.patch"

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>



---
 include/linux/gfp.h    |    3 ++-
 include/linux/mmzone.h |   11 +++++++----
 include/linux/vmstat.h |   13 +++++++++++--
 mm/Kconfig             |   13 +++++++++++++
 mm/page_alloc.c        |    6 ++++++
 mm/vmstat.c            |    8 +++++++-
 6 files changed, 46 insertions(+), 8 deletions(-)

Index: linux-2.6.22-rc6-mm1/include/linux/mmzone.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/linux/mmzone.h
+++ linux-2.6.22-rc6-mm1/include/linux/mmzone.h
@@ -177,7 +177,9 @@ enum zone_type {
 	 */
 	ZONE_HIGHMEM,
 #endif
+#ifdef CONFIG_ZONE_MOVABLE
 	ZONE_MOVABLE,
+#endif
 	MAX_NR_ZONES,
 #ifndef CONFIG_ZONE_DMA
 	ZONE_DMA,
@@ -188,6 +190,9 @@ enum zone_type {
 #ifndef CONFIG_HIGHMEM
 	ZONE_HIGHMEM,
 #endif
+#ifndef CONFIG_ZONE_MOVABLE
+	ZONE_MOVABLE,
+#endif
 	MAX_POSSIBLE_ZONES,
 };
 
@@ -567,11 +572,9 @@ static inline int zone_idx_is(enum zone_
 
 static inline int zone_movable_is_highmem(void)
 {
-#if CONFIG_ARCH_POPULATES_NODE_MAP
-	if (is_configured_zone(ZONE_HIGHMEM))
-		return movable_zone == ZONE_HIGHMEM;
-#endif
-	return 0;
+	return is_configured_zone(ZONE_HIGHMEM) &&
+	       is_configured_zone(ZONE_MOVABLE) &&
+		(movable_zone == ZONE_HIGHMEM);
 }
 
 static inline int is_highmem_idx(enum zone_type idx)
Index: linux-2.6.22-rc6-mm1/include/linux/gfp.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/linux/gfp.h
+++ linux-2.6.22-rc6-mm1/include/linux/gfp.h
@@ -122,7 +122,8 @@ static inline enum zone_type gfp_zone(gf
 	if (is_configured_zone(ZONE_DMA32) && (flags & __GFP_DMA32))
 		return ZONE_DMA32;
 
-	if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
+	if (is_configured_zone(ZONE_MOVABLE) &&
+	    (flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
 			(__GFP_HIGHMEM | __GFP_MOVABLE))
 		return ZONE_MOVABLE;
 
Index: linux-2.6.22-rc6-mm1/mm/Kconfig
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/Kconfig
+++ linux-2.6.22-rc6-mm1/mm/Kconfig
@@ -112,6 +112,19 @@ config SPARSEMEM_EXTREME
 	def_bool y
 	depends on SPARSEMEM && !SPARSEMEM_STATIC
 
+
+config ZONE_MOVABLE
+	bool	"A zone for movable pages"
+	depends on ARCH_POPULATES_NODE_MAP
+	help
+	  Allows creating a zone type only for movable pages, i.e page cache
+	  and anonymous memory. Because movable pages are tend to be easily
+	  reclaimed and page migration technique can move them, your chance
+	  for allocating big size memory will be better in this zone than
+  	  other zones.
+	  To use this zone, please see "kernelcore=" or "movablecore=" in
+	  Documentation/kernel-parameters.txt
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
Index: linux-2.6.22-rc6-mm1/mm/page_alloc.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/page_alloc.c
+++ linux-2.6.22-rc6-mm1/mm/page_alloc.c
@@ -86,7 +86,9 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z
 #ifdef CONFIG_HIGHMEM
 	 32,
 #endif
+#ifdef CONFIG_ZONE_MOVABLE
 	 32,
+#endif
 };
 
 EXPORT_SYMBOL(totalram_pages);
@@ -3883,6 +3885,10 @@ static int __init cmdline_parse_kernelco
 	if (!p)
 		return -EINVAL;
 
+	if (!is_configured_zone(ZONE_MOVABLE)) {
+		printk ("ZONE_MOVABLE is not configured, kernelcore= is ignored.\n");
+		return 0;
+	}
 	coremem = memparse(p, &p);
 	required_kernelcore = coremem >> PAGE_SHIFT;
 
Index: linux-2.6.22-rc6-mm1/mm/vmstat.c
===================================================================
--- linux-2.6.22-rc6-mm1.orig/mm/vmstat.c
+++ linux-2.6.22-rc6-mm1/mm/vmstat.c
@@ -694,8 +694,14 @@ const struct seq_operations pagetypeinfo
 #define TEXT_FOR_HIGHMEM(xx)
 #endif
 
+#ifdef CONFIG_ZONE_MOVABLE
+#define TEXT_FOR_MOVABLE(xx) xx "_movable",
+#else
+#define TEXT_FOR_MOVABLE(xx)
+#endif
+
 #define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \
-					TEXT_FOR_HIGHMEM(xx) xx "_movable",
+					TEXT_FOR_HIGHMEM(xx) xx TEXT_FOR_MOVABLE(xx)
 
 static const char * const vmstat_text[] = {
 	/* Zoned VM counters */
Index: linux-2.6.22-rc6-mm1/include/linux/vmstat.h
===================================================================
--- linux-2.6.22-rc6-mm1.orig/include/linux/vmstat.h
+++ linux-2.6.22-rc6-mm1/include/linux/vmstat.h
@@ -25,7 +25,14 @@
 #define HIGHMEM_ZONE(xx)
 #endif
 
-#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) , xx##_MOVABLE
+#ifdef CONFIG_ZONE_MOVABLE
+#define MOVABLE_ZONE(xx) , xx##_MOVABLE
+#else
+#define MOVABLE_ZONE(xx)
+#endif
+
+
+#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) MOVABLE_ZONE(xx)
 
 enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		FOR_ALL_ZONES(PGALLOC),
@@ -170,7 +177,9 @@ static inline unsigned long node_page_st
 	if (is_configured_zone(ZONE_HIGHMEM))
 		val += zone_page_state(&zones[ZONE_HIGHMEM], item);
 
-	val += zone_page_state(&zones[ZONE_MOVABLE], item);
+	if (is_configured_zone(ZONE_MOVABLE))
+		val += zone_page_state(&zones[ZONE_MOVABLE], item);
+
 	return val;
 }
 

--
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] 8+ messages in thread

* Re: [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering
  2007-07-21  7:00 [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering KAMEZAWA Hiroyuki
  2007-07-21  7:03 ` [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE KAMEZAWA Hiroyuki
@ 2007-07-23  7:22 ` Nick Piggin
  2007-07-24  2:26   ` KAMEZAWA Hiroyuki
  2007-07-23 13:16 ` Mel Gorman
  2 siblings, 1 reply; 8+ messages in thread
From: Nick Piggin @ 2007-07-23  7:22 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: linux-mm, mel, apw, Andrew Morton, Christoph Lameter

KAMEZAWA Hiroyuki wrote:
> This patch set is for changing ZONE_MOVABLE as configurable.
> 
> This patch cleans up #ifdef used for zones to some extent.
> But I noticed this will conflict witl Christoph's memory_less_node patch set.
> 
> If his set is ready to be merged to -mm(I hope so), I'll repost this after that.
> For now, this post is just for review, again. If this patch looks danger, please
> point out.
> 
> Patch is against 2.6.22-rc6-mm1. Tested on ia64/NUMA with and without setting CONFIG_ZONE_MOVABLE. both works well.
> 
> I'm sorry but my response will be delayed.
> 
> Thanks,
> -Kame
> ==
> zone_ifdef_cleanup_by_renumbering.patch
> 
> Now, this patch defines zone_idx for not-configured-zones.
> like 
> 	enum_zone_type {
> 		(ZONE_DMA configured)
> 		(ZONE_DMA32 configured)
> 		ZONE_NORMAL
> 		(ZONE_HIGHMEM configured)
> 		ZONE_MOVABLE
> 		MAX_NR_ZONES,
> 		(ZONE_DMA not-configured)
> 		(ZONE_DMA32 not-configured)
> 		(ZONE_HIGHMEM not-configured)
> 		MAX_POSSIBLE_ZONES,
> 	};
> 
> By this, we can determine zone is configured or not by
> 
> 	zone_idx < MAX_NR_ZONES.
> 
> By this, we can avoid #ifdef for CONFIG_ZONE_xxx to some extent.
> 
> This patch also replaces CONFIG_ZONE_DMA_FLAG by is_configured_zone(ZONE_DMA).

This looks nice to me. It seems like the constant folding will be pretty
trivial for the compiler to get right -- have you verified this?

Could make a comment about all the names of these little functions, but I
see that you're pretty well just following what's already there, so whoever
thought those are nice shouldn't have a problem with your patch :)

> 
> Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> 
> ---
>  include/linux/gfp.h    |   16 +++++-------
>  include/linux/mmzone.h |   64 ++++++++++++++++++++++++++-----------------------
>  include/linux/vmstat.h |   24 +++++++++---------
>  mm/Kconfig             |    5 ---
>  mm/page-writeback.c    |    7 ++---
>  mm/page_alloc.c        |   37 ++++++++++++----------------
>  mm/slab.c              |    4 +--
>  7 files changed, 74 insertions(+), 83 deletions(-)
> 
> Index: linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/include/linux/mmzone.h
> +++ linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> @@ -178,9 +178,24 @@ enum zone_type {
>  	ZONE_HIGHMEM,
>  #endif
>  	ZONE_MOVABLE,
> -	MAX_NR_ZONES
> +	MAX_NR_ZONES,
> +#ifndef CONFIG_ZONE_DMA
> +	ZONE_DMA,
> +#endif
> +#ifndef CONFIG_ZONE_DMA32
> +	ZONE_DMA32,
> +#endif
> +#ifndef CONFIG_HIGHMEM
> +	ZONE_HIGHMEM,
> +#endif
> +	MAX_POSSIBLE_ZONES,
>  };

One issue I see here is that MAX_POSSIBLE_ZONES also includes MAX_NR_ZONES
so I think it will be off-by-one, won't it?


> -static char * const zone_names[MAX_NR_ZONES] = {
> -#ifdef CONFIG_ZONE_DMA
> -	 "DMA",
> -#endif
> -#ifdef CONFIG_ZONE_DMA32
> -	 "DMA32",
> -#endif
> -	 "Normal",
> -#ifdef CONFIG_HIGHMEM
> -	 "HighMem",
> -#endif
> -	 "Movable",
> +static char * const zone_names[MAX_POSSIBLE_ZONES] = {
> +	[ZONE_DMA] = "DMA",
> +	[ZONE_DMA32] = "DMA32",
> +	[ZONE_NORMAL] = "Normal",
> +	[ZONE_HIGHMEM] = "HighMem",
> +	[ZONE_MOVABLE] =  "Movable",
>  };

Sweet :) I guess the slight increase in size is well worth the nice code!
However, I think you should be able to just avoid specifying the array
size explicitly, right?


> @@ -134,8 +128,8 @@ static unsigned long __meminitdata dma_r
>  
>    static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
>    static int __meminitdata nr_nodemap_entries;
> -  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
> -  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
> +  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_POSSIBLE_ZONES];
> +  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_POSSIBLE_ZONES];

I don't quite understand why you need to make this change? AFAKS, it is wrong.
Given that, you might be able to just get rid of MAX_POSSIBLE_ZONES completely?

-- 
SUSE Labs, Novell Inc.

--
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] 8+ messages in thread

* Re: [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE
  2007-07-21  7:03 ` [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE KAMEZAWA Hiroyuki
@ 2007-07-23  7:25   ` Nick Piggin
  2007-07-23 13:45   ` Mel Gorman
  1 sibling, 0 replies; 8+ messages in thread
From: Nick Piggin @ 2007-07-23  7:25 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: linux-mm, mel, apw, Andrew Morton, Christoph Lameter

KAMEZAWA Hiroyuki wrote:
> Makes ZONE_MOVABLE as configurable
> 
> Based on "zone_ifdef_cleanup_by_renumbering.patch"
> 
> Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Great, thanks. IMO this should definitely go in before 2.6.23.


-- 
SUSE Labs, Novell Inc.

--
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] 8+ messages in thread

* Re: [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering
  2007-07-21  7:00 [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering KAMEZAWA Hiroyuki
  2007-07-21  7:03 ` [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE KAMEZAWA Hiroyuki
  2007-07-23  7:22 ` [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering Nick Piggin
@ 2007-07-23 13:16 ` Mel Gorman
  2 siblings, 0 replies; 8+ messages in thread
From: Mel Gorman @ 2007-07-23 13:16 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: linux-mm, apw, Andrew Morton, nickpiggin, Christoph Lameter

On (21/07/07 16:00), KAMEZAWA Hiroyuki didst pronounce:
> This patch set is for changing ZONE_MOVABLE as configurable.
> 
> This patch cleans up #ifdef used for zones to some extent.
> But I noticed this will conflict witl Christoph's memory_less_node patch set.
> 
> If his set is ready to be merged to -mm(I hope so), I'll repost this after that.
> For now, this post is just for review, again. If this patch looks danger, please
> point out.
> 
> Patch is against 2.6.22-rc6-mm1. Tested on ia64/NUMA with and without setting CONFIG_ZONE_MOVABLE. both works well.
> 
> I'm sorry but my response will be delayed.
> 
> Thanks,
> -Kame
> ==
> zone_ifdef_cleanup_by_renumbering.patch
> 
> Now, this patch defines zone_idx for not-configured-zones.
> like 
> 	enum_zone_type {
> 		(ZONE_DMA configured)
> 		(ZONE_DMA32 configured)
> 		ZONE_NORMAL
> 		(ZONE_HIGHMEM configured)
> 		ZONE_MOVABLE
> 		MAX_NR_ZONES,
> 		(ZONE_DMA not-configured)
> 		(ZONE_DMA32 not-configured)
> 		(ZONE_HIGHMEM not-configured)
> 		MAX_POSSIBLE_ZONES,
> 	};

As I said before, I like this idea.

> 
> By this, we can determine zone is configured or not by
> 
> 	zone_idx < MAX_NR_ZONES.
> 
> By this, we can avoid #ifdef for CONFIG_ZONE_xxx to some extent.
> 
> This patch also replaces CONFIG_ZONE_DMA_FLAG by is_configured_zone(ZONE_DMA).
> 
> Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> 
> ---
>  include/linux/gfp.h    |   16 +++++-------
>  include/linux/mmzone.h |   64 ++++++++++++++++++++++++++-----------------------
>  include/linux/vmstat.h |   24 +++++++++---------
>  mm/Kconfig             |    5 ---
>  mm/page-writeback.c    |    7 ++---
>  mm/page_alloc.c        |   37 ++++++++++++----------------
>  mm/slab.c              |    4 +--
>  7 files changed, 74 insertions(+), 83 deletions(-)
> 
> Index: linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/include/linux/mmzone.h
> +++ linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> @@ -178,9 +178,24 @@ enum zone_type {
>  	ZONE_HIGHMEM,
>  #endif
>  	ZONE_MOVABLE,
> -	MAX_NR_ZONES
> +	MAX_NR_ZONES,
> +#ifndef CONFIG_ZONE_DMA
> +	ZONE_DMA,
> +#endif
> +#ifndef CONFIG_ZONE_DMA32
> +	ZONE_DMA32,
> +#endif
> +#ifndef CONFIG_HIGHMEM
> +	ZONE_HIGHMEM,
> +#endif
> +	MAX_POSSIBLE_ZONES,
>  };
>  
> +static inline int is_configured_zone(enum zone_type name)
> +{
> +	return (name < MAX_NR_ZONES);
> +}
> +

nit-pick; The use of "name" as a variable here is a little confusing because
zone->name is a char * while this is a zone index. I would prefer it was
called zoneidx or similar. Later you use idx so that would be fine.

>  /*
>   * When a memory allocation must conform to specific limitations (such
>   * as being suitable for DMA) the caller will pass in hints to the
> @@ -543,28 +558,31 @@ static inline int populated_zone(struct 
>  
>  extern int movable_zone;
>  
> -static inline int zone_movable_is_highmem(void)
> +static inline int zone_idx_is(enum zone_type idx, enum zone_type target)
>  {
> -#if defined(CONFIG_HIGHMEM) && defined(CONFIG_ARCH_POPULATES_NODE_MAP)
> -	return movable_zone == ZONE_HIGHMEM;
> -#else
> +	if (is_configured_zone(target) && (idx == target))
> +		return 1;
>  	return 0;
> +}
> +
> +static inline int zone_movable_is_highmem(void)
> +{
> +#if CONFIG_ARCH_POPULATES_NODE_MAP
> +	if (is_configured_zone(ZONE_HIGHMEM))
> +		return movable_zone == ZONE_HIGHMEM;
>  #endif
> +	return 0;
>  }
>  
>  static inline int is_highmem_idx(enum zone_type idx)
>  {
> -#ifdef CONFIG_HIGHMEM
> -	return (idx == ZONE_HIGHMEM ||
> -		(idx == ZONE_MOVABLE && zone_movable_is_highmem()));
> -#else
> -	return 0;
> -#endif
> +	return (zone_idx_is(idx, ZONE_HIGHMEM) ||
> +	       (zone_idx_is(idx, ZONE_MOVABLE) && zone_movable_is_highmem()));

Using spaces instead of tabs here.

>  }
>  
>  static inline int is_normal_idx(enum zone_type idx)
>  {
> -	return (idx == ZONE_NORMAL);
> +	return zone_idx_is(idx, ZONE_NORMAL);
>  }
>  
>  /**
> @@ -575,36 +593,22 @@ static inline int is_normal_idx(enum zon
>   */
>  static inline int is_highmem(struct zone *zone)
>  {
> -#ifdef CONFIG_HIGHMEM
> -	int zone_idx = zone - zone->zone_pgdat->node_zones;
> -	return zone_idx == ZONE_HIGHMEM ||
> -		(zone_idx == ZONE_MOVABLE && zone_movable_is_highmem());
> -#else
> -	return 0;
> -#endif
> +	return is_highmem_idx(zone_idx(zone));
>  }

Much nicer looking.

>  
>  static inline int is_normal(struct zone *zone)
>  {
> -	return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
> +	return zone_idx_is(zone_idx(zone), ZONE_NORMAL);
>  }
>  
>  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
> +	return zone_idx_is(zone_idx(zone), ZONE_DMA32);
>  }
>  
>  static inline int is_dma(struct zone *zone)
>  {
> -#ifdef CONFIG_ZONE_DMA
> -	return zone == zone->zone_pgdat->node_zones + ZONE_DMA;
> -#else
> -	return 0;
> -#endif
> +	return zone_idx_is(zone_idx(zone), ZONE_DMA);
>  }
>  
>  /* These two functions are used to setup the per zone pages min values */
> Index: linux-2.6.22-rc6-mm1/include/linux/vmstat.h
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/include/linux/vmstat.h
> +++ linux-2.6.22-rc6-mm1/include/linux/vmstat.h
> @@ -159,19 +159,19 @@ static inline unsigned long node_page_st
>  				 enum zone_stat_item item)
>  {
>  	struct zone *zones = NODE_DATA(node)->node_zones;
> +	unsigned long val = zone_page_state(&zones[ZONE_NORMAL],item);
>  
> -	return
> -#ifdef CONFIG_ZONE_DMA
> -		zone_page_state(&zones[ZONE_DMA], item) +
> -#endif
> -#ifdef CONFIG_ZONE_DMA32
> -		zone_page_state(&zones[ZONE_DMA32], item) +
> -#endif
> -#ifdef CONFIG_HIGHMEM
> -		zone_page_state(&zones[ZONE_HIGHMEM], item) +
> -#endif
> -		zone_page_state(&zones[ZONE_NORMAL], item) +
> -		zone_page_state(&zones[ZONE_MOVABLE], item);
> +	if (is_configured_zone(ZONE_DMA))
> +		val += zone_page_state(&zones[ZONE_DMA], item);
> +
> +	if (is_configured_zone(ZONE_DMA32))
> +		val += zone_page_state(&zones[ZONE_DMA32], item);
> +
> +	if (is_configured_zone(ZONE_HIGHMEM))
> +		val += zone_page_state(&zones[ZONE_HIGHMEM], item);
> +
> +	val += zone_page_state(&zones[ZONE_MOVABLE], item);
> +	return val;
>  }
>  
>  extern void zone_statistics(struct zonelist *, struct zone *);
> Index: linux-2.6.22-rc6-mm1/include/linux/gfp.h
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/include/linux/gfp.h
> +++ linux-2.6.22-rc6-mm1/include/linux/gfp.h
> @@ -116,21 +116,19 @@ static inline int allocflags_to_migratet
>  
>  static inline enum zone_type gfp_zone(gfp_t flags)
>  {
> -#ifdef CONFIG_ZONE_DMA
> -	if (flags & __GFP_DMA)
> +	if (is_configured_zone(ZONE_DMA) && (flags & __GFP_DMA))
>  		return ZONE_DMA;
> -#endif
> -#ifdef CONFIG_ZONE_DMA32
> -	if (flags & __GFP_DMA32)
> +
> +	if (is_configured_zone(ZONE_DMA32) && (flags & __GFP_DMA32))
>  		return ZONE_DMA32;
> -#endif
> +
>  	if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
>  			(__GFP_HIGHMEM | __GFP_MOVABLE))
>  		return ZONE_MOVABLE;
> -#ifdef CONFIG_HIGHMEM
> -	if (flags & __GFP_HIGHMEM)
> +
> +	if (is_configured_zone(ZONE_HIGHMEM) && (flags & __GFP_HIGHMEM))
>  		return ZONE_HIGHMEM;
> -#endif
> +
>  	return ZONE_NORMAL;
>  }
>  
> Index: linux-2.6.22-rc6-mm1/mm/Kconfig
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/mm/Kconfig
> +++ linux-2.6.22-rc6-mm1/mm/Kconfig
> @@ -158,11 +158,6 @@ config RESOURCES_64BIT
>  	help
>  	  This option allows memory and IO resources to be 64 bit.
>  
> -config ZONE_DMA_FLAG
> -	int
> -	default "0" if !ZONE_DMA
> -	default "1"
> -
>  config BOUNCE
>  	def_bool y
>  	depends on BLOCK && MMU && (ZONE_DMA || HIGHMEM)
> Index: linux-2.6.22-rc6-mm1/mm/page_alloc.c
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/mm/page_alloc.c
> +++ linux-2.6.22-rc6-mm1/mm/page_alloc.c
> @@ -91,18 +91,12 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z
>  
>  EXPORT_SYMBOL(totalram_pages);
>  
> -static char * const zone_names[MAX_NR_ZONES] = {
> -#ifdef CONFIG_ZONE_DMA
> -	 "DMA",
> -#endif
> -#ifdef CONFIG_ZONE_DMA32
> -	 "DMA32",
> -#endif
> -	 "Normal",
> -#ifdef CONFIG_HIGHMEM
> -	 "HighMem",
> -#endif
> -	 "Movable",
> +static char * const zone_names[MAX_POSSIBLE_ZONES] = {
> +	[ZONE_DMA] = "DMA",
> +	[ZONE_DMA32] = "DMA32",
> +	[ZONE_NORMAL] = "Normal",
> +	[ZONE_HIGHMEM] = "HighMem",
> +	[ZONE_MOVABLE] =  "Movable",
>  };
>  
>  int min_free_kbytes = 1024;
> @@ -134,8 +128,8 @@ static unsigned long __meminitdata dma_r
>  
>    static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
>    static int __meminitdata nr_nodemap_entries;
> -  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
> -  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
> +  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_POSSIBLE_ZONES];
> +  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_POSSIBLE_ZONES];

I don't think this change is necessary. Values larger than MAX_NR_ZONES will
never be used by the initialisation code. At least, I cannot find a place
where it would but did you spot somewhere?. If values outside of MAX_NR_ZONES
are used then the initialisation is going to go wrong.

>  #ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
>    static unsigned long __meminitdata node_boundary_start_pfn[MAX_NUMNODES];
>    static unsigned long __meminitdata node_boundary_end_pfn[MAX_NUMNODES];
> @@ -1834,14 +1828,15 @@ void si_meminfo_node(struct sysinfo *val
>  
>  	val->totalram = pgdat->node_present_pages;
>  	val->freeram = node_page_state(nid, NR_FREE_PAGES);
> -#ifdef CONFIG_HIGHMEM
> -	val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].present_pages;
> -	val->freehigh = zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
> +	if (is_configured_zone(ZONE_HIGHMEM)) {
> +		val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].present_pages;
> +		val->freehigh =
> +			zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
>  			NR_FREE_PAGES);
> -#else
> -	val->totalhigh = 0;
> -	val->freehigh = 0;
> -#endif
> +	} else {
> +		val->totalhigh = 0;
> +		val->freehigh = 0;
> +	}
>  	val->mem_unit = PAGE_SIZE;
>  }
>  #endif
> Index: linux-2.6.22-rc6-mm1/mm/slab.c
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/mm/slab.c
> +++ linux-2.6.22-rc6-mm1/mm/slab.c
> @@ -2328,7 +2328,7 @@ kmem_cache_create (const char *name, siz
>  	cachep->slab_size = slab_size;
>  	cachep->flags = flags;
>  	cachep->gfpflags = 0;
> -	if (CONFIG_ZONE_DMA_FLAG && (flags & SLAB_CACHE_DMA))
> +	if (is_configured_zone(ZONE_DMA) && (flags & SLAB_CACHE_DMA))
>  		cachep->gfpflags |= GFP_DMA;
>  	cachep->buffer_size = size;
>  	cachep->reciprocal_buffer_size = reciprocal_value(size);
> @@ -2649,7 +2649,7 @@ static void cache_init_objs(struct kmem_
>  
>  static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
>  {
> -	if (CONFIG_ZONE_DMA_FLAG) {
> +	if (is_configured_zone(ZONE_DMA)) {
>  		if (flags & GFP_DMA)
>  			BUG_ON(!(cachep->gfpflags & GFP_DMA));
>  		else
> Index: linux-2.6.22-rc6-mm1/mm/page-writeback.c
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/mm/page-writeback.c
> +++ linux-2.6.22-rc6-mm1/mm/page-writeback.c
> @@ -122,10 +122,12 @@ static void background_writeout(unsigned
>  
>  static unsigned long highmem_dirtyable_memory(unsigned long total)
>  {
> -#ifdef CONFIG_HIGHMEM
>  	int node;
>  	unsigned long x = 0;
>  
> +	if (!is_configured_zone(ZONE_HIGHMEM))
> +		return 0;
> +
>  	for_each_online_node(node) {
>  		struct zone *z =
>  			&NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
> @@ -141,9 +143,6 @@ static unsigned long highmem_dirtyable_m
>  	 * that this does not occur.
>  	 */
>  	return min(x, total);
> -#else
> -	return 0;
> -#endif
>  }
>  
>  static unsigned long determine_dirtyable_memory(void)

-- 
-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
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] 8+ messages in thread

* Re: [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE
  2007-07-21  7:03 ` [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE KAMEZAWA Hiroyuki
  2007-07-23  7:25   ` Nick Piggin
@ 2007-07-23 13:45   ` Mel Gorman
  2007-07-24  1:28     ` KAMEZAWA Hiroyuki
  1 sibling, 1 reply; 8+ messages in thread
From: Mel Gorman @ 2007-07-23 13:45 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki
  Cc: linux-mm, apw, Andrew Morton, nickpiggin, Christoph Lameter

On (21/07/07 16:03), KAMEZAWA Hiroyuki didst pronounce:
> 
> Makes ZONE_MOVABLE as configurable
> 
> Based on "zone_ifdef_cleanup_by_renumbering.patch"
> 
> Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> 
> 
> 
> ---
>  include/linux/gfp.h    |    3 ++-
>  include/linux/mmzone.h |   11 +++++++----
>  include/linux/vmstat.h |   13 +++++++++++--
>  mm/Kconfig             |   13 +++++++++++++
>  mm/page_alloc.c        |    6 ++++++
>  mm/vmstat.c            |    8 +++++++-
>  6 files changed, 46 insertions(+), 8 deletions(-)
> 
> Index: linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/include/linux/mmzone.h
> +++ linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> @@ -177,7 +177,9 @@ enum zone_type {
>  	 */
>  	ZONE_HIGHMEM,
>  #endif
> +#ifdef CONFIG_ZONE_MOVABLE
>  	ZONE_MOVABLE,
> +#endif
>  	MAX_NR_ZONES,
>  #ifndef CONFIG_ZONE_DMA
>  	ZONE_DMA,
> @@ -188,6 +190,9 @@ enum zone_type {
>  #ifndef CONFIG_HIGHMEM
>  	ZONE_HIGHMEM,
>  #endif
> +#ifndef CONFIG_ZONE_MOVABLE
> +	ZONE_MOVABLE,
> +#endif
>  	MAX_POSSIBLE_ZONES,
>  };
>  
> @@ -567,11 +572,9 @@ static inline int zone_idx_is(enum zone_
>  
>  static inline int zone_movable_is_highmem(void)
>  {
> -#if CONFIG_ARCH_POPULATES_NODE_MAP
> -	if (is_configured_zone(ZONE_HIGHMEM))
> -		return movable_zone == ZONE_HIGHMEM;
> -#endif
> -	return 0;
> +	return is_configured_zone(ZONE_HIGHMEM) &&
> +	       is_configured_zone(ZONE_MOVABLE) &&
> +		(movable_zone == ZONE_HIGHMEM);
>  }

I think this should remain inside the check for
CONFIG_ARCH_POPULATES_NODE_MAP . movable_zone is not defined if it is
not set. While this works with a cross-compiler for ARM (doesn't use
CONFIG_ARCH_POPULATES_NODE_MAP), it's because the optimiser is getting
rid of the references as opposed to the code being correct.

>  
>  static inline int is_highmem_idx(enum zone_type idx)
> Index: linux-2.6.22-rc6-mm1/include/linux/gfp.h
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/include/linux/gfp.h
> +++ linux-2.6.22-rc6-mm1/include/linux/gfp.h
> @@ -122,7 +122,8 @@ static inline enum zone_type gfp_zone(gf
>  	if (is_configured_zone(ZONE_DMA32) && (flags & __GFP_DMA32))
>  		return ZONE_DMA32;
>  
> -	if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
> +	if (is_configured_zone(ZONE_MOVABLE) &&
> +	    (flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
>  			(__GFP_HIGHMEM | __GFP_MOVABLE))
>  		return ZONE_MOVABLE;
>  
> Index: linux-2.6.22-rc6-mm1/mm/Kconfig
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/mm/Kconfig
> +++ linux-2.6.22-rc6-mm1/mm/Kconfig
> @@ -112,6 +112,19 @@ config SPARSEMEM_EXTREME
>  	def_bool y
>  	depends on SPARSEMEM && !SPARSEMEM_STATIC
>  
> +
> +config ZONE_MOVABLE
> +	bool	"A zone for movable pages"
> +	depends on ARCH_POPULATES_NODE_MAP
> +	help
> +	  Allows creating a zone type only for movable pages, i.e page cache

e.g. instead of i.e. here

i.e. implies that only page cache and anonymous memory can use the zone.
e.g. implies that page cache and anonymous memory are just two types
that can use it.

> +	  and anonymous memory. Because movable pages are to end to be easily

Because movable pages are easily reclaimed .....

> +	  reclaimed and page migration technique can move them, your chance
> +	  for allocating big size memory will be better in this zone than

allocating contiguous memory such as huge pages will be better ....

> +  	  other zones.
> +	  To use this zone, please see "kernelcore=" or "movablecore=" in
> +	  Documentation/kernel-parameters.txt
> +
>  # eventually, we can have this option just 'select SPARSEMEM'
>  config MEMORY_HOTPLUG
>  	bool "Allow for memory hot-add"
> Index: linux-2.6.22-rc6-mm1/mm/page_alloc.c
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/mm/page_alloc.c
> +++ linux-2.6.22-rc6-mm1/mm/page_alloc.c
> @@ -86,7 +86,9 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z
>  #ifdef CONFIG_HIGHMEM
>  	 32,
>  #endif
> +#ifdef CONFIG_ZONE_MOVABLE
>  	 32,
> +#endif
>  };
>  
>  EXPORT_SYMBOL(totalram_pages);
> @@ -3883,6 +3885,10 @@ static int __init cmdline_parse_kernelco
>  	if (!p)
>  		return -EINVAL;
>  
> +	if (!is_configured_zone(ZONE_MOVABLE)) {
> +		printk ("ZONE_MOVABLE is not configured, kernelcore= is ignored.\n");
> +		return 0;
> +	}

This is a good check but bear in mind that in 2.6.23-rc1, this block of
code looks different and there is both cmdline_parse_kernelcore() and
cmdline_parse_movablecore().

>  	coremem = memparse(p, &p);
>  	required_kernelcore = coremem >> PAGE_SHIFT;
>  
> Index: linux-2.6.22-rc6-mm1/mm/vmstat.c
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/mm/vmstat.c
> +++ linux-2.6.22-rc6-mm1/mm/vmstat.c
> @@ -694,8 +694,14 @@ const struct seq_operations pagetypeinfo
>  #define TEXT_FOR_HIGHMEM(xx)
>  #endif
>  
> +#ifdef CONFIG_ZONE_MOVABLE
> +#define TEXT_FOR_MOVABLE(xx) xx "_movable",
> +#else
> +#define TEXT_FOR_MOVABLE(xx)
> +#endif
> +
>  #define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \
> -					TEXT_FOR_HIGHMEM(xx) xx "_movable",
> +					TEXT_FOR_HIGHMEM(xx) xx TEXT_FOR_MOVABLE(xx)
>  
>  static const char * const vmstat_text[] = {
>  	/* Zoned VM counters */
> Index: linux-2.6.22-rc6-mm1/include/linux/vmstat.h
> ===================================================================
> --- linux-2.6.22-rc6-mm1.orig/include/linux/vmstat.h
> +++ linux-2.6.22-rc6-mm1/include/linux/vmstat.h
> @@ -25,7 +25,14 @@
>  #define HIGHMEM_ZONE(xx)
>  #endif
>  
> -#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) , xx##_MOVABLE
> +#ifdef CONFIG_ZONE_MOVABLE
> +#define MOVABLE_ZONE(xx) , xx##_MOVABLE
> +#else
> +#define MOVABLE_ZONE(xx)
> +#endif
> +
> +
> +#define FOR_ALL_ZONES(xx) DMA_ZONE(xx) DMA32_ZONE(xx) xx##_NORMAL HIGHMEM_ZONE(xx) MOVABLE_ZONE(xx)
>  
>  enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
>  		FOR_ALL_ZONES(PGALLOC),
> @@ -170,7 +177,9 @@ static inline unsigned long node_page_st
>  	if (is_configured_zone(ZONE_HIGHMEM))
>  		val += zone_page_state(&zones[ZONE_HIGHMEM], item);
>  
> -	val += zone_page_state(&zones[ZONE_MOVABLE], item);
> +	if (is_configured_zone(ZONE_MOVABLE))
> +		val += zone_page_state(&zones[ZONE_MOVABLE], item);
> +
>  	return val;
>  }
>  

-- 
-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
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] 8+ messages in thread

* Re: [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE
  2007-07-23 13:45   ` Mel Gorman
@ 2007-07-24  1:28     ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-07-24  1:28 UTC (permalink / raw)
  To: Mel Gorman; +Cc: linux-mm, apw, Andrew Morton, nickpiggin, Christoph Lameter

On Mon, 23 Jul 2007 14:45:17 +0100
mel@skynet.ie (Mel Gorman) wrote:

> > -	return 0;
> > +	return is_configured_zone(ZONE_HIGHMEM) &&
> > +	       is_configured_zone(ZONE_MOVABLE) &&
> > +		(movable_zone == ZONE_HIGHMEM);
> >  }
> 
> I think this should remain inside the check for
> CONFIG_ARCH_POPULATES_NODE_MAP . movable_zone is not defined if it is
> not set. While this works with a cross-compiler for ARM (doesn't use
> CONFIG_ARCH_POPULATES_NODE_MAP), it's because the optimiser is getting
> rid of the references as opposed to the code being correct.

Hmm, ok.


> > +
> > +config ZONE_MOVABLE
> > +	bool	"A zone for movable pages"
> > +	depends on ARCH_POPULATES_NODE_MAP
> > +	help
> > +	  Allows creating a zone type only for movable pages, i.e page cache
> 
> e.g. instead of i.e. here
> 
> i.e. implies that only page cache and anonymous memory can use the zone.
> e.g. implies that page cache and anonymous memory are just two types
> that can use it.
> 

> > +	  and anonymous memory. Because movable pages are to end to be easily
> 
> Because movable pages are easily reclaimed .....
> 
> > +	  reclaimed and page migration technique can move them, your chance
> > +	  for allocating big size memory will be better in this zone than
> 
> allocating contiguous memory such as huge pages will be better ....
> 

thanks, I'll merge above comments.


> > +	if (!is_configured_zone(ZONE_MOVABLE)) {
> > +		printk ("ZONE_MOVABLE is not configured, kernelcore= is ignored.\n");
> > +		return 0;
> > +	}
> 
> This is a good check but bear in mind that in 2.6.23-rc1, this block of
> code looks different and there is both cmdline_parse_kernelcore() and
> cmdline_parse_movablecore().
> 
yes. ok. I'll rebase.

Thank you.
-Kame

--
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] 8+ messages in thread

* Re: [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering
  2007-07-23  7:22 ` [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering Nick Piggin
@ 2007-07-24  2:26   ` KAMEZAWA Hiroyuki
  0 siblings, 0 replies; 8+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-07-24  2:26 UTC (permalink / raw)
  To: Nick Piggin; +Cc: linux-mm, mel, apw, Andrew Morton, Christoph Lameter

On Mon, 23 Jul 2007 17:22:50 +1000
Nick Piggin <nickpiggin@yahoo.com.au> wrote:
> > This patch also replaces CONFIG_ZONE_DMA_FLAG by is_configured_zone(ZONE_DMA).
> 
> This looks nice to me. It seems like the constant folding will be pretty
> trivial for the compiler to get right -- have you verified this?
> 

Yes. I checked to some extent. It seems that the compiler does enough work.

> Could make a comment about all the names of these little functions, but I
> see that you're pretty well just following what's already there, so whoever
> thought those are nice shouldn't have a problem with your patch :)
> 
I'll add some comments.

> > 
> > Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> > 
> > ---
> >  include/linux/gfp.h    |   16 +++++-------
> >  include/linux/mmzone.h |   64 ++++++++++++++++++++++++++-----------------------
> >  include/linux/vmstat.h |   24 +++++++++---------
> >  mm/Kconfig             |    5 ---
> >  mm/page-writeback.c    |    7 ++---
> >  mm/page_alloc.c        |   37 ++++++++++++----------------
> >  mm/slab.c              |    4 +--
> >  7 files changed, 74 insertions(+), 83 deletions(-)
> > 
> > Index: linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> > ===================================================================
> > --- linux-2.6.22-rc6-mm1.orig/include/linux/mmzone.h
> > +++ linux-2.6.22-rc6-mm1/include/linux/mmzone.h
> > @@ -178,9 +178,24 @@ enum zone_type {
> >  	ZONE_HIGHMEM,
> >  #endif
> >  	ZONE_MOVABLE,
> > -	MAX_NR_ZONES
> > +	MAX_NR_ZONES,
> > +#ifndef CONFIG_ZONE_DMA
> > +	ZONE_DMA,
> > +#endif
> > +#ifndef CONFIG_ZONE_DMA32
> > +	ZONE_DMA32,
> > +#endif
> > +#ifndef CONFIG_HIGHMEM
> > +	ZONE_HIGHMEM,
> > +#endif
> > +	MAX_POSSIBLE_ZONES,
> >  };
> 
> One issue I see here is that MAX_POSSIBLE_ZONES also includes MAX_NR_ZONES
> so I think it will be off-by-one, won't it?
> 

Hmm, "MAX_NR_ZONES"  wastes one entry in array of MAX_POSSIBLE_ZONES.
But to reduce MAX_POSSIBLE_ZONES by 1, all dummy names, ZONE_DMA-not-configured,
ZONE_HIGHMEM-not-configured etc... should be adjusted.

I think this wasting is not so high cost. MAX_POSSIBLE_ZONES will not be used by
usual codes. I'll add comments about "MAX_POSSIBLE_ZONES includes MAX_NR_ZONES".

,
> > +static char * const zone_names[MAX_POSSIBLE_ZONES] = {
> > +	[ZONE_DMA] = "DMA",
> > +	[ZONE_DMA32] = "DMA32",
> > +	[ZONE_NORMAL] = "Normal",
> > +	[ZONE_HIGHMEM] = "HighMem",
> > +	[ZONE_MOVABLE] =  "Movable",
> >  };
> 
> Sweet :) I guess the slight increase in size is well worth the nice code!
> However, I think you should be able to just avoid specifying the array
> size explicitly, right?
>
Ah, yes. Then...we remove the enum of MAX_POSSIBLE_ZONES. 

> 
> > @@ -134,8 +128,8 @@ static unsigned long __meminitdata dma_r
> >  
> >    static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
> >    static int __meminitdata nr_nodemap_entries;
> > -  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
> > -  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
> > +  static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_POSSIBLE_ZONES];
> > +  static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_POSSIBLE_ZONES];
> 
> I don't quite understand why you need to make this change? AFAKS, it is wrong.
> Given that, you might be able to just get rid of MAX_POSSIBLE_ZONES completely?
> 
Ok, I'll check again. and will remove MAX_POSSIBLE_ZONES (maybe).

Thanks,
-Kame



--
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] 8+ messages in thread

end of thread, other threads:[~2007-07-24  2:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-21  7:00 [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering KAMEZAWA Hiroyuki
2007-07-21  7:03 ` [RFC][PATCH] zone config patch set [2/2] CONFIG_ZONE_MOVABLE KAMEZAWA Hiroyuki
2007-07-23  7:25   ` Nick Piggin
2007-07-23 13:45   ` Mel Gorman
2007-07-24  1:28     ` KAMEZAWA Hiroyuki
2007-07-23  7:22 ` [RFC][PATCH] zone config patch set [1/2] zone ifdef cleaunp by renumbering Nick Piggin
2007-07-24  2:26   ` KAMEZAWA Hiroyuki
2007-07-23 13:16 ` Mel Gorman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox