public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* beautify nr_free_pages()
@ 2002-06-15 19:23 William Lee Irwin III
  0 siblings, 0 replies; only message in thread
From: William Lee Irwin III @ 2002-06-15 19:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: trivial

nr_free_pages() is overly verbose. The following is perhaps clearer and
gets to the point with fewer lines of code and inside of 80 columns.

Against 2.5.21


Cheers,
Bill



===== mm/page_alloc.c 1.67 vs edited =====
--- 1.67/mm/page_alloc.c	Mon Jun  3 08:25:10 2002
+++ edited/mm/page_alloc.c	Sat Jun 15 12:10:41 2002
@@ -495,16 +495,13 @@
  */
 unsigned int nr_free_pages(void)
 {
-	unsigned int sum;
-	zone_t *zone;
-	pg_data_t *pgdat = pgdat_list;
+	unsigned int i, sum = 0;
+	pg_data_t *pgdat;
+
+	for (pgdat = pgdat_list; pgdat; pgdat = pgdat->node_next)
+		for (i = 0; i < MAX_NR_ZONES; ++i)
+			sum += pgdat->node_zones[i].free_pages;
 
-	sum = 0;
-	while (pgdat) {
-		for (zone = pgdat->node_zones; zone < pgdat->node_zones + MAX_NR_ZONES; zone++)
-			sum += zone->free_pages;
-		pgdat = pgdat->node_next;
-	}
 	return sum;
 }
 

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

only message in thread, other threads:[~2002-06-15 19:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-15 19:23 beautify nr_free_pages() William Lee Irwin III

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