All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Alessio Igor Bogani <abogani@kernel.org>,
	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: Re: [PATCH 1/4] module: Restructure each_symbol() code
Date: Tue, 19 Apr 2011 11:01:51 +0930	[thread overview]
Message-ID: <87r58z3u2g.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1302960373-5309-2-git-send-email-abogani@kernel.org>

On Sat, 16 Apr 2011 15:26:10 +0200, Alessio Igor Bogani <abogani@kernel.org> wrote:
> Restructure code to better integrate future improvements.

I like all the rest, but I find the function names here a bit confusing.

How about using this (untested!) patch instead?

Thanks!
Rusty.
---
Subject: module: each_symbol_section instead of each_symbol

Instead of having a callback function for each symbol in the kernel,
have a callback for each array of symbols.

This eases the logic when we move to sorted symbols and binary search.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/include/linux/module.h b/include/linux/module.h
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -477,8 +477,9 @@ const struct kernel_symbol *find_symbol(
 					bool warn);
 
 /* Walk the exported symbol table */
-bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
-			    unsigned int symnum, void *data), void *data);
+bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
+				    struct module *owner,
+				    void *data), void *data);
 
 /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
    symnum out of range. */
diff --git a/kernel/module.c b/kernel/module.c
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -240,23 +240,24 @@ static bool each_symbol_in_section(const
 				   struct module *owner,
 				   bool (*fn)(const struct symsearch *syms,
 					      struct module *owner,
-					      unsigned int symnum, void *data),
+					      void *data),
 				   void *data)
 {
-	unsigned int i, j;
+	unsigned int j;
 
 	for (j = 0; j < arrsize; j++) {
-		for (i = 0; i < arr[j].stop - arr[j].start; i++)
-			if (fn(&arr[j], owner, i, data))
-				return true;
+		if (fn(&arr[j], owner, data))
+			return true;
 	}
 
 	return false;
 }
 
 /* Returns true as soon as fn returns true, otherwise false. */
-bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
-			    unsigned int symnum, void *data), void *data)
+bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
+				    struct module *owner,
+				    void *data),
+			 void *data)
 {
 	struct module *mod;
 	static const struct symsearch arr[] = {
@@ -309,7 +310,7 @@ bool each_symbol(bool (*fn)(const struct
 	}
 	return false;
 }
-EXPORT_SYMBOL_GPL(each_symbol);
+EXPORT_SYMBOL_GPL(each_symbol_section);
 
 struct find_symbol_arg {
 	/* Input */
@@ -323,9 +324,9 @@ struct find_symbol_arg {
 	const struct kernel_symbol *sym;
 };
 
-static bool find_symbol_in_section(const struct symsearch *syms,
-				   struct module *owner,
-				   unsigned int symnum, void *data)
+static bool test_symbol_for_find(const struct symsearch *syms,
+				 struct module *owner,
+				 unsigned int symnum, void *data)
 {
 	struct find_symbol_arg *fsa = data;
 
@@ -365,6 +366,19 @@ static bool find_symbol_in_section(const
 	return true;
 }
 
+static bool find_symbol_in_section(const struct symsearch *syms,
+				   struct module *owner,
+				   void *data)
+{
+	unsigned int i;
+
+	for (i = 0; i < syms->stop - syms->start; i++) {
+		if (test_symbol_for_find(syms, owner, i, data))
+			return true;
+	}
+	return false;
+}
+
 /* Find a symbol and return it, along with, (optional) crc and
  * (optional) module which owns it.  Needs preempt disabled or module_mutex. */
 const struct kernel_symbol *find_symbol(const char *name,
@@ -379,7 +393,7 @@ const struct kernel_symbol *find_symbol(
 	fsa.gplok = gplok;
 	fsa.warn = warn;
 
-	if (each_symbol(find_symbol_in_section, &fsa)) {
+	if (each_symbol_section(find_symbol_in_section, &fsa)) {
 		if (owner)
 			*owner = fsa.owner;
 		if (crc)

  reply	other threads:[~2011-04-19  1:31 UTC|newest]

Thread overview: 28+ 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 [this message]
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   ` 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
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 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
2011-05-15  8:28                       ` 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=87r58z3u2g.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --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=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.