Skip to contentSkip to conversation

ACPI: MRRM: Use for_each_populated_zone() in get_node_num()

PATCH Applied Sang-Heon Jeon 2 participants 2 messages Aug 21 – Sep 10 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: MRRM: Use for_each_populated_zone() in get_node_num()

get_node_num() iterates over the populated zones of every online node with a nested loop. for_each_populated_zone() iterates over the same zones in the same order.

So use for_each_populated_zone() instead and remove the unused variable.

No functional change.

---
 drivers/acpi/acpi_mrrm.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/acpi/acpi_mrrm.c +4 -10
index e99cbda83452..83934e2aa0d4 100644
@@ -36,17 +36,11 @@ static u32 mrrm_mem_entry_num;
 
 static int get_node_num(struct mrrm_mem_range_entry *e)
 {
-	unsigned int nid;
+	struct zone *zone;
 
-	for_each_online_node(nid) {
-		for (int z = 0; z < MAX_NR_ZONES; z++) {
-			struct zone *zone = NODE_DATA(nid)->node_zones + z;
-
-			if (!populated_zone(zone))
-				continue;
-			if (zone_intersects(zone, PHYS_PFN(e->base), PHYS_PFN(e->length)))
-				return zone_to_nid(zone);
-		}
+	for_each_populated_zone(zone) {
+		if (zone_intersects(zone, PHYS_PFN(e->base), PHYS_PFN(e->length)))
+			return zone_to_nid(zone);
 	}
 
 	return -ENOENT;
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 32 lines · Sang-Heon Jeon

get_node_num() iterates over the populated zones of every online node with a nested loop. for_each_populated_zone() iterates over the same zones in the same order.

So use for_each_populated_zone() instead and remove the unused variable.

No functional change.

---
 drivers/acpi/acpi_mrrm.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/acpi/acpi_mrrm.c +1 -7
index e99cbda83452..83934e2aa0d4 100644
@@ -36,17 +36,11 @@ static u32 mrrm_mem_entry_num;
 
 static int get_node_num(struct mrrm_mem_range_entry *e)
 {
-       unsigned int nid;
+       struct zone *zone;
 
-       for_each_online_node(nid) {
-               for (int z = 0; z < MAX_NR_ZONES; z++) {
-                       struct zone *zone = NODE_DATA(nid)->node_zones + z;
-
-                       if (!populated_zone(zone))
-                               continue;

drivers/acpi/acpi_mrrm.c static u32 mrrm_mem_entry_num;

Quoted 10 lines
drivers/acpi/acpi_mrrm.c +3 -4
-                       if (zone_intersects(zone, PHYS_PFN(e->base), PHYS_PFN(e->length)))
-                               return zone_to_nid(zone);
-               }
+       for_each_populated_zone(zone) {
+               if (zone_intersects(zone, PHYS_PFN(e->base), PHYS_PFN(e->length)))
+                       return zone_to_nid(zone);
        }
 
        return -ENOENT;
--

Applied as 7.4 material, thanks!