linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: memblock glitch
Date: Wed, 4 Aug 2010 09:49:30 +0100	[thread overview]
Message-ID: <20100804084930.GA4927@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1280882307.1902.124.camel@pasglop>

On Wed, Aug 04, 2010 at 10:38:27AM +1000, Benjamin Herrenschmidt wrote:
> Hi Russell !
> 
> While looking at updating ARM memblock to some of my changes, I found
> this bit in arch/arm/mm/init.c:
> 
> int pfn_valid(unsigned long pfn)
> {
> 	struct memblock_region *mem = &memblock.memory;
> 	unsigned int left = 0, right = mem->cnt;
> 
> 	do {
> 		unsigned int mid = (right + left) / 2;
> 
> 		if (pfn < memblock_start_pfn(mem, mid))
> 			right = mid;
> 		else if (pfn >= memblock_end_pfn(mem, mid))
> 			left = mid + 1;
> 		else
> 			return 1;
> 	} while (left < right);
> 	return 0;
> }
> EXPORT_SYMBOL(pfn_valid);
> 
> So you're trying to do a dichotomy to be faster.

Correct.  The normal size of this thing tends to typically be one or
maybe two entries, although we normally support up to 8 ranges, or 16
in one case.  It works well because of the tight cache locality of the
data, which occupies maybe up to three cache lines.

> However, that doesn't
> quite work with my new code as I'm trying to take away access to
> the internals of memblock from arch code so we can re-implement the core
> in a slightly saner way if we wish to.
> 
> Since I understand why you don't want a linear search there, any
> objection if I move the logic to the core memblock and expose it via a
> memblock_search() kind of facility ?

No objection.

      parent reply	other threads:[~2010-08-04  8:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-04  0:38 memblock glitch Benjamin Herrenschmidt
2010-08-04  1:38 ` Benjamin Herrenschmidt
2010-08-04  4:02   ` memblock_is_region_reserved() issue Benjamin Herrenschmidt
2010-09-02 13:41     ` Russell King - ARM Linux
2010-08-04  8:54   ` memblock glitch Russell King - ARM Linux
2010-08-04 10:41     ` Benjamin Herrenschmidt
2010-08-04  8:49 ` Russell King - ARM Linux [this message]

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=20100804084930.GA4927@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).