Re: [PATCH 4/4] module: Use the binary search for symbols resolution

2011-04-19 Thread Wanlong Gao

 2011-4-19 19:35, Rusty Russell wroted:

On Tue, 19 Apr 2011 09:44:20 +0800, Wanlong Gaowanlong@gmail.com  wrote:

   2011-4-19 9:37, Rusty Russell wroted:

On Sat, 16 Apr 2011 22:32:08 +0800, Wanlong Gaowanlong@gmail.com   wrote:

+   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.



The names are derived from the linker symbols for end of sections, which
is __stop_sectionname.

Cheers,
Rusty.

As this , why not change the bsearch's end to stop, too ? It will be
more readable.


I'm confused.  bsearch uses a count, not an end pointer...

Rusty.


Hmm...I see, I see . I made a mistake on this func .
Thanks for your explanation.

Best regards
--
To unsubscribe from this list: send the line unsubscribe linux-embedded in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] module: Use the binary search for symbols resolution

2011-04-18 Thread Rusty Russell
On Sat, 16 Apr 2011 22:32:08 +0800, Wanlong Gao wanlong@gmail.com wrote:
  +   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.


The names are derived from the linker symbols for end of sections, which
is __stop_sectionname.

Cheers,
Rusty.
--
To unsubscribe from this list: send the line unsubscribe linux-embedded in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] module: Use the binary search for symbols resolution

2011-04-18 Thread Wanlong Gao

 2011-4-19 9:37, Rusty Russell wroted:

On Sat, 16 Apr 2011 22:32:08 +0800, Wanlong Gaowanlong@gmail.com  wrote:

+   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.



The names are derived from the linker symbols for end of sections, which
is __stop_sectionname.

Cheers,
Rusty.
As this , why not change the bsearch's end to stop, too ? It will be 
more readable.


Thanks
Wanlong
--
To unsubscribe from this list: send the line unsubscribe linux-embedded in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] module: Use the binary search for symbols resolution

2011-04-16 Thread Wanlong Gao
On 4/16/11, Alessio Igor Bogani abog...@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 abog...@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,
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 majord...@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-embedded in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html