From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (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 CFA5B3368AB for ; Thu, 30 Jul 2026 03:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785380767; cv=none; b=q5s7ERZDufa5PFAQk8el6Hnpw1HB2rsjf5YXww4hWHrv+vWjV0xT+rtZHJJcGJBKJliPGbTcnFScYaeC0Dx1tlSlHtGBd+nO9wCyH5b3knwv4WhiwntadePsqBBZrq9MSvgyS5er50OG9SYaJwy64pmPqnvhKQ0fabhB3rtW/48= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785380767; c=relaxed/simple; bh=cllLhgmRjXVeqwURSS43GIa+82qyOa48o4iQoBUuXwk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aW/H407IH0uImVDncgt782GBjZhLUzVV2KIt4K/3piVOTuJJp5UqYi7iwAijnPM27JD5++9M7HTF5xC20ff1ZiXVD7b39HHhQJvM/KQMLquQBWoK2FJwaqDOuTOu/21zWJrXB6XUpZuTStuWJkBZcKlmdFVvAXk2K/woNWgMhUI= 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=DP14HDqt; arc=none smtp.client-ip=91.218.175.171 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="DP14HDqt" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785380753; 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=eMkah/7xCdD4zUghDYh4eVNm7WoXmd5uInZAQK3gLPA=; b=DP14HDqt8/CWCynEUMpJuo5di6yH7F1t3gzWP9h5l5ZP5yRB8fSAQsJyc3igiPwr4sXStT UMKuJWYdNe15ZE0uL72LHZDVS3nEW3+3HoK/kKgm5hIAhhndT5GUTYq2PWvO8ztr1CMzab LXWPuRRQbVlQNMnJeIRsKmX2Y92EnMw= Date: Thu, 30 Jul 2026 11:05:42 +0800 Precedence: bulk X-Mailing-List: linux-kselftest@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 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