Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755610Ab1DPOcO (ORCPT ); Sat, 16 Apr 2011 10:32:14 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:41830 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751447Ab1DPOcJ (ORCPT ); Sat, 16 Apr 2011 10:32:09 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:reply-to:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=I6KRCnM//LDVrX5oM3FxMgDfAQMb4MP5QmkjUzsrq9UYW9IbIwQ7CwKxCyBAVXJSS2 iZmPs694JZKyIgz3E8hBpu+ady/qR7c2yQSFNpdfl/7t5PbH5Iz6IZ7gFctrj+uHqLmh n2+G9S6EahUNMC8PmzTpjAgB8zkFOOUNv3hX8= MIME-Version: 1.0 Reply-To: wanlong.gao@gmail.com In-Reply-To: <1302960373-5309-5-git-send-email-abogani@kernel.org> References: <1302960373-5309-1-git-send-email-abogani@kernel.org> <1302960373-5309-5-git-send-email-abogani@kernel.org> Date: Sat, 16 Apr 2011 22:32:08 +0800 X-Google-Sender-Auth: wO5zXOm_QaiuBHZOOPrOvwHeewk Message-ID: Subject: Re: [PATCH 4/4] module: Use the binary search for symbols resolution From: Wanlong Gao To: Alessio Igor Bogani Cc: Rusty Russell , Tim Abbott , Anders Kaseorg , Jason Wessel , Tim Bird , LKML , Linux Embedded Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2342 Lines: 77 On 4/16/11, Alessio Igor Bogani 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 > --- > 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 > #include > #include > +#include > > #define CREATE_TRACE_POINTS > #include > @@ -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, As the bsearch func, why not change the syms->stop to syms->end ? Hmm..Just a stupid suggestion. Thanks > + 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 > > -- > 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/ > -- 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/