Skip to contentSkip to conversation

clean up redundant code for alloc_pages

RFC PATCH New Matthew Dobson 1 participant 1 message Feb 22, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 clean up redundant code for alloc_pages

Well, alloc_pages() and alloc_pages_node() look *REAAALY* similar. This is a really small patch to just shrink alloc_pages_node() a bit and point alloc_page() and alloc_pages() at alloc_pages_node() with the appropriate arguments.

It is a pretty trivial change, just curious if there are any violent objections to such a change.

[mcd@arrakis push]$ diffstat alloc_pages_cleanup-2.5.62.patch

 gfp.h |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

Cheers!

-Matt

include/linux/gfp.h +5 -13
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.62-vanilla/include/linux/gfp.h linux-2.5.62-alloc_pages/include/linux/gfp.h
@@ -49,24 +49,16 @@
 extern struct page * FASTCALL(__alloc_pages(unsigned int, unsigned int, struct zonelist *));
 static inline struct page * alloc_pages_node(int nid, unsigned int gfp_mask, unsigned int order)
 {
-	struct pglist_data *pgdat = NODE_DATA(nid);
-	unsigned int idx = (gfp_mask & GFP_ZONEMASK);
-
 	if (unlikely(order >= MAX_ORDER))
 		return NULL;
-	return __alloc_pages(gfp_mask, order, pgdat->node_zonelists + idx);
-}
-static inline struct page * alloc_pages(unsigned int gfp_mask, unsigned int order)
-{
-	struct pglist_data *pgdat = NODE_DATA(numa_node_id());
-	unsigned int idx = (gfp_mask & GFP_ZONEMASK);
 
-	if (unlikely(order >= MAX_ORDER))
-		return NULL;
-	return __alloc_pages(gfp_mask, order, pgdat->node_zonelists + idx);
+	return __alloc_pages(gfp_mask, order, NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK));
 }
 
-#define alloc_page(gfp_mask) alloc_pages(gfp_mask, 0)
+#define alloc_pages(gfp_mask, order) \
+		alloc_pages_node(numa_node_id(), gfp_mask, order)
+#define alloc_page(gfp_mask) \
+		alloc_pages_node(numa_node_id(), gfp_mask, 0)
 
 extern unsigned long FASTCALL(__get_free_pages(unsigned int gfp_mask, unsigned int order));
 extern unsigned long FASTCALL(get_zeroed_page(unsigned int gfp_mask));