All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alessio Igor Bogani <abogani@kernel.org>
To: 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>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Embedded <linux-embedded@vger.kernel.org>,
	Alessio Igor Bogani <abogani@kernel.org>
Subject: [PATCH 4/4] module: Use the binary search for symbols resolution
Date: Fri, 15 Apr 2011 17:24:57 +0200	[thread overview]
Message-ID: <1302881097-563-5-git-send-email-abogani@kernel.org> (raw)
In-Reply-To: <1302881097-563-1-git-send-email-abogani@kernel.org>

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 |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 8845a0b..731173c 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>
@@ -244,12 +245,15 @@ static bool each_symbol_in_section(const struct symsearch *arr,
 					      unsigned int symnum, void *data),
 				   void *data)
 {
-	unsigned int i, j;
+	unsigned int j;
+	const struct kernel_symbol *sym, *start;
+	size_t size = sizeof(struct kernel_symbol);
 
 	for (j = 0; j < arrsize; j++) {
-		for (i = 0; i < arr[j].stop - arr[j].start; i++)
-			if (cmp(data, &arr[j].start[i]) == 0)
-				return fn(&arr[j], owner, i, data);
+		start = arr[j].start;
+		sym = bsearch(data, start, arr[j].stop - arr[j].start, size, cmp);
+		if (sym != NULL)
+			return fn(&arr[j], owner, sym - start, data);
 	}
 
 	return false;
-- 
1.7.0.4

  parent reply	other threads:[~2011-04-15 15:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 15:24 [PATCH 0/4] Speed up the symbols' resolution process V3 Alessio Igor Bogani
2011-04-15 15:24 ` [PATCH 1/4] module: Split the find_symbol_in_section function Alessio Igor Bogani
2011-04-15 15:24 ` [PATCH 2/4] module: Sort exported symbols Alessio Igor Bogani
2011-04-15 15:24 ` [PATCH 3/4] lib: Add generic binary search function to the kernel Alessio Igor Bogani
2011-04-15 15:24   ` Alessio Igor Bogani
2011-04-15 15:24 ` Alessio Igor Bogani [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-16 13:26 [PATCH 0/4] Speed up the symbols' resolution process V4 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
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

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=1302881097-563-5-git-send-email-abogani@kernel.org \
    --to=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 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.