Commit c00eb15a authored by Yaowei Bai's avatar Yaowei Bai Committed by Linus Torvalds

mm/zonelist: enumerate zonelists array index

Hardcoding index to zonelists array in gfp_zonelist() is not a good
idea, let's enumerate it to improve readability.

No functional change.

[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: fix CONFIG_NUMA=n build]
[n-horiguchi@ah.jp.nec.com: fix warning in comparing enumerator]
Signed-off-by: default avatarYaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 06640290
...@@ -384,10 +384,11 @@ static inline enum zone_type gfp_zone(gfp_t flags) ...@@ -384,10 +384,11 @@ static inline enum zone_type gfp_zone(gfp_t flags)
static inline int gfp_zonelist(gfp_t flags) static inline int gfp_zonelist(gfp_t flags)
{ {
if (IS_ENABLED(CONFIG_NUMA) && unlikely(flags & __GFP_THISNODE)) #ifdef CONFIG_NUMA
return 1; if (unlikely(flags & __GFP_THISNODE))
return ZONELIST_NOFALLBACK;
return 0; #endif
return ZONELIST_FALLBACK;
} }
/* /*
......
...@@ -571,19 +571,17 @@ static inline bool zone_is_empty(struct zone *zone) ...@@ -571,19 +571,17 @@ static inline bool zone_is_empty(struct zone *zone)
/* Maximum number of zones on a zonelist */ /* Maximum number of zones on a zonelist */
#define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES) #define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)
enum {
ZONELIST_FALLBACK, /* zonelist with fallback */
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
/*
/* * The NUMA zonelists are doubled because we need zonelists that
* The NUMA zonelists are doubled because we need zonelists that restrict the * restrict the allocations to a single node for __GFP_THISNODE.
* allocations to a single node for __GFP_THISNODE. */
* ZONELIST_NOFALLBACK, /* zonelist without fallback (__GFP_THISNODE) */
* [0] : Zonelist with fallback
* [1] : No fallback (__GFP_THISNODE)
*/
#define MAX_ZONELISTS 2
#else
#define MAX_ZONELISTS 1
#endif #endif
MAX_ZONELISTS
};
/* /*
* This struct contains information about a zone in a zonelist. It is stored * This struct contains information about a zone in a zonelist. It is stored
......
...@@ -4148,8 +4148,7 @@ static void set_zonelist_order(void) ...@@ -4148,8 +4148,7 @@ static void set_zonelist_order(void)
static void build_zonelists(pg_data_t *pgdat) static void build_zonelists(pg_data_t *pgdat)
{ {
int j, node, load; int i, node, load;
enum zone_type i;
nodemask_t used_mask; nodemask_t used_mask;
int local_node, prev_node; int local_node, prev_node;
struct zonelist *zonelist; struct zonelist *zonelist;
...@@ -4169,7 +4168,7 @@ static void build_zonelists(pg_data_t *pgdat) ...@@ -4169,7 +4168,7 @@ static void build_zonelists(pg_data_t *pgdat)
nodes_clear(used_mask); nodes_clear(used_mask);
memset(node_order, 0, sizeof(node_order)); memset(node_order, 0, sizeof(node_order));
j = 0; i = 0;
while ((node = find_next_best_node(local_node, &used_mask)) >= 0) { while ((node = find_next_best_node(local_node, &used_mask)) >= 0) {
/* /*
...@@ -4186,12 +4185,12 @@ static void build_zonelists(pg_data_t *pgdat) ...@@ -4186,12 +4185,12 @@ static void build_zonelists(pg_data_t *pgdat)
if (order == ZONELIST_ORDER_NODE) if (order == ZONELIST_ORDER_NODE)
build_zonelists_in_node_order(pgdat, node); build_zonelists_in_node_order(pgdat, node);
else else
node_order[j++] = node; /* remember order */ node_order[i++] = node; /* remember order */
} }
if (order == ZONELIST_ORDER_ZONE) { if (order == ZONELIST_ORDER_ZONE) {
/* calculate node order -- i.e., DMA last! */ /* calculate node order -- i.e., DMA last! */
build_zonelists_in_zone_order(pgdat, j); build_zonelists_in_zone_order(pgdat, i);
} }
build_thisnode_zonelists(pgdat); build_thisnode_zonelists(pgdat);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment