Skip to content

Commit

Permalink
mm/zonelist: enumerate zonelists array index
Browse files Browse the repository at this point in the history
Hardcoding index to zonelists array in gfp_zonelist() is not a good idea,
let's enumerate it to improve readability.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Yaowei Bai authored and sfrothwell committed Dec 11, 2015
1 parent 34fa1fc commit 92d7625
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions include/linux/gfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ static inline enum zone_type gfp_zone(gfp_t flags)
static inline int gfp_zonelist(gfp_t flags)
{
if (IS_ENABLED(CONFIG_NUMA) && unlikely(flags & __GFP_THISNODE))
return 1;
return ZONELIST_NOFALLBACK;

return 0;
return ZONELIST_FALLBACK;
}

/*
Expand Down
20 changes: 9 additions & 11 deletions include/linux/mmzone.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,19 +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
#else
#define MAX_ZONELISTS 1
/*
* 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
Expand Down

0 comments on commit 92d7625

Please sign in to comment.