[PATCH v2 5/6] mm: Introduce for_each_zone_nid()

From: David Hildenbrand
Date: Mon Aug 26 2019 - 06:10:48 EST


Allow to iterate all zones belonging to a nid.

Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Vlastimil Babka <vbabka@xxxxxxx>
Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Wei Yang <richard.weiyang@xxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Arun KS <arunks@xxxxxxxxxxxxxx>
Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
---
include/linux/mmzone.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 8b5f758942a2..71f2b9b55069 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1004,6 +1004,11 @@ extern struct zone *next_zone(struct zone *zone);
; /* do nothing */ \
else

+#define for_each_zone_nid(zone, nid) \
+ for (zone = (NODE_DATA(nid))->node_zones; \
+ zone && zone_to_nid(zone) == nid; \
+ zone = next_zone(zone))
+
static inline struct zone *zonelist_zone(struct zoneref *zoneref)
{
return zoneref->zone;
--
2.21.0