All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: Bernd Eckenfels <ecki@lina.inka.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: slab: avoid linear search in kmalloc? (GCC Guru wanted :)
Date: Tue, 20 Nov 2001 18:03:26 -0800	[thread overview]
Message-ID: <3BFB0B6E.147EBABF@zip.com.au> (raw)
In-Reply-To: <20011121024525.A18750@lina.inka.de>

Bernd Eckenfels wrote:
> 
> Hello,
> 
> I noticed that kmalloc and kmem_find_general_cachep are doing a linear
> search in the cache_sizes array. Isnt it better to speed that up by doing a
> binary search or a b-tree if like the following patch?
> 

Possibly.  I've never seen it on a profile though.

Just for kicks, try feeding this into gcc and take a look
at the assembly output:

int thing(int size)
{
	int ret;

	switch (size) {
	case 0 ... 2:
		return 1;
	case 3 ... 4:
		return 2;
	case 5 ... 8:
		return 3;
	case 9 ... 16:
		return 4;
	case 17 ... 31:
		return 5;
	case 32 ... 64:
		return 6;
	case 65 ... 128:
		return 7;
	case 129 ... 256:
		return 8;
	case 257 ... 512:
		return 9;
	case 513 ... 1024:
		return 10;
	case 1025 ... 2048:
		return 11;
	case 2049 ... 4096:
		return 12;
	case 4097 ... 8192:
		return 13;
	case 8193 ... 16384:
		return 14;
	case 16385 ... 32768:
		return 15;
	case 32769 ... 65536:
		return 16;
	}
	return -1;
}

  reply	other threads:[~2001-11-21  2:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-21  1:45 slab: avoid linear search in kmalloc? (GCC Guru wanted :) Bernd Eckenfels
2001-11-21  2:03 ` Andrew Morton [this message]
2001-11-21  9:14 ` Momchil Velikov
2001-11-21  9:22   ` Arjan van de Ven
2001-11-21  9:34     ` Momchil Velikov

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=3BFB0B6E.147EBABF@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=ecki@lina.inka.de \
    --cc=linux-kernel@vger.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 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.