*
  * If the zonelist cache is present in the passed in zonelist, then
  * returns a pointer to the allowed node mask (either the current
- * tasks mems_allowed, or node_online_map.)
+ * tasks mems_allowed, or node_states[N_HIGH_MEMORY].)
  *
  * If the zonelist cache is not available for this zonelist, does
  * nothing and returns NULL.
 
        allowednodes = !in_interrupt() && (alloc_flags & ALLOC_CPUSET) ?
                                        &cpuset_current_mems_allowed :
-                                       &node_online_map;
+                                       &node_states[N_HIGH_MEMORY];
        return allowednodes;
 }
 
                return node;
        }
 
-       for_each_online_node(n) {
+       for_each_node_state(n, N_HIGH_MEMORY) {
                cpumask_t tmp;
 
                /* Don't want a node to appear more than once */
         * If there is a node whose DMA/DMA32 memory is very big area on
         * local memory, NODE_ORDER may be suitable.
          */
-       average_size = total_size / (num_online_nodes() + 1);
+       average_size = total_size /
+                               (nodes_weight(node_states[N_HIGH_MEMORY]) + 1);
        for_each_online_node(nid) {
                low_kmem_size = 0;
                total_size = 0;
 
 #endif /* CONFIG_NUMA */
 
-/* Any regular memory on that node ? */
-static void check_for_regular_memory(pg_data_t *pgdat)
-{
-#ifdef CONFIG_HIGHMEM
-       enum zone_type zone_type;
-
-       for (zone_type = 0; zone_type <= ZONE_NORMAL; zone_type++) {
-               struct zone *zone = &pgdat->node_zones[zone_type];
-               if (zone->present_pages)
-                       node_set_state(zone_to_nid(zone), N_NORMAL_MEMORY);
-       }
-#endif
-}
-
 /* return values int ....just for stop_machine_run() */
 static int __build_all_zonelists(void *dummy)
 {
 
                build_zonelists(pgdat);
                build_zonelist_cache(pgdat);
-
-               /* Any memory on that node */
-               if (pgdat->node_present_pages)
-                       node_set_state(nid, N_HIGH_MEMORY);
-               check_for_regular_memory(pgdat);
        }
        return 0;
 }
        return max_pfn;
 }
 
+/*
+ * early_calculate_totalpages()
+ * Sum pages in active regions for movable zone.
+ * Populate N_HIGH_MEMORY for calculating usable_nodes.
+ */
 unsigned long __init early_calculate_totalpages(void)
 {
        int i;
        unsigned long totalpages = 0;
 
-       for (i = 0; i < nr_nodemap_entries; i++)
-               totalpages += early_node_map[i].end_pfn -
+       for (i = 0; i < nr_nodemap_entries; i++) {
+               unsigned long pages = early_node_map[i].end_pfn -
                                                early_node_map[i].start_pfn;
-
-       return totalpages;
+               totalpages += pages;
+               if (pages)
+                       node_set_state(early_node_map[i].nid, N_HIGH_MEMORY);
+       }
+       return totalpages;
 }
 
 /*
        int i, nid;
        unsigned long usable_startpfn;
        unsigned long kernelcore_node, kernelcore_remaining;
-       int usable_nodes = num_online_nodes();
+       unsigned long totalpages = early_calculate_totalpages();
+       int usable_nodes = nodes_weight(node_states[N_HIGH_MEMORY]);
 
        /*
         * If movablecore was specified, calculate what size of
         * what movablecore would have allowed.
         */
        if (required_movablecore) {
-               unsigned long totalpages = early_calculate_totalpages();
                unsigned long corepages;
 
                /*
 restart:
        /* Spread kernelcore memory as evenly as possible throughout nodes */
        kernelcore_node = required_kernelcore / usable_nodes;
-       for_each_online_node(nid) {
+       for_each_node_state(nid, N_HIGH_MEMORY) {
                /*
                 * Recalculate kernelcore_node if the division per node
                 * now exceeds what is necessary to satisfy the requested
                        roundup(zone_movable_pfn[nid], MAX_ORDER_NR_PAGES);
 }
 
+/* Any regular memory on that node ? */
+static void check_for_regular_memory(pg_data_t *pgdat)
+{
+#ifdef CONFIG_HIGHMEM
+       enum zone_type zone_type;
+
+       for (zone_type = 0; zone_type <= ZONE_NORMAL; zone_type++) {
+               struct zone *zone = &pgdat->node_zones[zone_type];
+               if (zone->present_pages)
+                       node_set_state(zone_to_nid(zone), N_NORMAL_MEMORY);
+       }
+#endif
+}
+
 /**
  * free_area_init_nodes - Initialise all pg_data_t and zone data
  * @max_zone_pfn: an array of max PFNs for each zone
                pg_data_t *pgdat = NODE_DATA(nid);
                free_area_init_node(nid, pgdat, NULL,
                                find_min_pfn_for_node(nid), NULL);
+
+               /* Any memory on that node */
+               if (pgdat->node_present_pages)
+                       node_set_state(nid, N_HIGH_MEMORY);
+               check_for_regular_memory(pgdat);
        }
 }
 
 
                *nodelist++ = '\0';
                if (nodelist_parse(nodelist, *policy_nodes))
                        goto out;
-               if (!nodes_subset(*policy_nodes, node_online_map))
+               if (!nodes_subset(*policy_nodes, node_states[N_HIGH_MEMORY]))
                        goto out;
        }
        if (!strcmp(value, "default")) {
                        err = 0;
        } else if (!strcmp(value, "interleave")) {
                *policy = MPOL_INTERLEAVE;
-               /* Default to nodes online if no nodelist */
+               /*
+                * Default to online nodes with memory if no nodelist
+                */
                if (!nodelist)
-                       *policy_nodes = node_online_map;
+                       *policy_nodes = node_states[N_HIGH_MEMORY];
                err = 0;
        }
 out:
        return page;
 }
 #else
-static inline int shmem_parse_mpol(char *value, int *policy, nodemask_t *policy_nodes)
+static inline int shmem_parse_mpol(char *value, int *policy,
+                                               nodemask_t *policy_nodes)
 {
        return 1;
 }
        unsigned long blocks = 0;
        unsigned long inodes = 0;
        int policy = MPOL_DEFAULT;
-       nodemask_t policy_nodes = node_online_map;
+       nodemask_t policy_nodes = node_states[N_HIGH_MEMORY];
 
 #ifdef CONFIG_TMPFS
        /*