[PATCH 2/2] perf symbol: Simplify kernel module checking

From: Namhyung Kim
Date: Fri Apr 26 2024 - 17:51:52 EST


In dso__load(), it checks if the dso is a kernel module by looking the
symtab type. Actually dso has 'is_kmod' field to check that easily and
dso__set_module_info() set the symtab type and the is_kmod bit. So it
should have the same result to check the is_kmod bit.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/util/symbol.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 63936269ec15..50969c687135 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1811,10 +1811,7 @@ int dso__load(struct dso *dso, struct map *map)
goto out;
}

- kmod = dso__symtab_type(dso) == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
- dso__symtab_type(dso) == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP ||
- dso__symtab_type(dso) == DSO_BINARY_TYPE__GUEST_KMODULE ||
- dso__symtab_type(dso) == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
+ kmod = dso__is_kmod(dso);

if (dso__kernel(dso) && !kmod) {
if (dso__kernel(dso) == DSO_SPACE__KERNEL)
--
2.44.0.769.g3c40516874-goog