From: Wanlong Gao <wanlong.gao@gmail.com>
To: Alessio Igor Bogani <abogani@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
Tim Abbott <tabbott@ksplice.com>,
Anders Kaseorg <andersk@ksplice.com>,
Jason Wessel <jason.wessel@windriver.com>,
Tim Bird <tim.bird@am.sony.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Embedded <linux-embedded@vger.kernel.org>
Subject: Re: [PATCH 4/4] module: Use the binary search for symbols resolution
Date: Sat, 16 Apr 2011 22:08:48 +0800 [thread overview]
Message-ID: <BANLkTikVMv_3vjypP=+ZCmn5BwEazRZ36w@mail.gmail.com> (raw)
In-Reply-To: <1302960373-5309-5-git-send-email-abogani@kernel.org>
On 4/16/11, Alessio Igor Bogani <abogani@kernel.org> wrote:
> Takes advantage of the order and locates symbols using binary search.
>
> This work was supported by a hardware donation from the CE Linux Forum.
>
> Signed-off-by: Alessio Igor Bogani <abogani@kernel.org>
> ---
> kernel/module.c | 23 ++++++++++++++++-------
> 1 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index b438b25..74a57c1 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -57,6 +57,7 @@
> #include <linux/kmemleak.h>
> #include <linux/jump_label.h>
> #include <linux/pfn.h>
> +#include <linux/bsearch.h>
>
> #define CREATE_TRACE_POINTS
> #include <trace/events/module.h>
> @@ -351,22 +352,30 @@ struct find_symbol_arg {
> const struct kernel_symbol *sym;
> };
>
> +static int cmp_name(const void *va, const void *vb)
> +{
> + const char *a;
> + const struct kernel_symbol *b;
> + a = va; b = vb;
> + return strcmp(a, b->name);
> +}
> +
> static bool find_symbol_in_symsearch(const struct symsearch *syms,
> struct module *owner,
> void *data)
> {
> struct find_symbol_arg *fsa = data;
> + struct kernel_symbol *sym;
> unsigned int symnum;
> - int result;
>
> - for (symnum = 0; symnum < syms->stop - syms->start; symnum++) {
> - result = strcmp(fsa->name, syms->start[symnum].name);
> - if (result == 0)
> - break;
> - }
> - if (symnum >= syms->stop - syms->start)
> + sym = bsearch(fsa->name, syms->start, syms->stop - syms->start,
> + sizeof(struct kernel_symbol), cmp_name);
> +
> + if (sym == NULL)
> return false;
>
> + symnum = sym - syms->start;
> +
> if (!fsa->gplok) {
> if (syms->licence == GPL_ONLY)
> return false;
> --
> 1.7.4.1
>
> --
It seems like a great work .
Thanks
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
next prev parent reply other threads:[~2011-04-16 14:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-16 13:26 [PATCH 0/4] Speed up the symbols' resolution process V4 Alessio Igor Bogani
2011-04-16 13:26 ` [PATCH 1/4] module: Restructure each_symbol() code Alessio Igor Bogani
2011-04-19 1:31 ` Rusty Russell
2011-04-16 13:26 ` [PATCH 2/4] module: Sort exported symbols Alessio Igor Bogani
2011-04-16 13:26 ` [PATCH 3/4] lib: Add generic binary search function to the kernel Alessio Igor Bogani
2011-04-16 13:26 ` [PATCH 4/4] module: Use the binary search for symbols resolution Alessio Igor Bogani
2011-04-16 14:08 ` Wanlong Gao [this message]
2011-04-16 14:32 ` Wanlong Gao
2011-04-19 1:37 ` Rusty Russell
2011-04-19 1:44 ` Wanlong Gao
2011-04-19 11:35 ` Rusty Russell
2011-04-19 12:46 ` Wanlong Gao
2011-04-27 15:31 ` [PATCH 0/4] Speed up the symbols' resolution process V4 Dirk Behme
2011-05-11 3:32 ` Mike Frysinger
2011-05-11 7:04 ` Alessio Igor Bogani
2011-05-11 9:19 ` Alessio Igor Bogani
2011-05-11 13:44 ` Alessio Igor Bogani
2011-05-11 14:47 ` Mike Frysinger
2011-05-11 15:25 ` Alessio Igor Bogani
2011-05-11 15:52 ` Mike Frysinger
2011-05-12 9:10 ` Alessio Igor Bogani
2011-05-12 14:30 ` Mike Frysinger
2011-05-13 7:01 ` Alessio Igor Bogani
2011-05-14 17:32 ` Mike Frysinger
2011-05-15 8:28 ` Alessio Igor Bogani
-- strict thread matches above, loose matches on Subject: below --
2011-04-15 15:24 [PATCH 0/4] Speed up the symbols' resolution process V3 Alessio Igor Bogani
2011-04-15 15:24 ` [PATCH 4/4] module: Use the binary search for symbols resolution Alessio Igor Bogani
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='BANLkTikVMv_3vjypP=+ZCmn5BwEazRZ36w@mail.gmail.com' \
--to=wanlong.gao@gmail.com \
--cc=abogani@kernel.org \
--cc=andersk@ksplice.com \
--cc=jason.wessel@windriver.com \
--cc=linux-embedded@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--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;
as well as URLs for NNTP newsgroup(s).