Skip to contentSkip to conversation

mm: use zonelist_zone() to get zone

PATCH Superseded Wei Yang 3 participants 4 messages Jul 6, 2024 – Jul 9, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm: use zonelist_zone() to get zone

Instead of accessing zoneref->zone directly, use zonelist_zone() like other places for consistency.

No functional change.

CC Mike Rapoport (IBM) <[email protected]>
CC David Hildenbrand <[email protected]>
---
 include/linux/mmzone.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mmzone.h +2 -2
index cb7f265c2b96..51bce636373f 100644
@@ -1690,7 +1690,7 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
 			zone = zonelist_zone(z))
 
 #define for_next_zone_zonelist_nodemask(zone, z, highidx, nodemask) \
-	for (zone = z->zone;	\
+	for (zone = zonelist_zone(z);	\
 		zone;							\
 		z = next_zones_zonelist(++z, highidx, nodemask),	\
 			zone = zonelist_zone(z))
@@ -1726,7 +1726,7 @@ static inline bool movable_only_nodes(nodemask_t *nodes)
 	nid = first_node(*nodes);
 	zonelist = &NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK];
 	z = first_zones_zonelist(zonelist, ZONE_NORMAL,	nodes);
-	return (!z->zone) ? true : false;
+	return (!zonelist_zone(z)) ? true : false;
 }
 
 
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 26 lines · Wei Yang

Instead of accessing zoneref->zone directly, use zonelist_zone() like other places for consistency.

No functional change.

CC Mike Rapoport (IBM) <[email protected]>
CC David Hildenbrand <[email protected]>
---
  include/linux/mmzone.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mmzone.h +1 -1
index cb7f265c2b96..51bce636373f 100644
@@ -1690,7 +1690,7 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
  			zone = zonelist_zone(z))
 
  #define for_next_zone_zonelist_nodemask(zone, z, highidx, nodemask) \
-	for (zone = z->zone;	\
+	for (zone = zonelist_zone(z);	\
  		zone;							\
  		z = next_zones_zonelist(++z, highidx, nodemask),	\
  			zone = zonelist_zone(z))

include/linux/mmzone.h static inline bool movable_only_nodes(nodemask_t *nodes) · line 1732

Quoted 8 lines
include/linux/mmzone.h +1 -1
@@ -1726,7 +1726,7 @@ static inline bool movable_only_nodes(nodemask_t *nodes)
  	nid = first_node(*nodes);
  	zonelist = &NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK];
  	z = first_zones_zonelist(zonelist, ZONE_NORMAL,	nodes);
-	return (!z->zone) ? true : false;
+	return (!zonelist_zone(z)) ? true : false;
  }
 
 
Signature · 3 lines
Cheers,

David / dhildenb
#2 lore raw
In reply to Wei Yang
Quoted 26 lines · Wei Yang

Instead of accessing zoneref->zone directly, use zonelist_zone() like other places for consistency.

No functional change.

CC Mike Rapoport (IBM) <[email protected]>
CC David Hildenbrand <[email protected]>
---
 include/linux/mmzone.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mmzone.h +1 -1
index cb7f265c2b96..51bce636373f 100644
@@ -1690,7 +1690,7 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
 			zone = zonelist_zone(z))
 
 #define for_next_zone_zonelist_nodemask(zone, z, highidx, nodemask) \
-	for (zone = z->zone;	\
+	for (zone = zonelist_zone(z);	\
 		zone;							\
 		z = next_zones_zonelist(++z, highidx, nodemask),	\
 			zone = zonelist_zone(z))

include/linux/mmzone.h static inline bool movable_only_nodes(nodemask_t *nodes) · line 1732

Quoted 8 lines
include/linux/mmzone.h +1 -1
@@ -1726,7 +1726,7 @@ static inline bool movable_only_nodes(nodemask_t *nodes)
 	nid = first_node(*nodes);
 	zonelist = &NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK];
 	z = first_zones_zonelist(zonelist, ZONE_NORMAL,	nodes);
-	return (!z->zone) ? true : false;
+	return (!zonelist_zone(z)) ? true : false;
 }
 
 

Hi Wei,

I'd like to propose extending the use of the zonelist_zone helper function in several other locations.

I've identified the following places where zonelist_zone could be used instead of the current approach:

oom.h:58 __entry->node = zone_to_nid(zoneref->zone); mempolicy.c:1956 return z->zone ? zone_to_nid(z->zone) : node; mempolicy.c:2805 polnid = zone_to_nid(z->zone); page_alloc.c:4205 if (!z->zone)
page_alloc.c:5285 return zone_to_nid(z->zone);

I hope this will further help with improving readability and maintainability across mm.

Thanks,
Shivank

author
#3 lore raw
Quoted 45 lines · Shivank
Quoted 26 lines · Wei Yang

Instead of accessing zoneref->zone directly, use zonelist_zone() like other places for consistency.

No functional change.

CC Mike Rapoport (IBM) <[email protected]>
CC David Hildenbrand <[email protected]>
---
 include/linux/mmzone.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mmzone.h +1 -1
index cb7f265c2b96..51bce636373f 100644
@@ -1690,7 +1690,7 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
 			zone = zonelist_zone(z))
 
 #define for_next_zone_zonelist_nodemask(zone, z, highidx, nodemask) \
-	for (zone = z->zone;	\
+	for (zone = zonelist_zone(z);	\
 		zone;							\
 		z = next_zones_zonelist(++z, highidx, nodemask),	\
 			zone = zonelist_zone(z))

include/linux/mmzone.h static inline bool movable_only_nodes(nodemask_t *nodes) · line 1732

Quoted 8 lines
include/linux/mmzone.h +1 -1
@@ -1726,7 +1726,7 @@ static inline bool movable_only_nodes(nodemask_t *nodes)
 	nid = first_node(*nodes);
 	zonelist = &NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK];
 	z = first_zones_zonelist(zonelist, ZONE_NORMAL,	nodes);
-	return (!z->zone) ? true : false;
+	return (!zonelist_zone(z)) ? true : false;
 }
 
 

Hi Wei,

I'd like to propose extending the use of the zonelist_zone helper function in several other locations.

I've identified the following places where zonelist_zone could be used instead of the current approach:

Quoted 9 lines

oom.h:58 __entry->node = zone_to_nid(zoneref->zone); mempolicy.c:1956 return z->zone ? zone_to_nid(z->zone) : node; mempolicy.c:2805 polnid = zone_to_nid(z->zone); page_alloc.c:4205 if (!z->zone)
page_alloc.c:5285 return zone_to_nid(z->zone);

I hope this will further help with improving readability and maintainability across mm.

Will add this, thanks.

Quoted 4 lines

Thanks,
Shivank

Signature · 2 lines
Wei Yang
Help you, Help me