From: Christoph Lameter Subject: Pageflags: Get rid of FLAGS_RESERVED NR_PAGEFLAGS specifies the number of page flags we are using. From that we can calculate the number of bits leftover that can be used for zone, node (and maybe the sections id). There is no need anymore for FLAGS_RESERVED if we use NR_PAGEFLAGS. Use the new methods to make NR_PAGEFLAGS available via the preprocessor. NR_PAGEFLAGS is used to calculate field boundaries in the page flags fields. These field widths have to be available to the preprocessor. Signed-off-by: Christoph Lameter --- arch/sparc64/mm/init.c | 5 +++-- include/linux/mm.h | 6 +++--- include/linux/mmzone.h | 19 ------------------- include/linux/page-flags.h | 19 ++++++++++++------- kernel/bounds.c | 2 ++ 5 files changed, 20 insertions(+), 31 deletions(-) Index: linux-2.6.25-rc5-mm1/include/linux/mm.h =================================================================== --- linux-2.6.25-rc5-mm1.orig/include/linux/mm.h 2008-03-20 12:28:20.475763203 -0700 +++ linux-2.6.25-rc5-mm1/include/linux/mm.h 2008-03-20 12:57:46.606137879 -0700 @@ -398,7 +398,7 @@ static inline void set_compound_order(st #define ZONES_WIDTH ZONES_SHIFT -#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= FLAGS_RESERVED +#if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS #define NODES_WIDTH NODES_SHIFT #else #ifdef CONFIG_SPARSEMEM_VMEMMAP @@ -446,8 +446,8 @@ static inline void set_compound_order(st #define ZONEID_PGSHIFT (ZONEID_PGOFF * (ZONEID_SHIFT != 0)) -#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED -#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED +#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS +#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > BITS_PER_LONG - NR_PAGEFLAGS #endif #define ZONES_MASK ((1UL << ZONES_WIDTH) - 1) Index: linux-2.6.25-rc5-mm1/include/linux/mmzone.h =================================================================== --- linux-2.6.25-rc5-mm1.orig/include/linux/mmzone.h 2008-03-20 12:27:31.224540190 -0700 +++ linux-2.6.25-rc5-mm1/include/linux/mmzone.h 2008-03-20 12:57:46.606137879 -0700 @@ -839,25 +839,6 @@ static inline struct zoneref *next_zones #include #endif -#if BITS_PER_LONG == 32 -/* - * with 32 bit page->flags field, we reserve 9 bits for node/zone info. - * there are 4 zones (3 bits) and this leaves 9-3=6 bits for nodes. - */ -#define FLAGS_RESERVED 9 - -#elif BITS_PER_LONG == 64 -/* - * with 64 bit flags field, there's plenty of room. - */ -#define FLAGS_RESERVED 32 - -#else - -#error BITS_PER_LONG not defined - -#endif - #if !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) && \ !defined(CONFIG_ARCH_POPULATES_NODE_MAP) #define early_pfn_to_nid(nid) (0UL) Index: linux-2.6.25-rc5-mm1/include/linux/page-flags.h =================================================================== --- linux-2.6.25-rc5-mm1.orig/include/linux/page-flags.h 2008-03-20 12:34:14.488025658 -0700 +++ linux-2.6.25-rc5-mm1/include/linux/page-flags.h 2008-03-20 12:57:46.610137790 -0700 @@ -6,7 +6,10 @@ #define PAGE_FLAGS_H #include +#ifndef __GENERATING_BOUNDS_H #include +#include +#endif /* !__GENERATING_BOUNDS_H */ /* * Various page->flags bits: @@ -59,13 +62,12 @@ * extends from the high bits downwards. * * | FIELD | ... | FLAGS | - * N-1 ^ 0 - * (N-FLAGS_RESERVED) + * N-1 ^ 0 + * (NR_PAGEFLAGS) * - * The fields area is reserved for fields mapping zone, node and SPARSEMEM - * section. The boundry between these two areas is defined by - * FLAGS_RESERVED which defines the width of the fields section - * (see linux/mmzone.h). New flags must _not_ overlap with this area. + * The fields area is reserved for fields mapping zone, node (for NUMA) and + * SPARSEMEM section (for variants of SPARSEMEM that require section ids like + * SPARSEMEM_EXTREME with !SPARSEMEM_VMEMMAP). */ enum pageflags { PG_locked, /* Page is locked. Don't touch. */ @@ -104,9 +106,11 @@ enum pageflags { */ PG_uncached = 31, /* Page has been mapped as uncached */ #endif - NR_PAGEFLAGS + __NR_PAGEFLAGS }; +#ifndef __GENERATING_BOUNDS_H + /* * Manipulation of page state flags */ @@ -307,4 +311,5 @@ static inline void set_page_writeback(st test_set_page_writeback(page); } +#endif /* !__GENERATING_BOUNDS_H */ #endif /* PAGE_FLAGS_H */ Index: linux-2.6.25-rc5-mm1/kernel/bounds.c =================================================================== --- linux-2.6.25-rc5-mm1.orig/kernel/bounds.c 2008-03-20 12:29:09.683018563 -0700 +++ linux-2.6.25-rc5-mm1/kernel/bounds.c 2008-03-20 12:57:46.610137790 -0700 @@ -6,6 +6,7 @@ #define __GENERATING_BOUNDS_H /* Include headers that define the enum constants of interest */ +#include #define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val)) @@ -15,5 +16,6 @@ void foo(void) { /* The enum constants to put into include/linux/bounds.h */ + DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS); /* End of constants */ } Index: linux-2.6.25-rc5-mm1/arch/sparc64/mm/init.c =================================================================== --- linux-2.6.25-rc5-mm1.orig/arch/sparc64/mm/init.c 2008-03-20 12:27:31.256539893 -0700 +++ linux-2.6.25-rc5-mm1/arch/sparc64/mm/init.c 2008-03-20 12:57:46.610137790 -0700 @@ -1310,9 +1310,10 @@ void __init paging_init(void) * functions like clear_dcache_dirty_cpu use the cpu mask * in 13-bit signed-immediate instruction fields. */ - BUILD_BUG_ON(FLAGS_RESERVED != 32); + BUILD_BUG_ON(BITS_PER_LONG - NR_PAGEFLAGS != 32); BUILD_BUG_ON(SECTIONS_WIDTH + NODES_WIDTH + ZONES_WIDTH + - ilog2(roundup_pow_of_two(NR_CPUS)) > FLAGS_RESERVED); + ilog2(roundup_pow_of_two(NR_CPUS)) > + BITS_PER_LONG - NR_PAGEFLAGS); BUILD_BUG_ON(NR_CPUS > 4096); kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;