linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: linux-mm@kvack.org
Subject: Re: [RFC] memory-layout-free zones (for review) [1/3] for_each_page_in_zone()
Date: Thu, 23 Feb 2006 10:03:44 -0800	[thread overview]
Message-ID: <1140717824.8697.59.camel@localhost.localdomain> (raw)
In-Reply-To: <20060223175643.a685dfb3.kamezawa.hiroyu@jp.fujitsu.com>

On Thu, 2006-02-23 at 17:56 +0900, KAMEZAWA Hiroyuki wrote:
> +/*
> + *  These inline function for for_each_page_in_zone can work
> + *  even if CONFIG_SPARSEMEM=y.
> + */
> +static inline struct page *first_page_in_zone(struct zone *zone)
> +{
> +	unsigned long start_pfn = zone->zone_start_pfn;
> +	unsigned long i = 0;
> +
> +	if (!populated_zone(zone))
> +		return NULL;
> +
> +	for (i = 0; i < zone->zone_spanned_pages; i++) {
> +		if (pfn_valid(start_pfn + i))
> +			break;
> +	}
> +	return pfn_to_page(start_pfn + i);
> +}

Isn't this a little hefty of a function for an inline?

Also, why would we _ever_ have a zone that didn't actually have a valid
pfn at its start?  If there wasn't a valid pfn there, with no
zone_mem_map, wouldn't we just bump up the start_pfn?

> +static inline struct page *next_page_in_zone(struct page *page,
> +					     struct zone *zone)
> +{
> +	unsigned long start_pfn = zone->zone_start_pfn;
> +	unsigned long i = page_to_pfn(page) - start_pfn;
> +
> +	if (!populated_zone(zone))
> +		return NULL;
> +
> +	for (i = i + 1; i < zone->zone_spanned_pages; i++) {
> +		if (pfn_vlaid(start_pfn + i))
> +			break;
> +	}
> +	if (i == zone->zone_spanned_pages)
> +		return NULL;
> +	return pfn_to_page(start_pfn + i);
> +}

Seems like this should share code with the other function.  And the
"vlaid" part looks a bit uncompilable. ;)

> +/**
> + * for_each_page_in_zone -- helper macro to iterate over all pages in a zone.
> + * @page - pointer to page
> + * @zone - pointer to zone
> + *
> + */
> +#define for_each_page_in_zone(page, zone)		\
> +	for (page = (first_page_in_zone((zone)));	\
> +	     page;					\
> +	     page = next_page_in_zone(page, (zone)));
> +

Nice.  We need one of these.  The rest of the patch looks pretty
straighforward.

-- Dave

--
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:[~2006-02-23 18:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-23  8:56 KAMEZAWA Hiroyuki
2006-02-23 18:03 ` Dave Hansen [this message]
2006-02-23 23:45   ` KAMEZAWA Hiroyuki

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=1140717824.8697.59.camel@localhost.localdomain \
    --to=haveblue@us.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.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