mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Alessio Igor Bogani <abogani@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Tim Bird <tim.bird@am.sony.com>,
	Alessio Igor Bogani <abogani@kernel.org>,
	Tim Abbott <tabbott@ksplice.com>
Subject: Re: [PATCH] module: Use the binary search for symbols resolution
Date: Tue, 12 Apr 2011 13:18:54 +0930	[thread overview]
Message-ID: <87aafwceop.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1302024146-2608-2-git-send-email-abogani@kernel.org>

On Tue,  5 Apr 2011 19:22:26 +0200, Alessio Igor Bogani <abogani@kernel.org> wrote:
> Let the linker sort the exported symbols and use the binary search for
> locate them.

OK, but why is this optional?

Also note that each_symbol() has an out-of-tree user in ksplice, so
changing the semantics to always search for a particular name might
break them.

Assuming they need it, we could rename it (so they can easily detect the
change) to search_symbol() and make it take a comparitor fn and a
"found" function.

So we want this as three patches, I think:
1) Change each_symbol() to search_symbol() as detailed above.
2) Change symbol tables to be sorted.
3) Change module code to do binary search.

That means we can tell exactly *what* breaks things in linux-next :)

Also:
>  	for (j = 0; j < arrsize; j++) {
> -		for (i = 0; i < arr[j].stop - arr[j].start; i++)
> -			if (fn(&arr[j], owner, i, data))
> +#ifdef CONFIG_SYMBOLS_BSEARCH
> +		num = arr[j].stop - arr[j].start;
> +		start = 0, end = num - 1, mid, result;
> +		while (start <= end) {
> +			mid = (start + end) / 2;
> +			result = strcmp(fsa->name, arr[j].start[mid].name);
> +			if (result < 0)
> +				end = mid - 1;
> +			else if (result > 0)
> +				start = mid + 1;
> +			else
> +				if (fn(&arr[j], owner, mid, data))
> +					return true;
> +		}
> +#else

This will loop forever if rn() returns false!  You want

     return fn(&arr[j], owner, mid, data)

I think.

But very neat work!
Rusty.

  parent reply	other threads:[~2011-04-12  3:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05 17:22 [PATCH] Speed up the symbols' resolution process V2 Alessio Igor Bogani
2011-04-05 17:22 ` [PATCH] module: Use the binary search for symbols resolution Alessio Igor Bogani
2011-04-07 13:49   ` Jason Wessel
2011-04-12  3:48   ` Rusty Russell [this message]
2011-04-12 22:36     ` Anders Kaseorg

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=87aafwceop.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=abogani@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tabbott@ksplice.com \
    --cc=tim.bird@am.sony.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome