From: Jiri Olsa <olsajiri@gmail.com>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Jiri Olsa <olsajiri@gmail.com>, Naveen N Rao <naveen@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
x86@kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCHv2 1/2] kprobes: Increase the kprobe hash table size
Date: Wed, 25 Nov 2026 23:05:27 +0100 [thread overview]
Message-ID: <awdbpwBAyzIdG9tL@krava> (raw)
In-Reply-To: <undine-1795616480318619368-1be7e961905611b5@undined.local>
On Wed, Nov 25, 2026 at 11:21:20PM +0900, Masami Hiramatsu (Google) wrote:
SNIP
> > > If this change is intended solely to improve performance for an extremely
> > > unlikely use case, I would, at the very least, make the size configurable
> > > via Kconfig.
> > >
> > > Since this change affects all architectures, those working with small,
> > > embedded-system chips might be reluctant to "pay" 32 KB for a use case
> > > that is highly unlikely to ever occur.
> >
> > I can add CONFIG_KPROBE_HASH_BITS with range 6-16. I'd keep 6 for
> > CONFIG_BASE_SMALL, so small systems don't pay anything, and use
> > 10 (8KB on 64-bit) as the default otherwise, which gets most of the
> > speedup from the table in the changelog
>
> That is good. If you introduce the inline function support which is
> enabled by some kconfig, that kconfig can increase the hash bits. That
> should be more reasonable.
yes, good idea, something like below, I'll send that as part of the
inline tracing changes
thanks,
jirka
---
diff --git a/arch/Kconfig b/arch/Kconfig
index 1163736de1f9..350144df6863 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -141,6 +141,23 @@ config KPROBES
for kernel debugging, non-intrusive instrumentation and testing.
If in doubt, say "N".
+config KPROBE_HASH_BITS
+ int "Kprobe hash table size in bits" if EXPERT
+ depends on KPROBES
+ range 6 16
+ default 10 if DEBUG_INFO_BTF_INLINE
+ default 6
+ help
+ Size of the kprobe hash table as a power of two. The default
+ of 6 (64 buckets) is enough for a small number of probes.
+
+ Attaching to inlined functions can register thousands of
+ kprobes at once, so the default is raised to 10 (1024 buckets,
+ 8KB on 64-bit) when the inline site information is available
+ (DEBUG_INFO_BTF_INLINE).
+
+ If in doubt, keep the default.
+
config JUMP_LABEL
bool "Optimize very unlikely/likely branches"
depends on HAVE_ARCH_JUMP_LABEL
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index f14f7ff45961..eba446e8ae37 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -50,7 +50,7 @@
#include <asm/errno.h>
#include <linux/uaccess.h>
-#define KPROBE_HASH_BITS 6
+#define KPROBE_HASH_BITS CONFIG_KPROBE_HASH_BITS
#define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS)
#if !defined(CONFIG_OPTPROBES) || !defined(CONFIG_SYSCTL)
next prev parent reply other threads:[~2026-11-25 22:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 20:02 [PATCHv2 0/2] kprobes: Reduce registration lookup costs Jiri Olsa
2026-11-22 20:02 ` [PATCHv2 1/2] kprobes: Increase the kprobe hash table size Jiri Olsa
2026-11-23 23:49 ` Masami Hiramatsu (Google)
2026-11-24 14:19 ` Jiri Olsa
2026-11-25 14:21 ` Masami Hiramatsu (Google)
2026-11-25 22:05 ` Jiri Olsa [this message]
2026-11-22 20:02 ` [PATCHv2 2/2] x86/kprobes: Use ftrace_location_range in __recover_probed_insn Jiri Olsa
2026-11-23 18:07 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awdbpwBAyzIdG9tL@krava \
--to=olsajiri@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=naveen@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.