[PATCH] kallsyms: skip kernel symbols when lookup in module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kernel symbols lookup is expensive, when we know it's a lookup in module,
we can skip the heavy kernel symbols.

Signed-off-by: Cheng Renquan <crquan@xxxxxxxxx>
---
 kernel/kallsyms.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 8e5288a..bb9fdc5 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -173,12 +173,16 @@ unsigned long kallsyms_lookup_name(const char *name)
 	unsigned long i;
 	unsigned int off;
 
-	for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
-		off = kallsyms_expand_symbol(off, namebuf);
+	/* if a colon ':' found, skip the heavy kernel symbols */
+	if (strchr(name, ':') == NULL) {
+		for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
+			off = kallsyms_expand_symbol(off, namebuf);
 
-		if (strcmp(namebuf, name) == 0)
-			return kallsyms_addresses[i];
+			if (strcmp(namebuf, name) == 0)
+				return kallsyms_addresses[i];
+		}
 	}
+
 	return module_kallsyms_lookup_name(name);
 }
 EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
-- 
1.6.5

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

[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux