[RFC][PATCH 1/4] build_zonelists(): create zone_index_to_type() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The two build_zonelists() do identical conversions from a
zone index variable (__GFP_*) to a zone type variable
(ZONE_*).  Create a common helper.

Signed-off-by: Dave Hansen <[email protected]>
---

 memhotplug-dave/mm/page_alloc.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff -puN mm/page_alloc.c~B1-build_zonelists_unification mm/page_alloc.c
--- memhotplug/mm/page_alloc.c~B1-build_zonelists_unification	2005-09-14 09:32:37.000000000 -0700
+++ memhotplug-dave/mm/page_alloc.c	2005-09-14 09:32:37.000000000 -0700
@@ -1451,6 +1451,18 @@ static int __init build_zonelists_node(p
 	return j;
 }
 
+static inline zone_index_to_type(int index)
+{
+	int type = ZONE_NORMAL;
+
+	if (index & __GFP_HIGHMEM)
+		type = ZONE_HIGHMEM;
+	if (index & __GFP_DMA)
+		type = ZONE_DMA;
+	return type;
+}
+
+
 #ifdef CONFIG_NUMA
 #define MAX_NODE_LOAD (num_online_nodes())
 static int __initdata node_load[MAX_NUMNODES];
@@ -1547,11 +1559,7 @@ static void __init build_zonelists(pg_da
 			zonelist = pgdat->node_zonelists + i;
 			for (j = 0; zonelist->zones[j] != NULL; j++);
 
-			k = ZONE_NORMAL;
-			if (i & __GFP_HIGHMEM)
-				k = ZONE_HIGHMEM;
-			if (i & __GFP_DMA)
-				k = ZONE_DMA;
+			k = zone_index_to_type(i);
 
 	 		j = build_zonelists_node(NODE_DATA(node), zonelist, j, k);
 			zonelist->zones[j] = NULL;
@@ -1572,11 +1580,7 @@ static void __init build_zonelists(pg_da
 		zonelist = pgdat->node_zonelists + i;
 
 		j = 0;
-		k = ZONE_NORMAL;
-		if (i & __GFP_HIGHMEM)
-			k = ZONE_HIGHMEM;
-		if (i & __GFP_DMA)
-			k = ZONE_DMA;
+		k = zone_index_to_type(i);
 
  		j = build_zonelists_node(pgdat, zonelist, j, k);
  		/*
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux