mm: page_alloc: generalize the dirty balance reserve
[cascardo/linux.git] / include / linux / mmzone.h
index e326843..33bb1b1 100644 (file)
 
 enum {
        MIGRATE_UNMOVABLE,
-       MIGRATE_RECLAIMABLE,
        MIGRATE_MOVABLE,
+       MIGRATE_RECLAIMABLE,
        MIGRATE_PCPTYPES,       /* the number of types on the pcp lists */
-       MIGRATE_RESERVE = MIGRATE_PCPTYPES,
+       MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES,
 #ifdef CONFIG_CMA
        /*
         * MIGRATE_CMA migration type is designed to mimic the way
@@ -195,11 +195,6 @@ static inline int is_active_lru(enum lru_list lru)
        return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE);
 }
 
-static inline int is_unevictable_lru(enum lru_list lru)
-{
-       return (lru == LRU_UNEVICTABLE);
-}
-
 struct zone_reclaim_stat {
        /*
         * The pageout code in vmscan.c keeps track of how many of the
@@ -334,13 +329,16 @@ struct zone {
        /* zone watermarks, access with *_wmark_pages(zone) macros */
        unsigned long watermark[NR_WMARK];
 
+       unsigned long nr_reserved_highatomic;
+
        /*
-        * We don't know if the memory that we're going to allocate will be freeable
-        * or/and it will be released eventually, so to avoid totally wasting several
-        * GB of ram we must reserve some of the lower zone memory (otherwise we risk
-        * to run OOM on the lower zones despite there's tons of freeable ram
-        * on the higher zones). This array is recalculated at runtime if the
-        * sysctl_lowmem_reserve_ratio sysctl changes.
+        * We don't know if the memory that we're going to allocate will be
+        * freeable or/and it will be released eventually, so to avoid totally
+        * wasting several GB of ram we must reserve some of the lower zone
+        * memory (otherwise we risk to run OOM on the lower zones despite
+        * there being tons of freeable ram on the higher zones).  This array is
+        * recalculated at runtime if the sysctl_lowmem_reserve_ratio sysctl
+        * changes.
         */
        long lowmem_reserve[MAX_NR_ZONES];
 
@@ -358,10 +356,10 @@ struct zone {
        struct per_cpu_pageset __percpu *pageset;
 
        /*
-        * This is a per-zone reserve of pages that should not be
-        * considered dirtyable memory.
+        * This is a per-zone reserve of pages that are not available
+        * to userspace allocations.
         */
-       unsigned long           dirty_balance_reserve;
+       unsigned long           totalreserve_pages;
 
 #ifndef CONFIG_SPARSEMEM
        /*
@@ -429,12 +427,6 @@ struct zone {
 
        const char              *name;
 
-       /*
-        * Number of MIGRATE_RESERVE page block. To maintain for just
-        * optimization. Protected by zone->lock.
-        */
-       int                     nr_migrate_reserve_block;
-
 #ifdef CONFIG_MEMORY_ISOLATION
        /*
         * Number of isolated pageblock. It is used to solve incorrect
@@ -579,86 +571,17 @@ static inline bool zone_is_empty(struct zone *zone)
 /* Maximum number of zones on a zonelist */
 #define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)
 
+enum {
+       ZONELIST_FALLBACK,      /* zonelist with fallback */
 #ifdef CONFIG_NUMA
-
-/*
- * The NUMA zonelists are doubled because we need zonelists that restrict the
- * allocations to a single node for __GFP_THISNODE.
- *
- * [0] : Zonelist with fallback
- * [1] : No fallback (__GFP_THISNODE)
- */
-#define MAX_ZONELISTS 2
-
-
-/*
- * We cache key information from each zonelist for smaller cache
- * footprint when scanning for free pages in get_page_from_freelist().
- *
- * 1) The BITMAP fullzones tracks which zones in a zonelist have come
- *    up short of free memory since the last time (last_fullzone_zap)
- *    we zero'd fullzones.
- * 2) The array z_to_n[] maps each zone in the zonelist to its node
- *    id, so that we can efficiently evaluate whether that node is
- *    set in the current tasks mems_allowed.
- *
- * Both fullzones and z_to_n[] are one-to-one with the zonelist,
- * indexed by a zones offset in the zonelist zones[] array.
- *
- * The get_page_from_freelist() routine does two scans.  During the
- * first scan, we skip zones whose corresponding bit in 'fullzones'
- * is set or whose corresponding node in current->mems_allowed (which
- * comes from cpusets) is not set.  During the second scan, we bypass
- * this zonelist_cache, to ensure we look methodically at each zone.
- *
- * Once per second, we zero out (zap) fullzones, forcing us to
- * reconsider nodes that might have regained more free memory.
- * The field last_full_zap is the time we last zapped fullzones.
- *
- * This mechanism reduces the amount of time we waste repeatedly
- * reexaming zones for free memory when they just came up low on
- * memory momentarilly ago.
- *
- * The zonelist_cache struct members logically belong in struct
- * zonelist.  However, the mempolicy zonelists constructed for
- * MPOL_BIND are intentionally variable length (and usually much
- * shorter).  A general purpose mechanism for handling structs with
- * multiple variable length members is more mechanism than we want
- * here.  We resort to some special case hackery instead.
- *
- * The MPOL_BIND zonelists don't need this zonelist_cache (in good
- * part because they are shorter), so we put the fixed length stuff
- * at the front of the zonelist struct, ending in a variable length
- * zones[], as is needed by MPOL_BIND.
- *
- * Then we put the optional zonelist cache on the end of the zonelist
- * struct.  This optional stuff is found by a 'zlcache_ptr' pointer in
- * the fixed length portion at the front of the struct.  This pointer
- * both enables us to find the zonelist cache, and in the case of
- * MPOL_BIND zonelists, (which will just set the zlcache_ptr to NULL)
- * to know that the zonelist cache is not there.
- *
- * The end result is that struct zonelists come in two flavors:
- *  1) The full, fixed length version, shown below, and
- *  2) The custom zonelists for MPOL_BIND.
- * The custom MPOL_BIND zonelists have a NULL zlcache_ptr and no zlcache.
- *
- * Even though there may be multiple CPU cores on a node modifying
- * fullzones or last_full_zap in the same zonelist_cache at the same
- * time, we don't lock it.  This is just hint data - if it is wrong now
- * and then, the allocator will still function, perhaps a bit slower.
- */
-
-
-struct zonelist_cache {
-       unsigned short z_to_n[MAX_ZONES_PER_ZONELIST];          /* zone->nid */
-       DECLARE_BITMAP(fullzones, MAX_ZONES_PER_ZONELIST);      /* zone full? */
-       unsigned long last_full_zap;            /* when last zap'd (jiffies) */
-};
-#else
-#define MAX_ZONELISTS 1
-struct zonelist_cache;
+       /*
+        * The NUMA zonelists are doubled because we need zonelists that
+        * restrict the allocations to a single node for __GFP_THISNODE.
+        */
+       ZONELIST_NOFALLBACK,    /* zonelist without fallback (__GFP_THISNODE) */
 #endif
+       MAX_ZONELISTS
+};
 
 /*
  * This struct contains information about a zone in a zonelist. It is stored
@@ -675,9 +598,6 @@ struct zoneref {
  * allocation, the other zones are fallback zones, in decreasing
  * priority.
  *
- * If zlcache_ptr is not NULL, then it is just the address of zlcache,
- * as explained above.  If zlcache_ptr is NULL, there is no zlcache.
- * *
  * To speed the reading of the zonelist, the zonerefs contain the zone index
  * of the entry being read. Helper functions to access information given
  * a struct zoneref are
@@ -687,11 +607,7 @@ struct zoneref {
  * zonelist_node_idx() - Return the index of the node for an entry
  */
 struct zonelist {
-       struct zonelist_cache *zlcache_ptr;                  // NULL or &zlcache
        struct zoneref _zonerefs[MAX_ZONES_PER_ZONELIST + 1];
-#ifdef CONFIG_NUMA
-       struct zonelist_cache zlcache;                       // optional ...
-#endif
 };
 
 #ifndef CONFIG_DISCONTIGMEM
@@ -1284,13 +1200,13 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
  * the zone and PFN linkages are still valid. This is expensive, but walkers
  * of the full memmap are extremely rare.
  */
-int memmap_valid_within(unsigned long pfn,
+bool memmap_valid_within(unsigned long pfn,
                                        struct page *page, struct zone *zone);
 #else
-static inline int memmap_valid_within(unsigned long pfn,
+static inline bool memmap_valid_within(unsigned long pfn,
                                        struct page *page, struct zone *zone)
 {
-       return 1;
+       return true;
 }
 #endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */