public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 16/18] factor common code in page_alloc.c
@ 2002-05-26 20:47 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2002-05-26 20:47 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml


Factor out some similar code in page_alloc.c

=====================================

--- 2.5.18/mm/page_alloc.c~zone-pages-cleanup	Sun May 26 12:38:09 2002
+++ 2.5.18-akpm/mm/page_alloc.c	Sun May 26 12:38:09 2002
@@ -543,16 +543,13 @@ unsigned int nr_free_pages (void)
 	return sum;
 }
 
-/*
- * Amount of free RAM allocatable as buffer memory:
- */
-unsigned int nr_free_buffer_pages (void)
+static unsigned int nr_free_zone_pages(int offset)
 {
 	pg_data_t *pgdat = pgdat_list;
 	unsigned int sum = 0;
 
 	do {
-		zonelist_t *zonelist = pgdat->node_zonelists + (GFP_USER & GFP_ZONEMASK);
+		zonelist_t *zonelist = pgdat->node_zonelists + offset;
 		zone_t **zonep = zonelist->zones;
 		zone_t *zone;
 
@@ -570,30 +567,19 @@ unsigned int nr_free_buffer_pages (void)
 }
 
 /*
- * Amount of free RAM allocatable as pagecache memory:
+ * Amount of free RAM allocatable within ZONE_DMA and ZONE_NORMAL
  */
-unsigned int nr_free_pagecache_pages(void)
+unsigned int nr_free_buffer_pages(void)
 {
-	pg_data_t *pgdat = pgdat_list;
-	unsigned int sum = 0;
-
-	do {
-		zonelist_t *zonelist = pgdat->node_zonelists +
-				(GFP_HIGHUSER & GFP_ZONEMASK);
-		zone_t **zonep = zonelist->zones;
-		zone_t *zone;
-
-		for (zone = *zonep++; zone; zone = *zonep++) {
-			unsigned long size = zone->size;
-			unsigned long high = zone->pages_high;
-			if (size > high)
-				sum += size - high;
-		}
-
-		pgdat = pgdat->node_next;
-	} while (pgdat);
+	return nr_free_zone_pages(GFP_USER & GFP_ZONEMASK);
+}
 
-	return sum;
+/*
+ * Amount of free RAM allocatable within all zones
+ */
+unsigned int nr_free_pagecache_pages(void)
+{
+	return nr_free_zone_pages(GFP_HIGHUSER & GFP_ZONEMASK);
 }
 
 #if CONFIG_HIGHMEM


-

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-05-26 20:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-26 20:47 [patch 16/18] factor common code in page_alloc.c Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox