[PATCH 09/11] Make ZONE_HIGHMEM optional

From: Christoph Lameter
Date: Fri Jul 07 2006 - 19:21:13 EST


Make ZONE_HIGHMEM optional

- ifdef out code and definitions related to CONFIG_HIGHMEM

- __GFP_HIGHMEM falls back to normal allocations if there is no
ZONE_HIGHMEM

- GFP_ZONEMASK becomes 0x01 if there is no DMA32 and no HIGHMEM
zone.

Signed-off-by: Christoph Lameter <clameter@xxxxxxx>

Index: linux-2.6.17-mm6/include/linux/gfp.h
===================================================================
--- linux-2.6.17-mm6.orig/include/linux/gfp.h 2006-07-07 15:07:48.199517409 -0700
+++ linux-2.6.17-mm6/include/linux/gfp.h 2006-07-07 15:07:51.984440142 -0700
@@ -12,7 +12,13 @@ struct vm_area_struct;
*/
/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low three bits) */
#define __GFP_DMA ((__force gfp_t)0x01u)
+
+#ifdef CONFIG_HIGHMEM
#define __GFP_HIGHMEM ((__force gfp_t)0x02u)
+#else
+#define __GFP_HIGHMEM ((__force gfp_t)0x00) /* NORMAL is HIGHMEM */
+#endif
+
#ifndef CONFIG_ZONE_DMA32
#define __GFP_DMA32 ((__force gfp_t)0x01) /* ZONE_DMA is ZONE_DMA32 */
#elif BITS_PER_LONG < 64
Index: linux-2.6.17-mm6/mm/page_alloc.c
===================================================================
--- linux-2.6.17-mm6.orig/mm/page_alloc.c 2006-07-07 15:07:48.160457319 -0700
+++ linux-2.6.17-mm6/mm/page_alloc.c 2006-07-07 15:07:51.986393146 -0700
@@ -73,7 +73,9 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_Z
#ifdef CONFIG_ZONE_DMA32
256,
#endif
+#ifdef CONFIG_HIGHMEM
32
+#endif
};

EXPORT_SYMBOL(totalram_pages);
@@ -91,7 +93,9 @@ static char *zone_names[MAX_NR_ZONES] =
"DMA32",
#endif
"Normal",
+#ifdef CONFIG_HIGHMEM
"HighMem"
+#endif
};

int min_free_kbytes = 1024;
@@ -1473,8 +1477,10 @@ static int __meminit build_zonelists_nod
static inline int highest_zone(int zone_bits)
{
int res = ZONE_NORMAL;
+#ifdef CONFIG_HIGHMEM
if (zone_bits & (__force int)__GFP_HIGHMEM)
res = ZONE_HIGHMEM;
+#endif
#ifdef CONFIG_ZONE_DMA32
if (zone_bits & (__force int)__GFP_DMA32)
res = ZONE_DMA32;
Index: linux-2.6.17-mm6/include/linux/mmzone.h
===================================================================
--- linux-2.6.17-mm6.orig/include/linux/mmzone.h 2006-07-07 15:07:48.161433821 -0700
+++ linux-2.6.17-mm6/include/linux/mmzone.h 2006-07-07 15:07:51.987369648 -0700
@@ -122,6 +122,7 @@ typedef enum {
* 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
@@ -131,11 +132,10 @@ typedef enum {
* access.
*/
ZONE_HIGHMEM,
-
+#endif
MAX_NR_ZONES
} zones_t;

-#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */

/*
* When a memory allocation must conform to specific limitations (such
@@ -166,8 +166,15 @@ typedef enum {

#ifdef CONFIG_ZONE_DMA32
#define GFP_ZONEMASK 0x07
+#define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */
#else
+#ifdef CONFIG_HIGHMEM
#define GFP_ZONEMASK 0x03
+#define ZONES_SHIFT 2
+#else
+#define GFP_ZONEMASK 0x01
+#define ZONES_SHIFT 1
+#endif
#endif

struct zone {
@@ -414,7 +421,11 @@ static inline int populated_zone(struct

static inline int is_highmem_idx(zones_t idx)
{
+#ifdef CONFIG_HIGHMEM
return (idx == ZONE_HIGHMEM);
+#else
+ return 0;
+#endif
}

static inline int is_normal_idx(zones_t idx)
@@ -430,7 +441,11 @@ static inline int is_normal_idx(zones_t
*/
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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/