From: William Lee Irwin III <wli@holomorphy.com>
To: linux-kernel@vger.kernel.org
Cc: trivial@rustcorp.com.au
Subject: beautify nr_free_pages()
Date: Sat, 15 Jun 2002 12:23:57 -0700 [thread overview]
Message-ID: <20020615192357.GR25360@holomorphy.com> (raw)
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;
}
reply other threads:[~2002-06-15 19:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020615192357.GR25360@holomorphy.com \
--to=wli@holomorphy.com \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox