From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Jiri Olsa" <jolsa@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>
Cc: <bpf@vger.kernel.org>, "Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Mike Rapoport" <rppt@kernel.org>
Subject: Re: [PATCH bpf-next] bpf, x86: Use global buffer for trampoline size generation
Date: Mon, 07 Sep 2026 12:56:33 -0700 [thread overview]
Message-ID: <DL9CKPXX2OFG.2EK0RAZUT2PMV@gmail.com> (raw)
In-Reply-To: <20260907160538.922450-1-jolsa@kernel.org>
On Mon Sep 7, 2026 at 9:05 AM PDT, Jiri Olsa wrote:
> Currently arch_bpf_trampoline_size allocates and frees a temporary
> trampoline buffer on every invocation. The buffer is only used as a
> scratch space while __arch_prepare_bpf_trampoline() calculates the
> required size, and the generated trampoline is discarded.
>
> Allocating a writable scratch page during kernel initialization and
> reusing it for all size calculations. This improves tracing_multi
> attachment time.
>
> With current code:
>
> # ./test_progs -t tracing_multi_bench_attach -v
> ...
> serial_test_tracing_multi_bench_attach: found 55227 functions
> serial_test_tracing_multi_bench_attach: attached in 1.563s
> serial_test_tracing_multi_bench_attach: detached in 0.256s
>
> With the fix:
>
> # ./test_progs -t tracing_multi_bench_attach -v
> ...
> serial_test_tracing_multi_bench_attach: found 55235 functions
> serial_test_tracing_multi_bench_attach: attached in 0.798s
> serial_test_tracing_multi_bench_attach: detached in 0.258s
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> was "bpf, x86: Add support for jit dry run",
> - doing this by having single scratch page instead as suggested by Alexei
>
> arch/x86/net/bpf_jit_comp.c | 30 +++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
> index bba351944202..13ef0d53ca29 100644
> --- a/arch/x86/net/bpf_jit_comp.c
> +++ b/arch/x86/net/bpf_jit_comp.c
> @@ -9,6 +9,7 @@
> #include <linux/filter.h>
> #include <linux/if_vlan.h>
> #include <linux/bitfield.h>
> +#include <linux/init.h>
> #include <linux/bpf.h>
> #include <linux/bpf_verifier.h>
> #include <linux/memory.h>
> @@ -35,6 +36,15 @@ void __asan_store8(void *p);
>
> static bool all_callee_regs_used[4] = {true, true, true, true};
>
> +static void *trampoline_size_image;
> +
> +static int __init init_trampoline_size_image(void)
> +{
> + trampoline_size_image = execmem_alloc(EXECMEM_MODULE_DATA, PAGE_SIZE);
I think I asked it earlier... why does it have to be execmem ?
Can it be normal page?
If so then alloc it and free it every time. No need to keep one page in reserve.
pw-bot: cr
next prev parent reply other threads:[~2026-09-07 19:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 16:05 [PATCH bpf-next] bpf, x86: Use global buffer for trampoline size generation Jiri Olsa
2026-09-07 16:20 ` sashiko-bot
2026-09-07 19:56 ` Alexei Starovoitov [this message]
2026-09-07 20:26 ` Jiri Olsa
2026-09-08 0:13 ` Alexei Starovoitov
2026-09-08 12:25 ` Jiri Olsa
2026-09-08 15:19 ` Mike Rapoport
2026-09-09 9:49 ` Jiri Olsa
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=DL9CKPXX2OFG.2EK0RAZUT2PMV@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=jolsa@kernel.org \
--cc=martin.lau@linux.dev \
--cc=rppt@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox