[patch 16/18] factor common code in page_alloc.c

Andrew Morton (akpm@zip.com.au)
Sun, 26 May 2002 13:47:37 -0700


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

-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/