From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B87A408600 for ; Thu, 30 Jul 2026 10:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785409113; cv=none; b=nN/ENiFZRxYf9DciElxUCeWXPyiygW4djY8WL9IQ6nSZl90li9ucBbaNaPUXdore9oXALL4KYOuAMTf9Xa+e3cJETJz3J2dnUWx51Wb13UXV2bdnzGee1hF8hhJkFmiE/A8Zi/rGSg4VYl9Br9/DJoj8ctPsqAWyj7+kBBkdBOY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785409113; c=relaxed/simple; bh=OUZJe9ibUbTY3/iskfpej3snXo+kezysiy+SxHFR7w4=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Nqb+aDE9xnzRME5DCr9mjOcuo4WSo1bhzdHV+FDsPDtJQ302c//0pAlaAl8m5pobWXIPH2tN/ZT10nVAEkrRCzIRr109yYZrYY0tk+nwbi2Dry3aOltJNTtma1kS0OFPH1VtBWkZBk0x+iZsRHqkREVYuLMmr61nnpdueqcSLWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=p0mjHqGu; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p0mjHqGu" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-c1712a04ddaso330150366b.2 for ; Thu, 30 Jul 2026 03:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785409110; x=1786013910; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=BtmEW6LmpN3hbmzYM7Cf4iCPw5cw70uOQWik1DIJVKg=; b=p0mjHqGuHmE4rHDrfSwM/V0o+jJpbKJ7EJO6fvpk+LTEC1E/PoFtOUISPW/6oQIWxp CszJci8hAV4UeJeSWR9WG2mJ77RujcSGRnrgVYLbFNjCHBiYmQNM9CTO+si5Vs9M9YRI JqJBktYIKXYOQBl82moIa0O6XBc8w1X95iloT2zFsb7oe2gdkMNDw5skKO+kpbIQ8x0I ATSktbcUXeQdRajCoLvE5G3Kqb13U3EKsReQRc7PxFqF08BUfIJ8+qQQNQctKCIPfDzw 9PMceRqdnZoVj3E6xXO37Zm1aqbaYgrMxG26zUDPTa23Mv/+k2oB2TYx2RpwY2havJ/e vV0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785409110; x=1786013910; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BtmEW6LmpN3hbmzYM7Cf4iCPw5cw70uOQWik1DIJVKg=; b=Sp9rDRoBsItmskdzAs+pAUOTOGkVNNrxY7Oo//DI100a0Vd7/PyvFuLQGLvx3iyVFE sTlJPmf8+OoFQLkIyz8FH/dTmcX+pdpUjbQqKsKVkyuFqX0X6yS+qWCu0NC466U6zIiF lIgcjT5OWx/QGi3odxsiawXdOgLAsB1uCEa7PsNJvDCw9d1n7ao1I1SAEZhYZ2paN8iR RW0vJn9p/FbDUImoFrF4XbBiUHfITET+TGm2GS4wAT7QcGyyknA/U2+DHlGPy797yC56 bfE9t9aYIzOhob48/HsofYyn+EEsKouPJStdAwodc7GngzRICdetL4bTrbcYnTMa+klx e7Aw== X-Forwarded-Encrypted: i=1; AHgh+Rp64hX8Or9thItVTSeG2CfZXnZogHbzPyW40i3AncRg6XBP8KGgdXVW41RdrlspCIc+JE275BTrkVXMqpY=@vger.kernel.org X-Gm-Message-State: AOJu0YxQTtxV60KOp3CaC3t1jxinohV0oFj/ydUYYtep6QreDBAyiqNJ TibwChwaYWxwiXD47OTBAutCx2ZT+ELfnX0VvOZSksUeF0IC4QE6YeQo X-Gm-Gg: AR+sD10NEgfArs79DxFDEN43wAcTOgurfDAjJ7U44epTfPmOeEFK/oVeZJKH2PB81Cr cWteqLF2asJwAibnsef/IGs+7j0T3yQphMTnsu+bNcL9y2KiRF1p/8q3rdl6rlfaAOKF2zl/XiH omGWIde65Ob1ZnLbMjsPYiTpV2jLELpBKKRrLddrnLlPan9ywSCIuxDCJeBXoFAR7EHJmsh6GRc gZehm2Tnjjp912nXHZeNeDu55ij5po5y3abRPJvWE0GDwWFomDNrUjA3VUqaxv/yOFaJOMJcfbH oq1dOdGJLOnY+HpN0olSbeawIMqLuxyB4adUK7+dihMj/7gmsiKDC5FTCnkHakImlPw034JFPad Aey2uA+C+bYImi2S/DxdVTCD/lnZKTmzq5UyAsSNqd7tqEJaSYBm+jXiwcGlupuIppK/hj2nptx YMacWBUnH/As6QAkf/6uJ5JhNYYspM0cXJ1VVdAEaNeqGocDU= X-Received: by 2002:a17:907:9443:b0:c1c:4afd:8d8c with SMTP id a640c23a62f3a-c1fa558e48emr104613966b.14.1785409110114; Thu, 30 Jul 2026 03:58:30 -0700 (PDT) Received: from krava ([173.38.220.35]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1fa8578015sm55934266b.18.2026.07.30.03.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 03:58:29 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Thu, 30 Jul 2026 12:58:27 +0200 To: Leon Hwang Cc: Jiri Olsa , 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 Subject: Re: [PATCH 1/2] arm64: ftrace: enable single ftrace_ops for direct calls Message-ID: References: <20260727142844.21212-1-leon.hwang@linux.dev> <20260727142844.21212-2-leon.hwang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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? jirka