From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60DB62309B2 for ; Fri, 31 Jul 2026 02:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785465075; cv=none; b=o0+6UFJvopuPMRsJ+9AZkwThC661od2Ko29XiXJOPMskMjB8F2YVIWUXmptCQ3yuiaU4iOiuN5Up096ZrObel3/PLxyKQhYa1og9BJQAp7zPU9pcPFGaNfI9URIffxN7zPZIfIvzQEcIHxdEYiG8GqHN0SzNPf+u9mtC/sWC5Ic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785465075; c=relaxed/simple; bh=0DgxL8B455K7k+RhedyR+qazvps3OmmxNNo2GvFJZrc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZGZ42lc+y6xtls+L+pomQ5ICBkQ7QyUBkXmq1I5IKPJikip/YegpzQ7morq7fz90aSRaJ3B4fEAV0sCNGaVB9ktDD8A0u3orZi1uXgOjkdUFZ/XK2SPyucS33RiXzSKFpaS23CKFj/BFuhrTWNwcZlBGnSwhOOc0PwE5QXO/yLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=YpGoNeNN; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="YpGoNeNN" Message-ID: <3f8e64b4-e60a-4eba-afb6-5af668ac1f85@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785465071; 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=go9e1FTWLKxTTOfTi113qwmgUMtPejwq61+ADMUh6Dc=; b=YpGoNeNNwTqx9ibJwMxEeOMg0AK9brZQjsfrgeSAz/B/G1V0kjp7YOAKgCHRHgVPRYkT5w tVsin+P46wlmcpajdK6uJO1VSehLEpOLnGg+ktVcOKNXSVWF46rE68ku1et81odaYsHCeJ o0D7L0eOMgHQ8go3cYwoCLXYxleh/lU= Date: Fri, 31 Jul 2026 10:30:37 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH 1/2] arm64: ftrace: enable single ftrace_ops for direct calls To: Jiri Olsa Cc: 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 , Emil Tsalapatis , Shuah Khan , 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: Leon Hwang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 30/7/26 18:58, Jiri Olsa wrote: > On Thu, Jul 30, 2026 at 11:05:42AM +0800, Leon Hwang wrote: >> 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 any 2nd user on the same function triggers the slow path, > and that's fine, the single_ops handles slow path correctly > > but IIUC the out-of-range target will now always go through slow path, > which in current code it doesn't, right? > Right. Pls see the sibling thread with Ihor. With in-range BPF trampoline allocation, the slow-path regression should mostly disappear. Let's continue the discussion in that thread. Thanks, Leon