All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: Tim Abbott <tabbott@ksplice.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	rusty@rustcorp.com.au, linux-kbuild@vger.kernel.org,
	linux-modules@vger.kernel.org
Subject: Re: [PATCH 0/2] Use generic binary search function
Date: Wed, 23 Sep 2009 19:08:00 +0100	[thread overview]
Message-ID: <4ABA6400.8060901@tuffmail.co.uk> (raw)
In-Reply-To: <1253726926-5504-1-git-send-email-tabbott@ksplice.com>

Tim Abbott wrote:
>> The builtin symbol tables are now sorted, so we can use a binary
>> search.
>>     
>
> Hi Alan,
>
> There a large number hand-coded binary searches in the kernel (run
> "git grep search | grep binary" to find many of them).  Since getting
> binary searches right is difficult, I've been meaning to submit a
> patch adding a lib/bsearch.c for some time now, so that we only have
> to get binary search right in one place.
>
> This patch series contains a generic binary search implementation as
> well as something converting your module.c patch to use it.  I haven't
> had a chance to boot-test yet,

You might want to wait.  I found some weirdness in my patches - as if my 
bsearch is backwards but the tables are also being reversed.

Whatever the problem, it endorses the idea of having one known good 
bsearch function :-).

>  but this should give you a sense of
> what this is going to look like.  To me, you take some somewhat
> complex code and replace it with some very straightforward code.
>
> This generic binary search implementation comes from Ksplice.  It has
> the same basic API as the C library bsearch() function.  Ksplice uses
> it in half a dozen places with 4 different comparison functions, and I
> think our code is substantially cleaner because of this.
>
> I don't claim that this is a perfect implementation of binary search,
> though it is reasonably well tested.  My theory is that it is about as
> good as all the hand-coded copies all over the kernel, and we can
> optimize it to perfection later.
>
> Tim Abbott (2):
>   lib: Add generic binary search function to the kernel.
>   module: use bsearch in find_symbol_in_kernel_section.
>
>  include/linux/bsearch.h |    9 ++++++++
>  kernel/module.c         |   34 +++++++++++++----------------
>  lib/Makefile            |    2 +-
>  lib/bsearch.c           |   53 +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 78 insertions(+), 20 deletions(-)
>  create mode 100644 include/linux/bsearch.h
>  create mode 100644 lib/bsearch.c
>
>   


  reply	other threads:[~2009-09-23 18:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-22 13:38 module: Speed up symbol resolution during module loading Alan Jenkins
2009-09-22 13:38 ` [PATCH 1/4] module: extract __ExPORT_SYMBOL from module.h into mod_export.h Alan Jenkins
2009-09-22 14:42   ` Sam Ravnborg
2009-09-22 14:45     ` Alan Jenkins
2009-09-22 15:45   ` Daniel Walker
2009-09-22 15:50     ` Alan Jenkins
2009-09-22 15:55       ` Daniel Walker
2009-09-22 13:38 ` [PATCH 2/4] kbuild: sort the list of symbols exported by the kernel (__ksymtab) Alan Jenkins
2009-09-22 14:48   ` Sam Ravnborg
2009-09-22 15:08     ` Alan Jenkins
2009-09-23 17:38       ` Sam Ravnborg
2009-09-22 13:38 ` [PATCH 3/4] module: unexport each_symbol() Alan Jenkins
2009-09-23 17:29   ` Tim Abbott
2009-09-23 18:36     ` Alan Jenkins
2009-09-23 22:00     ` Christoph Hellwig
2009-09-24  0:15       ` Rusty Russell
2009-09-26 12:13       ` Alan Jenkins
2009-09-22 13:38 ` [PATCH 4/4] module: speed up find_symbol() using binary search on the builtin symbol tables Alan Jenkins
2009-09-23 17:28   ` [PATCH 0/2] Use generic binary search function Tim Abbott
2009-09-23 18:08     ` Alan Jenkins [this message]
2009-09-23 17:28   ` [PATCH 1/2] lib: Add generic binary search function to the kernel Tim Abbott
2009-09-24  0:11     ` Rusty Russell
2009-09-27 17:05       ` Tim Abbott
2009-11-03 15:14         ` Thiago Farina
2009-11-03 15:14           ` Thiago Farina
2009-11-03 15:34           ` Alan Jenkins
2009-09-23 17:28   ` [PATCH 2/2] module: use bsearch in find_symbol_in_kernel_section Tim Abbott

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=4ABA6400.8060901@tuffmail.co.uk \
    --to=alan-jenkins@tuffmail.co.uk \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tabbott@ksplice.com \
    /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.