Linux Trace Kernel
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Shuah Khan <shuah@kernel.org>,
	bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 1/2] arm64: ftrace: enable single ftrace_ops for direct calls
Date: Thu, 30 Jul 2026 11:05:42 +0800	[thread overview]
Message-ID: <d745ca80-6516-4c61-8107-88c6a2d9cea4@linux.dev> (raw)
In-Reply-To: <amnqXeC6D4mjcAe_@krava>

On 29/7/26 19:56, Jiri Olsa wrote:
> On Mon, Jul 27, 2026 at 10:28:43PM +0800, Leon Hwang wrote:
>> The BPF tracing multi link updates several direct-call sites through one
>> ftrace_ops. Its implementation is therefore gated by
>> HAVE_SINGLE_FTRACE_DIRECT_OPS in addition to
>> DYNAMIC_FTRACE_WITH_DIRECT_CALLS.
>>
>> Select HAVE_SINGLE_FTRACE_DIRECT_OPS whenever arm64 enables dynamic ftrace
>> direct calls. This enables BPF tracing multi links on arm64. Also
>> generalize the unreachable-trampoline comment because the single-ops path
>> does not use ops->direct_call.
> 
> hi,
> iirc arm needs ops->direct_call for trampolines to work properly,
> that's the reason we enabled single ftrace_ops on x86 only:
> 
>   424f6a361096 bpf,x86: Use single ftrace_ops for direct calls
> 
> I don't understand the arm usage of op->direct_call, but it looks like
> (codex thinks) that the fast path won't always work without op->direct_call
> being set


In theory, op->direct_call is the fallback for the case:
HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS=y, out-of-range target, and non-BPF
direct ops. This is what Codex thinks about.

However, after searching the call sites of
register_ftrace_direct()/__modify_ftrace_direct() in kernel, which would
set ops->direct_call, the actual callers are in bpf/trampoline.c, which
have been gated with HAVE_SINGLE_FTRACE_DIRECT_OPS. That said, for
normal usage of HAVE_SINGLE_FTRACE_DIRECT_OPS=y, op->direct_call is unused.

If someone uses register_ftrace_direct() or
modify_ftrace_direct/_nolock() outside BPF in the future,
op->direct_call will be used.

So, I'd like to drop the comment change in the next revision.

Thanks,
Leon

> 
> from arch/arm64/kernel/entry-ftrace.S:
> 
> 	#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
> 		/*
> 		 * If the op has a direct call, handle it immediately without
> 		 * saving/restoring registers.
> 		 */
> 		ldr     x17, [x11, #FTRACE_OPS_DIRECT_CALL]             // op->direct_call
> 		cbnz    x17, ftrace_caller_direct
> 	#endif
> 	#endif
> 
> jirka


  reply	other threads:[~2026-07-30  3:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 14:28 [PATCH 0/2] arm64: ftrace: enable single ftrace_ops for direct calls Leon Hwang
2026-07-27 14:28 ` [PATCH 1/2] " Leon Hwang
2026-07-29 11:56   ` Jiri Olsa
2026-07-30  3:05     ` Leon Hwang [this message]
2026-07-27 14:28 ` [PATCH 2/2] selftests/bpf: Enable tracing_multi tests on arm64 Leon Hwang

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=d745ca80-6516-4c61-8107-88c6a2d9cea4@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=olsajiri@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=will@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