crash/0004-symbols-Intergrate-symbol_exists-with-mod_symname_ha.patch
Lianbo Jiang e1f6e2b6fb Update to the latest upstream <68870c83d299>
Release: crash-7.3.0-5

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
2021-11-06 14:37:23 +08:00

75 lines
1.9 KiB
Diff

From f3bee9375ed32b85e7f81a5e46a0040620553ae0 Mon Sep 17 00:00:00 2001
From: Tao Liu <ltao@redhat.com>
Date: Sat, 16 Oct 2021 13:21:14 +0800
Subject: [PATCH 4/9] symbols: Intergrate symbol_exists() with mod_symname_hash
search
This patch introduces mod_symname_hash search to symbol_exists()
to improve its performance. And code refactoring for
kernel_symbol_exists().
Signed-off-by: Tao Liu <ltao@redhat.com>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
---
symbols.c | 35 ++++-------------------------------
1 file changed, 4 insertions(+), 31 deletions(-)
diff --git a/symbols.c b/symbols.c
index 83393f09270d..8d3dd95f737b 100644
--- a/symbols.c
+++ b/symbols.c
@@ -5481,33 +5481,11 @@ value_symbol(ulong value)
int
symbol_exists(char *symbol)
{
- int i;
- struct syment *sp, *sp_end;
- struct load_module *lm;
-
- if ((sp = symname_hash_search(st->symname_hash, symbol)))
+ if (symname_hash_search(st->symname_hash, symbol))
return TRUE;
- for (i = 0; i < st->mods_installed; i++) {
- lm = &st->load_modules[i];
- sp = lm->mod_symtable;
- sp_end = lm->mod_symend;
-
- for ( ; sp < sp_end; sp++) {
- if (STREQ(symbol, sp->name))
- return(TRUE);
- }
-
- if (lm->mod_init_symtable) {
- sp = lm->mod_init_symtable;
- sp_end = lm->mod_init_symend;
-
- for ( ; sp < sp_end; sp++) {
- if (STREQ(symbol, sp->name))
- return(TRUE);
- }
- }
- }
+ if (symname_hash_search(st->mod_symname_hash, symbol))
+ return TRUE;
return(FALSE);
}
@@ -5562,12 +5540,7 @@ per_cpu_symbol_search(char *symbol)
int
kernel_symbol_exists(char *symbol)
{
- struct syment *sp;
-
- if ((sp = symname_hash_search(st->symname_hash, symbol)))
- return TRUE;
- else
- return FALSE;
+ return !!symname_hash_search(st->symname_hash, symbol);
}
/*
--
2.30.2