diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2023-01-19 17:07:15 -0800 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2023-01-19 17:07:50 -0800 |
| commit | 00b8f39f1d15c7e16e3f5ca7538f522f3a89131f (patch) | |
| tree | 143f3ba40e705b2c470f90c491ecd38935581482 /kernel/module | |
| parent | 92afc5329a5b23d876b215b783d200352d5aaea6 (diff) | |
| parent | 6a5f2d6ee8d515d5912e33d63a7386d03854a655 (diff) | |
Merge branch 'kallsyms: Optimize the search for module symbols by livepatch and bpf'
Jiri Olsa says:
====================
hi,
sending new version of [1] patchset posted originally by Zhen Lei.
It contains 2 changes that improove search performance for livepatch
and bpf.
v3 changes:
- fixed off by 1 issue, simplified condition, added acks [Song]
- added module attach as subtest [Andrii]
v2 changes:
- reworked the bpf change and meassured the performance
- adding new selftest to benchmark kprobe multi module attachment
- skipping patch 3 as requested by Zhen Lei
- added Reviewed-by for patch 1 [Petr Mladek]
thanks,
jirka
[1] https://lore.kernel.org/bpf/20221230112729.351-1-thunder.leizhen@huawei.com/
---
Jiri Olsa (2):
selftests/bpf: Add serial_test_kprobe_multi_bench_attach_kernel/module tests
bpf: Change modules resolving for kprobe multi link
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/module')
| -rw-r--r-- | kernel/module/kallsyms.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index 4523f99b0358..ab2376a1be88 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -494,7 +494,8 @@ unsigned long module_kallsyms_lookup_name(const char *name) return ret; } -int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, +int module_kallsyms_on_each_symbol(const char *modname, + int (*fn)(void *, const char *, struct module *, unsigned long), void *data) { @@ -509,6 +510,9 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, if (mod->state == MODULE_STATE_UNFORMED) continue; + if (modname && strcmp(modname, mod->name)) + continue; + /* Use rcu_dereference_sched() to remain compliant with the sparse tool */ preempt_disable(); kallsyms = rcu_dereference_sched(mod->kallsyms); @@ -525,6 +529,13 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, if (ret != 0) goto out; } + + /* + * The given module is found, the subsequent modules do not + * need to be compared. + */ + if (modname) + break; } out: mutex_unlock(&module_mutex); |
