From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9629C55165 for ; Thu, 30 Jul 2026 23:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OAzNMKmzxCFzEOWAiEeFQaer1iebyg6cnDmy70dSSVc=; b=NnEYKvnHB/+Ou2WAAYPZ8/ikDo bidSA8rr2fQY0p/oepLUelwEoZFt8q2suCk/eW3zaR0F1hmdOQdoeIq2xOgNKKMk89wgcYOk+8IWH LTXbOseLYgzp1sOjPdIA5Opm1+dOwEkYY2CsIFh5AySMYgj2BjyJBrq63tKoYQi0rhiDjlZ52SMeJ ctaRK9g/OvHgOhlQYXxbLkeQjKu8gwJ9COcjdwXAnEnehHaYYsT1qCYuFECzPAoaEaNhqOT+ynnO0 sNMVYJyrTSSJSek1FsHvFlbkccxX47bonTkkAteUYZX0MZiwjbUA3u6Lr7dTP9mZvelI2VV8PzmQ5 PppsOj/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wpZnG-0000000BSo5-0pEF; Thu, 30 Jul 2026 23:04:02 +0000 Received: from out-183.mta1.migadu.com ([95.215.58.183]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wpZnB-0000000BSnX-2Mz0 for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2026 23:04:01 +0000 Message-ID: <77edc25d-a521-4f65-84ed-dbb016593902@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785452631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OAzNMKmzxCFzEOWAiEeFQaer1iebyg6cnDmy70dSSVc=; b=ByXJ6MS1MhKl0IZKznqW2J5nDrksOfD/dwgBIHmiEQXINrWpU3ijNcB6h40pP7yFC5i1vM gUD57GI4yWuIFnk56E1motluBATL65JoyAMundcpQ2zA2vs6bjJIR14Nd3A/OfA2iTBfTn CMAjhXxMsRAxvi87UlEJeKSsQFE83ms= Date: Thu, 30 Jul 2026 16:03:33 -0700 MIME-Version: 1.0 Subject: Re: [PATCH 1/2] arm64: ftrace: enable single ftrace_ops for direct calls To: Leon Hwang , Catalin Marinas , Will Deacon , Steven Rostedt , Masami Hiramatsu , Mark Rutland , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Shuah Khan , "Jose Fernandez (Anthropic)" Cc: 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 References: <20260727142844.21212-1-leon.hwang@linux.dev> <20260727142844.21212-2-leon.hwang@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Ihor Solodrai In-Reply-To: <20260727142844.21212-2-leon.hwang@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260730_160359_324216_1C903BEE X-CRM114-Status: GOOD ( 23.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/27/26 7:28 AM, 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 Leon, I don't think this change can land as is yet. The series doesn't even apply cleanly to bpf-next, but that's minor. More importantly, it depends on Jose's series [1], which is not in the mainline yet. And there Mark has raised performance concerns [2] and the discussion still seems to be open. [1] https://lore.kernel.org/all/20260609-arm64-ftrace-direct-calls-v1-0-4a46f266697f@linux.dev/ [2] https://lore.kernel.org/all/amjnf5gz0xP5PTSB@J2N7QTR9R3/ > > Assisted-by: Codex:gpt-5.6-sol > Signed-off-by: Leon Hwang > --- > arch/arm64/Kconfig | 2 ++ > arch/arm64/kernel/ftrace.c | 3 +-- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 0de419ed780f..c98dca76859b 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -188,6 +188,8 @@ config ARM64 > CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS) > select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS \ > if DYNAMIC_FTRACE_WITH_ARGS > + select HAVE_SINGLE_FTRACE_DIRECT_OPS \ > + if DYNAMIC_FTRACE_WITH_DIRECT_CALLS\ The select is only conditional on DYNAMIC_FTRACE_WITH_DIRECT_CALLS, so it can be set along with HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS. And AFAIU this would make the fast path effectively dead: every BPF direct call routed through ftrace_caller now goes through the slow path. As Mark noted in the other thread, on arm64 trampolines come from EXECMEM_BPF, so they always land out of BL range (chance of landing in range is 256M/terabytes). I vibe-slop-coded a benchmark and ran it on a Neoverse V2 machine, and toggling your config change seems to be causing a 1.3x regression in the tracing overhead: do-nothing fentry (r0=0; exit) on __arm64_sys_getpid, 20 M calls, min-of-N, several boots. Results: untraced (base) traced overhead Kernel A ~128 ns/call ~145.5 ns ~17.6 ns (fast path: br x17) Kernel B ~127 ns/call ~150.4 ns ~23.4 ns (slow path: save regs + call_direct_funcs + hash) This confirms Jiri's suspicion. However my understanding is the regression should mostly disappear in case some version of in-range trampoline allocation on arm64 lands. So, I think the landing sequence should be something like follows: * in-range BPF-trampoline allocation that Jose proposed [3] * then HAVE_SINGLE_FTRACE_DIRECT_OPS selection After all of that reaches mainline, then a selftest patch can go through the bpf-next. [3] https://lore.kernel.org/all/amn7cBQ-cqs2XlKV@linux.dev/ > select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS \ > if (DYNAMIC_FTRACE_WITH_ARGS && !CFI && \ > (CC_IS_CLANG || !CC_OPTIMIZE_FOR_SIZE)) > diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c > index e1a3c0b3a051..56ba72a87dfa 100644 > --- a/arch/arm64/kernel/ftrace.c > +++ b/arch/arm64/kernel/ftrace.c > @@ -301,8 +301,7 @@ static bool ftrace_find_callable_addr(struct dyn_ftrace *rec, > > /* > * If a custom trampoline is unreachable, rely on the ftrace_caller > - * trampoline which knows how to indirectly reach that trampoline > - * through ops->direct_call. > + * trampoline which knows how to indirectly reach that trampoline. > */ > if (*addr != FTRACE_ADDR && !reachable_by_bl(*addr, pc)) > *addr = FTRACE_ADDR;