All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wu Fengguang <wfg@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Vladislav Bolkhovitin <vst@vlnb.net>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] radix-tree: add radix_tree_prev_hole()
Date: Mon, 13 Apr 2009 21:44:35 +0800	[thread overview]
Message-ID: <20090413134435.GA10143@localhost> (raw)
In-Reply-To: <20090412102952.0dd377d6.akpm@linux-foundation.org>

On Sun, Apr 12, 2009 at 10:29:52AM -0700, Andrew Morton wrote:
> On Sun, 12 Apr 2009 15:19:51 +0800 Wu Fengguang <fengguang.wu@intel.com> wrote:
> 
> > +unsigned long radix_tree_prev_hole(struct radix_tree_root *root,
> > +				   unsigned long index, unsigned long max_scan)
> > +{
> > +	unsigned long i;
> > +
> > +	for (i = 0; i < max_scan; i++) {
> > +		if (!radix_tree_lookup(root, index))
> > +			break;
> > +		index--;
> > +		if (index == LONG_MAX)
> > +			break;
> > +	}
> > +
> > +	return index;
> > +}
> 
> argh.  This is about as inefficient as we could possibly make it :(

Right, a dumb loop!

> Really, this function should dive into radix-tree internals and walk
> individual radix_tree_node.slots[] arrays.  And heck, it can peek at
> radix_tree_node.count and _bypass_ entire nodes, too.

Good idea! In fact I'm planning such a smart version. It will be using
radix_tree_lookup_slot() to access the ->count member, in order to
check if the whole slot can be bypassed.

radix_tree_next_hole() is another optimization candidate.
But that will be a post 2.6.30 stuff.

The current dumb-but-obvious-right version is OK for 2.6.30, because
in most radix_tree_prev_hole() invocations the actual loop count will
be merely 1.

Thanks,
Fengguang

  reply	other threads:[~2009-04-13 13:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-12  7:19 [PATCH 0/3] context readahead for concurrent IO take 2 Wu Fengguang
2009-04-12  7:19 ` [PATCH 1/3] radix-tree: add radix_tree_prev_hole() Wu Fengguang
2009-04-12 17:29   ` Andrew Morton
2009-04-13 13:44     ` Wu Fengguang [this message]
2009-04-12  7:19 ` [PATCH 2/3] readahead: move the random read case to bottom Wu Fengguang
2009-04-12  7:19 ` [PATCH 3/3] readahead: introduce context readahead algorithm Wu Fengguang
2009-04-12  8:48   ` Ingo Molnar
2009-04-12 12:35     ` Wu Fengguang
2009-04-12 12:35       ` Wu Fengguang
2009-04-16 17:12       ` Vladislav Bolkhovitin
2009-04-16 17:12         ` Vladislav Bolkhovitin
     [not found]   ` <87zlej7kwf.fsf@basil.nowhere.org>
2009-04-14  9:27     ` Wu Fengguang
2009-04-14 10:00       ` Andi Kleen
2009-04-14 10:58         ` Wu Fengguang
2009-04-14 11:11           ` Wu Fengguang
2009-04-15  3:43   ` Jeff Moyer
2009-04-15  4:43     ` Wu Fengguang
2009-04-15 17:55       ` Jeff Moyer
2009-04-27  4:48         ` Wu Fengguang
  -- strict thread matches above, loose matches on Subject: below --
2009-04-10 13:12 [PATCH 0/3] context readahead for concurrent IO Wu Fengguang
2009-04-10 13:12 ` [PATCH 1/3] radix-tree: add radix_tree_next_hole() Wu Fengguang
2009-04-10 13:31   ` [PATCH 1/3] radix-tree: add radix_tree_prev_hole() Wu Fengguang

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=20090413134435.GA10143@localhost \
    --to=wfg@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vst@vlnb.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.