Skip to content

kprobes: Reduce registration lookup costs

Jiri Olsa bpf linux-trace-kernel lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesIn review
  2. v113 patches 16 repliesSuperseded

Changes in v2 from the cover letter

- 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

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2kprobes: Increase the kprobe hash table sizekernel/kprobes.c+1 -11 reply
2/2x86/kprobes: Use ftrace_location_range in __recover_probed_insnarch/x86/kernel/kprobes/core.c include/linux/ftrace.h+9 -11 reply

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchSteven Rostedt
1/2
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

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

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/[email protected]/
[2] https://lore.kernel.org/bpf/[email protected]/
---
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(-)