linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Overstreet <kmo@daterainc.com>
To: Tejun Heo <tj@kernel.org>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Fengguang Wu <fengguang.wu@intel.com>
Subject: Re: [PATCH] idr: Document ida tree sections
Date: Tue, 13 Aug 2013 15:27:59 -0700	[thread overview]
Message-ID: <20130813222759.GA12069@kmo-pixel> (raw)
In-Reply-To: <20130813221928.GE28996@mtj.dyndns.org>

On Tue, Aug 13, 2013 at 06:19:28PM -0400, Tejun Heo wrote:
> Hello,
> 
> On Tue, Aug 13, 2013 at 03:13:08PM -0700, Kent Overstreet wrote:
> > If you're convinced this is a real issue though - how about
> 
> It is a real issue.  Large order allocation is fine for optimization
> but shouldn't be depended upon.  It does fail easily without
> compaction and compaction is heavy-ass operation which will blow up
> any minute performance advantage you might get from avoiding proper
> radix tree implementation.
> 
> > IDA_SECTION_SIZE conditional on CONFIG_COMPACTION, so we use order 2 or
> > 3 allocations if CONFIG_COMPACTION=n?
> > 
> > Then the max size toplevel array of pointers to segments would be
> > bigger, but that's only an issue when we're allocating up to near
> > INT_MAX ids, so it's difficult to see how _that_ would be an issue on a
> > small/embedded system... and we could even use vmalloc for that
> > allocation when the size of that array is > IDA_SECTION_SIZE.
> 
> What about cyclic allocations then?  This is natrually a radix tree
> problem.  I don't know why you're resisting radix tree so much here.

It's only naturally a radix tree problem _if_ you require sparseness.
Otherwise, radix trees require pointer chasing, which we can avoid -
which saves us both the cost of chasing pointers (which is significant)
and the overhead of storing them.

The patch handles cyclic allocation by limiting sparseness - we talked
about this and I thought you were ok with this solution, though it was
awhile ago and I could be misremembering your comments.

To recap, here's the code that implements that sparseness limiting, it's
documented in ida_alloc_cyclic()'s docs:

static int __ida_alloc_cyclic(struct ida *ida, unsigned start, unsigned end,
			      gfp_t gfp, unsigned long *flags)
	__releases(&ida->lock)
	__acquires(&ida->lock)
{
	int ret;
	unsigned id;

	ret = __ida_alloc_range_multiple(ida, &id, 1,
					 max(start, ida->cur_id),
					 end, gfp, flags);

	if (ret < 0)
		ret = __ida_alloc_range_multiple(ida, &id, 1, start,
						 end, gfp, flags);
	if (ret == 1) {
		ida->cur_id = id + 1;
		if ((ida->cur_id - start) / 2 > max(1024U, ida->allocated_ids))
			ida->cur_id = 0;

		return id;
	}

	return ret;
}

  reply	other threads:[~2013-08-13 22:27 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07 17:34 IDA/IDR rewrite, percpu ida Kent Overstreet
2013-08-07 17:34 ` [PATCH 03/10] idr: Rewrite ida Kent Overstreet
2013-08-07 20:22   ` Tejun Heo
2013-08-07 20:51     ` [PATCH] idr: Document ida tree sections Kent Overstreet
2013-08-09 14:57       ` Tejun Heo
2013-08-13 22:13         ` Kent Overstreet
2013-08-13 22:19           ` Tejun Heo
2013-08-13 22:27             ` Kent Overstreet [this message]
2013-08-13 22:44               ` Tejun Heo
2013-08-13 22:59                 ` Kent Overstreet
2013-08-13 23:22                   ` Tejun Heo
2013-08-13 23:51                     ` Kent Overstreet
2013-08-13 23:59                       ` Tejun Heo
2013-08-15  0:04                         ` Kent Overstreet
2013-08-15  0:22                           ` Tejun Heo
2013-08-13 22:33         ` Kent Overstreet
2013-08-07 17:34 ` [PATCH 04/10] idr: Percpu ida Kent Overstreet
2013-08-07 17:56   ` Christoph Lameter
2013-08-07 18:33     ` Kent Overstreet
2013-08-07 19:40       ` Christoph Lameter
2013-08-07 19:57         ` [PATCH] idr: Use this_cpu_ptr() for percpu_ida Kent Overstreet
2013-08-08 14:32           ` Christoph Lameter
2013-08-20 21:19             ` Nicholas A. Bellinger
2013-08-20 21:29               ` Andrew Morton
2013-08-21  2:01                 ` Kent Overstreet
2013-08-21  2:07                   ` Tejun Heo
2013-08-21  2:31                     ` Kent Overstreet
2013-08-21 11:59                       ` Tejun Heo
2013-08-21 21:09                         ` Kent Overstreet
2013-08-21 21:16                           ` Tejun Heo
2013-08-21 21:24                             ` Kent Overstreet
2013-08-21 21:31                               ` Tejun Heo
2013-08-21 14:32               ` Christoph Lameter
2013-08-21 17:49                 ` Nicholas A. Bellinger
2013-08-21 20:49                 ` Andrew Morton
2013-08-22 16:44                   ` Christoph Lameter
2013-08-22 16:56                     ` Jens Axboe
2013-08-07 17:46 ` [PATCH 05/10] idr: Kill old deprecated idr interfaces Kent Overstreet
2013-08-07 17:46 ` [PATCH 06/10] idr: Rename idr_get_next() -> idr_find_next() Kent Overstreet
2013-08-07 17:46 ` [PATCH 08/10] idr: Reimplement idr on top of ida/radix trees Kent Overstreet

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=20130813222759.GA12069@kmo-pixel \
    --to=kmo@daterainc.com \
    --cc=akpm@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=tj@kernel.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).