linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Christoph Lameter <clameter@sgi.com>
Cc: linux-mm@kvack.org
Subject: Re: Use ZVC counters to establish exact size of dirtyable pages
Date: Tue, 13 Feb 2007 00:04:11 -0800	[thread overview]
Message-ID: <20070213000411.a6d76e0c.akpm@linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0702121014500.15560@schroedinger.engr.sgi.com>

On Mon, 12 Feb 2007 10:16:23 -0800 (PST) Christoph Lameter <clameter@sgi.com> wrote:

> +static unsigned long determine_dirtyable_memory(void)
> +{
> +	unsigned long x;
> +
> +#ifndef CONFIG_HIGHMEM
> +	x = global_page_state(NR_FREE_PAGES)
> +		+ global_page_state(NR_INACTIVE)
> +		+ global_page_state(NR_ACTIVE);
> +#else
> +	/*
> +	 * We always exclude high memory from our count
> +	 */
> +#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)
> +	/*
> +	 * i386 32 bit NUMA configurations have all non HIGHMEM zones on
> +	 * node 0. So its easier to just add up the lowmemt zones on node 0.
> +	 */
> +	struct zone * z;
> +
> +	x = 0;
> +	for (z = NODE_DATA(0)->node_zones;
> +			z < NODE_DATA(0)->node_zones + ZONE_HIGHMEM;
> +			z++)
> +		x = zone_page_state(z, NR_FREE_PAGES)
> +			+ zone_page_state(z, NR_INACTIVE)
> +			+ zone_page_state(z, NR_ACTIVE);
> +
> +#else
> +	/*
> +	 * Just subtract the HIGHMEM zones.
> +	 */
> +	int node;
> +
> +	x = global_page_state(NR_FREE_PAGES)
> +		+ global_page_state(NR_INACTIVE)
> +		+ global_page_state(NR_ACTIVE);
> +
> +	for_each_online_node(node) {
> +		struct zone *z =
> +			&NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
> +
> +		x -= zone_page_state(z, NR_FREE_PAGES)
> +			+ zone_page_state(z, NR_INACTIVE)
> +			+ zone_page_state(z, NR_ACTIVE);
> +	}
> +
> +#endif
> +#endif /* CONFIG_HIGHMEM */
> +	return x;
> +}

gaaack.

If CONFIG_HIGHMEM=n and CONFIG_NUMA=n, that definition of `node' is going
to come after the calculation of `x' and is going to spit a warning.

And we'll run global_page_state() six times where three would have
sufficed.

Also I think you'll be wanting a += in that first loop.

I believe i386 NUMA is rare as hen's teeth and perhaps we can just forget
about optimising for it.

Wanna have another go at this?  Perhaps split it into separate functions or
something.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-02-13  8:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-12 18:16 Christoph Lameter
2007-02-13  8:04 ` Andrew Morton [this message]
2007-02-13 17:43   ` Christoph Lameter
2007-02-13 18:03     ` Andrew Morton
2007-02-14 22:24     ` Andrew Morton
2007-02-14 22:41       ` Christoph Lameter
2007-02-14 22:49         ` Christoph Lameter
2007-02-14 23:19         ` Andrew Morton
2007-02-14 23:35           ` Christoph Lameter
2007-02-14 23:44             ` Andrew Morton
2007-02-15  0:00               ` Christoph Lameter

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=20070213000411.a6d76e0c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=linux-mm@kvack.org \
    /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