Skip to contentSkip to conversation

Uninline zonelist iterator helper functions

PATCH In review Mel Gorman 2 participants 2 messages Mar 27, 2008

Subsystems (6)
lore
Share & tools
lore

Mel Gorman

author
#0 lore raw

PATCH 1/1 Uninline zonelist iterator helper functions

for_each_zone_zonelist_nodemask() uses large inlined helpers. The number of callsites using it means that the size of the text section is increased. This patch uninlines the helpers to reduce the amount of text bloat.

---
 fs/buffer.c            |    4 ++-
 include/linux/mmzone.h |   62 +++++++------------------------------------------
 mm/mempolicy.c         |    4 ++-
 mm/mmzone.c            |   31 ++++++++++++++++++++++++
 mm/page_alloc.c        |   10 ++++++-
 5 files changed, 55 insertions(+), 56 deletions(-)
fs/buffer.c +3 -1
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.25-rc5-mm1-clean/fs/buffer.c linux-2.6.25-rc5-mm1-1020_uninline/fs/buffer.c
@@ -369,6 +369,7 @@ void invalidate_bdev(struct block_device
 static void free_more_memory(void)
 {
 	struct zoneref *zrefs;
+	struct zone *dummy;
 	int nid;
 
 	wakeup_pdflush(1024);
@@ -376,7 +377,8 @@ static void free_more_memory(void)
 
 	for_each_online_node(nid) {
 		zrefs = first_zones_zonelist(node_zonelist(nid, GFP_NOFS),
-						gfp_zone(GFP_NOFS), NULL);
+						gfp_zone(GFP_NOFS), NULL,
+						&dummy);
 		if (zrefs->zone)
 			try_to_free_pages(node_zonelist(nid, GFP_NOFS), 0,
 						GFP_NOFS);
include/linux/mmzone.h +10 -52

80 lines not on this page · raw message

mm/mempolicy.c +3 -1
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.25-rc5-mm1-clean/mm/mempolicy.c linux-2.6.25-rc5-mm1-1020_uninline/mm/mempolicy.c
@@ -1340,10 +1340,12 @@ unsigned slab_node(struct mempolicy *pol
 		 */
 		struct zonelist *zonelist;
 		struct zoneref *z;
+		struct zone *dummy;
 		enum zone_type highest_zoneidx = gfp_zone(GFP_KERNEL);
 		zonelist = &NODE_DATA(numa_node_id())->node_zonelists[0];
 		z = first_zones_zonelist(zonelist, highest_zoneidx,
-							&policy->v.nodes);
+							&policy->v.nodes,
+							&dummy);
 		return zonelist_node_idx(z);
 	}
 
mm/mmzone.c +30 -0
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.25-rc5-mm1-clean/mm/mmzone.c linux-2.6.25-rc5-mm1-1020_uninline/mm/mmzone.c
@@ -42,3 +42,33 @@ struct zone *next_zone(struct zone *zone
 	return zone;
 }
 
+static inline int zref_in_nodemask(struct zoneref *zref, nodemask_t *nodes)
+{
+#ifdef CONFIG_NUMA
+	return node_isset(zonelist_node_idx(zref), *nodes);
+#else
+	return 1;
+#endif /* CONFIG_NUMA */
+}
+
+/* Returns the next zone at or below highest_zoneidx in a zonelist */
+struct zoneref *next_zones_zonelist(struct zoneref *z,
+					enum zone_type highest_zoneidx,
+					nodemask_t *nodes,
+					struct zone **zone)
+{
+	/*
+	 * Find the next suitable zone to use for the allocation.
+	 * Only filter based on nodemask if it's set
+	 */
+	if (likely(nodes == NULL))
+		while (zonelist_zone_idx(z) > highest_zoneidx)
+			z++;
+	else
+		while (zonelist_zone_idx(z) > highest_zoneidx ||
+				(z->zone && !zref_in_nodemask(z, nodes)))
+			z++;
+
+	*zone = zonelist_zone(z++);
+	return z;
+}
mm/page_alloc.c +8 -2
diff -rup -X /usr/src/patchset-0.6/bin//dontdiff linux-2.6.25-rc5-mm1-clean/mm/page_alloc.c linux-2.6.25-rc5-mm1-1020_uninline/mm/page_alloc.c
@@ -1406,9 +1406,9 @@ get_page_from_freelist(gfp_t gfp_mask, n
 	int zlc_active = 0;		/* set if using zonelist_cache */
 	int did_zlc_setup = 0;		/* just call zlc_setup() one time */
 
-	z = first_zones_zonelist(zonelist, high_zoneidx, nodemask);
+	z = first_zones_zonelist(zonelist, high_zoneidx, nodemask,
+							&preferred_zone);
 	classzone_idx = zonelist_zone_idx(z);
-	preferred_zone = zonelist_zone(z);
 
 zonelist_scan:
 	/*
@@ -1974,6 +1974,12 @@ void show_free_areas(void)
 	show_swap_cache_info();
 }
 
+static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref)
+{
+	zoneref->zone = zone;
+	zoneref->zone_idx = zone_idx(zone);
+}
+
 /*
  * Builds allocation fallback zone lists.
  *

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw

Hi

Quoted 5 lines · Mel Gorman

for_each_zone_zonelist_nodemask() uses large inlined helpers. The number of
callsites using it means that the size of the text section is increased. This patch uninlines the helpers to reduce the amount of text bloat.

I found no bug :)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>