Merge branch 'post-2.6.15' of git://brick.kernel.dk/data/git/linux-2.6-block
[sfrench/cifs-2.6.git] / include / linux / mmzone.h
index f5fa3082fd6a56c628730c67873429f64f8d9cbb..c34f4a2c62f8e252bc9c260ebad20d419a180750 100644 (file)
@@ -46,7 +46,6 @@ struct zone_padding {
 
 struct per_cpu_pages {
        int count;              /* number of pages in the list */
-       int low;                /* low watermark, refill needed */
        int high;               /* high watermark, emptying needed */
        int batch;              /* chunk size for buddy add/remove */
        struct list_head list;  /* the list of pages */
@@ -71,10 +70,11 @@ struct per_cpu_pageset {
 #endif
 
 #define ZONE_DMA               0
-#define ZONE_NORMAL            1
-#define ZONE_HIGHMEM           2
+#define ZONE_DMA32             1
+#define ZONE_NORMAL            2
+#define ZONE_HIGHMEM           3
 
-#define MAX_NR_ZONES           3       /* Sync this with ZONES_SHIFT */
+#define MAX_NR_ZONES           4       /* Sync this with ZONES_SHIFT */
 #define ZONES_SHIFT            2       /* ceil(log2(MAX_NR_ZONES)) */
 
 
@@ -90,27 +90,18 @@ struct per_cpu_pageset {
  * will be a maximum of 4 (2 ** 2) zonelists, for 3 modifiers there will
  * be 8 (2 ** 3) zonelists.  GFP_ZONETYPES defines the number of possible
  * combinations of zone modifiers in "zone modifier space".
+ *
+ * NOTE! Make sure this matches the zones in <linux/gfp.h>
  */
-#define GFP_ZONEMASK   0x03
-/*
- * As an optimisation any zone modifier bits which are only valid when
- * no other zone modifier bits are set (loners) should be placed in
- * the highest order bits of this field.  This allows us to reduce the
- * extent of the zonelists thus saving space.  For example in the case
- * of three zone modifier bits, we could require up to eight zonelists.
- * If the left most zone modifier is a "loner" then the highest valid
- * zonelist would be four allowing us to allocate only five zonelists.
- * Use the first form when the left most bit is not a "loner", otherwise
- * use the second.
- */
-/* #define GFP_ZONETYPES       (GFP_ZONEMASK + 1) */           /* Non-loner */
-#define GFP_ZONETYPES  ((GFP_ZONEMASK + 1) / 2 + 1)            /* Loner */
+#define GFP_ZONEMASK   0x07
+#define GFP_ZONETYPES  5
 
 /*
  * On machines where it is needed (eg PCs) we divide physical memory
- * into multiple physical zones. On a PC we have 3 zones:
+ * into multiple physical zones. On a 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
  */
@@ -329,7 +320,7 @@ void get_zone_counts(unsigned long *active, unsigned long *inactive,
 void build_all_zonelists(void);
 void wakeup_kswapd(struct zone *zone, int order);
 int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
-               int alloc_type, int can_try_harder, gfp_t gfp_high);
+               int classzone_idx, int alloc_flags);
 
 #ifdef CONFIG_HAVE_MEMORY_PRESENT
 void memory_present(int nid, unsigned long start, unsigned long end);
@@ -397,6 +388,11 @@ static inline struct zone *next_zone(struct zone *zone)
 #define for_each_zone(zone) \
        for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone))
 
+static inline int populated_zone(struct zone *zone)
+{
+       return (!!zone->present_pages);
+}
+
 static inline int is_highmem_idx(int idx)
 {
        return (idx == ZONE_HIGHMEM);
@@ -406,6 +402,7 @@ static inline int is_normal_idx(int idx)
 {
        return (idx == ZONE_NORMAL);
 }
+
 /**
  * is_highmem - helper function to quickly check if a struct zone is a 
  *              highmem zone or not.  This is an attempt to keep references
@@ -422,6 +419,16 @@ static inline int is_normal(struct zone *zone)
        return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
 }
 
+static inline int is_dma32(struct zone *zone)
+{
+       return zone == zone->zone_pgdat->node_zones + ZONE_DMA32;
+}
+
+static inline int is_dma(struct zone *zone)
+{
+       return zone == zone->zone_pgdat->node_zones + ZONE_DMA;
+}
+
 /* These two functions are used to setup the per zone pages min values */
 struct ctl_table;
 struct file;
@@ -433,7 +440,9 @@ int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *,
 
 #include <linux/topology.h>
 /* Returns the number of the current Node. */
+#ifndef numa_node_id
 #define numa_node_id()         (cpu_to_node(raw_smp_processor_id()))
+#endif
 
 #ifndef CONFIG_NEED_MULTIPLE_NODES
 
@@ -441,7 +450,6 @@ extern struct pglist_data contig_page_data;
 #define NODE_DATA(nid)         (&contig_page_data)
 #define NODE_MEM_MAP(nid)      mem_map
 #define MAX_NODES_SHIFT                1
-#define pfn_to_nid(pfn)                (0)
 
 #else /* CONFIG_NEED_MULTIPLE_NODES */
 
@@ -453,12 +461,12 @@ extern struct pglist_data contig_page_data;
 #include <asm/sparsemem.h>
 #endif
 
-#if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED)
+#if BITS_PER_LONG == 32
 /*
- * with 32 bit page->flags field, we reserve 8 bits for node/zone info.
- * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes.
+ * 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         8
+#define FLAGS_RESERVED         9
 
 #elif BITS_PER_LONG == 64
 /*
@@ -476,6 +484,10 @@ extern struct pglist_data contig_page_data;
 #define early_pfn_to_nid(nid)  (0UL)
 #endif
 
+#ifdef CONFIG_FLATMEM
+#define pfn_to_nid(pfn)                (0)
+#endif
+
 #define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT)
 #define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT)
 
@@ -570,11 +582,6 @@ static inline int valid_section_nr(unsigned long nr)
        return valid_section(__nr_to_section(nr));
 }
 
-/*
- * Given a kernel address, find the home node of the underlying memory.
- */
-#define kvaddr_to_nid(kaddr)   pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
-
 static inline struct mem_section *__pfn_to_section(unsigned long pfn)
 {
        return __nr_to_section(pfn_to_section_nr(pfn));
@@ -604,13 +611,14 @@ static inline int pfn_valid(unsigned long pfn)
  * this restriction.
  */
 #ifdef CONFIG_NUMA
-#define pfn_to_nid             early_pfn_to_nid
-#endif
-
-#define pfn_to_pgdat(pfn)                                              \
+#define pfn_to_nid(pfn)                                                        \
 ({                                                                     \
-       NODE_DATA(pfn_to_nid(pfn));                                     \
+       unsigned long __pfn_to_nid_pfn = (pfn);                         \
+       page_to_nid(pfn_to_page(__pfn_to_nid_pfn));                     \
 })
+#else
+#define pfn_to_nid(pfn)                (0)
+#endif
 
 #define early_pfn_valid(pfn)   pfn_valid(pfn)
 void sparse_init(void);
@@ -619,12 +627,6 @@ void sparse_init(void);
 #define sparse_index_init(_sec, _nid)  do {} while (0)
 #endif /* CONFIG_SPARSEMEM */
 
-#ifdef CONFIG_NODES_SPAN_OTHER_NODES
-#define early_pfn_in_nid(pfn, nid)     (early_pfn_to_nid(pfn) == (nid))
-#else
-#define early_pfn_in_nid(pfn, nid)     (1)
-#endif
-
 #ifndef early_pfn_valid
 #define early_pfn_valid(pfn)   (1)
 #endif