From: Jiri Olsa <olsajiri@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
bpf@vger.kernel.org, andrii@kernel.org,
Menglong Dong <dongml2@chinatelecom.cn>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH bpf 1/2] x86/ftrace: Use jmp mode only where functions are aligned
Date: Sun, 25 Oct 2026 14:18:53 +0100 [thread overview]
Message-ID: <at4BvTcsjWwDuvbl@krava> (raw)
In-Reply-To: <DMDB1EESN4U0.KLEICFNC4NUP@gmail.com>
On Sat, Oct 24, 2026 at 07:10:57PM +0000, Alexei Starovoitov wrote:
> On Sat, Oct 24, 2026 at 12:37 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
> > Bit 0 has that meaning only for the direct trampolines that a dyn_ftrace
> > record can point to, so jmp mode relies on every other target being even.
> > Select HAVE_DYNAMIC_FTRACE_WITH_JMP only where it is, with
> > CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT or without CONFIG_CC_OPTIMIZE_FOR_SIZE.
>
> Disabling it for -Os builds is not great.
> Can we fix the users of ftrace_call_replace() instead ?
looks good, it takes care of the C function targets, the rest
should be aligned ftrace trampolines (static or dynamic) or
direct api targets
jirka
>
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 17d6edf..654c3f2 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -190,11 +190,11 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> const char *new;
>
> ip = (unsigned long)(&ftrace_call);
> - new = ftrace_call_replace(ip, (unsigned long)func);
> + new = text_gen_insn(CALL_INSN_OPCODE, (void *)ip, func);
> smp_text_poke_single((void *)ip, new, MCOUNT_INSN_SIZE, NULL);
>
> ip = (unsigned long)(&ftrace_regs_call);
> - new = ftrace_call_replace(ip, (unsigned long)func);
> + new = text_gen_insn(CALL_INSN_OPCODE, (void *)ip, func);
> smp_text_poke_single((void *)ip, new, MCOUNT_INSN_SIZE, NULL);
>
> return 0;
> @@ -503,7 +503,7 @@ void arch_ftrace_update_trampoline(struct ftrace_ops *ops)
>
> mutex_lock(&text_mutex);
> /* Do a safe modify in case the trampoline is executing */
> - new = ftrace_call_replace(ip, (unsigned long)func);
> + new = text_gen_insn(CALL_INSN_OPCODE, (void *)ip, func);
> smp_text_poke_single((void *)ip, new, MCOUNT_INSN_SIZE, NULL);
> mutex_unlock(&text_mutex);
> }
>
next prev parent reply other threads:[~2026-10-25 13:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 7:37 [PATCH bpf 1/2] x86/ftrace: Use jmp mode only where functions are aligned Daniel Borkmann
2026-10-24 7:37 ` [PATCH bpf 2/2] selftests/bpf: Test kprobe and fentry programs on one function Daniel Borkmann
2026-10-24 19:10 ` [PATCH bpf 1/2] x86/ftrace: Use jmp mode only where functions are aligned Alexei Starovoitov
2026-10-25 13:18 ` Jiri Olsa [this message]
2026-10-25 15:27 ` Daniel Borkmann
2026-10-25 17:38 ` Alexei Starovoitov
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=at4BvTcsjWwDuvbl@krava \
--to=olsajiri@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dongml2@chinatelecom.cn \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox