diff -Naurp -X /home/jbarnes/dontdiff 200-udelay-preempt-fix.patch/mm/page_alloc.c 210-nr-free-pages-fix.patch/mm/page_alloc.c --- 200-udelay-preempt-fix.patch/mm/page_alloc.c Thu Feb 12 10:23:10 2004 +++ 210-nr-free-pages-fix.patch/mm/page_alloc.c Thu Feb 12 10:27:56 2004 @@ -755,11 +755,23 @@ EXPORT_SYMBOL(free_pages); */ unsigned int nr_free_pages(void) { - unsigned int sum = 0; + static unsigned long jiffies_last_compute = 0; + static unsigned int free_pages_last_compute = 0; + pg_data_t *pgdat; + unsigned int sum, n; struct zone *zone; - for_each_zone(zone) - sum += zone->free_pages; +#define RECALC_TICKS 10 + + if (jiffies < jiffies_last_compute) + return free_pages_last_compute; + + jiffies_last_compute = jiffies + RECALC_TICKS; + sum = 0; + for_each_pgdat(pgdat) + for (zone=pgdat->node_zones,n=0; nnr_zones; n++, zone++) + sum += zone->free_pages; + free_pages_last_compute = sum; return sum; }