[PATCHv2 0/2] kprobes: Reduce registration lookup costs

From: Jiri Olsa

Date: Sun Nov 22 2026 - 15:02:54 EST


hi,
this is a smaller follow up to the v1 series [1]. This version does
only partial fixes of what v1 addressed. Instead of the rbtree and
iterators, it makes the existing per-address lookups cheaper:

- increase the kprobe hash table from 64 to 4096 buckets, so the
get_kprobe() calls done for every byte or decoded instruction
around the new probe walk short chains instead of 300+ entries
per bucket with 20000 probes

- use ftrace_location_range() in x86 __recover_probed_insn(), so we
skip the symbol lookup ftrace_location() does for every decoded
instruction that is not an ftrace location

Registering kprobes with the kprobe_many_example sample module [2] from
v1 in a KVM guest goes from 4.71s to 1.30s for 20000 probes and from
29.99s to 3.64s for 50000 probes with the hash table change, and the
ftrace change brings 20587 probes from 4.02s to 3.70s. Please check the
changelogs for more details, the first patch has numbers for different
hash table sizes.

v2 changes:
- dropped the static_call/jump_label indexes and the kprobe rbtree
and iterators [will be addressed later]
- added hash table size increase and the ftrace_location_range
change for __recover_probed_insn

thanks,
jirka


[1] https://lore.kernel.org/bpf/20261109194916.1089703-1-jolsa@xxxxxxxxxx/
[2] https://lore.kernel.org/bpf/20261109195827.1091410-1-jolsa@xxxxxxxxxx/
---
Jiri Olsa (2):
kprobes: Increase the kprobe hash table size
x86/kprobes: Use ftrace_location_range in __recover_probed_insn

arch/x86/kernel/kprobes/core.c | 6 +++++-
include/linux/ftrace.h | 4 ++++
kernel/kprobes.c | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)