Skip to contentSkip to conversation

kallsyms: skip kernel symbols when lookup in module

PATCH In review Cheng Renquan 2 participants 2 messages Jan 7, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kallsyms: skip kernel symbols when lookup in module

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

---
 kernel/kallsyms.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
kernel/kallsyms.c +8 -4
index 8e5288a..bb9fdc5 100644
@@ -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);
Signature · 1 line
1.6.5
Acked-by on v1 1/1
#1 lore raw
Quoted 23 lines · Cheng Renquan

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

---
 kernel/kallsyms.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
kernel/kallsyms.c +4 -2
index 8e5288a..bb9fdc5 100644
@@ -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);
 

kernel/kallsyms.c unsigned long kallsyms_lookup_name(const char *name) · line 188

Quoted 10 lines
kernel/kallsyms.c +4 -2
-		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);

It think Rusty is the right person to handle this (CC added). But if you want my opinion: The patch looks ok.

Michal