From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 6CBAC33C182 for ; Sun, 2 Aug 2026 20:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785703473; cv=none; b=VEEDKxeUrxvzG3rZ9+VbpmwONFU4PGVZ7gvhS8AceyIx3CHDtvS+AYE0QZBudRJkAkFmFb3vHvi+1eHeFqnP1kQf5rB2xu0ahDRyEgfkkLAhWMVqDBAU/yyvn7gGTuyJJGg8c/qJpoV7MnpBt6RAIpW3K6e97Vr6f/omHb0Yexo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785703473; c=relaxed/simple; bh=XoF2yLF3AcvHIdTsY8+5xQfUf5rqYNg3g91Py3R48nM=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jf2/IAOl+2r69Bd64XKZPtvCxfPc879uRYgBoGW0+cZtgWxc7y07rH7SMc/LxmTDucM24RqlgX2nWWMltG9j0KhPmwvd187PF+4s2EUuzltVQYJE4Mi/3NwZKRUIBCwRpG965kLIVFt64gnbh806bbcbsqsyZ3+doe3Xk9IfYII= 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=CYQqho85; arc=none smtp.client-ip=209.85.221.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="CYQqho85" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-47f93b2fe4cso1614579f8f.0 for ; Sun, 02 Aug 2026 13:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785703471; x=1786308271; 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=J0Po6SXhfV2vXQAkV6y/NPCPoeX6dz+V1IoPOu929LY=; b=CYQqho85vIYW54C7T/LuNZF+XP6kEz6GqinVZd1K45OrdACOK4fgJjVPvVO9V/TLu+ m5pzpiGV/TT81y2lwNF1tE1gvBLvRi8pfB/TeJtePmAma7/nUFgWzswVXoVH39GROu20 hWLe5PVSruXssnNjOS0qPqI4Fy2+SG6Cqs4/FAHqpS+a5S7sPzEPvYmbNfaKczaNow5+ m8UgU3VvNGlj5t2NRX0l+o7yaC2JLHk4Z2luVhn7c9PFQim8qf492rpDwas2Z76XPoFz HcrnR7n4R0YLzFJzxC0k8l3b4MbRPKpR2MS36dL5ADVdngCYazpAb+bDmVxFnl81Sebs cePw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785703471; x=1786308271; 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=J0Po6SXhfV2vXQAkV6y/NPCPoeX6dz+V1IoPOu929LY=; b=agwchdpOXEsKQT27/MJaDstI9qcuSKSiiDe8REH9l6TfIvLvBp7FwkeH3rdKJqE40e F8U8m+XleUca78BtqxNC9+gg37xc2tnW7DOhq5CJFO9atesRV1yN/os1JIg/L/YzU7lZ B4IyqByOn5ZVhRwmnx37nqrm3MKYauouJk/J3bKeuJt+CcL6nrqgUxxNnN9+PDLhw9ra Ae+FTXossJ1KYbF0t0kr2EFnFkrjGPqbHLqSD+1AWN1On67bZBymhc4rO6/WhOKWmyxp t7n3iiS7O7evlFNhOSTI8A/zkoD2szQ6SLuuM4QD0YTNcVG9vrSohrB1A1a9SWA/YaI+ 6D3w== X-Forwarded-Encrypted: i=1; AHgh+Ro0gWU3TJf2fO22de4o5CmwRZAtPUvaYO+ijaai5+ZrI+KMks2idoe1sChaTIbp9tV3OfZXX8t9ve/TPzk=@vger.kernel.org X-Gm-Message-State: AOJu0YxlWkQrODK0aHAcqT9HYH6Yu7dUGcD0PtmvTCbuoOAIOJIHkVZM 5wga86UJtW9A2nq7ADNjh5CG6Y+mZYxEmg1YyoR3ppASEvUEwbJu9HZx X-Gm-Gg: AR+sD11Qy0fxPfsvlyLgRrq39NIcq9MA6SEcuoQoGcYtTwlJkkOhW6wRlG84GhsdooF 8J+zlGxdJeF/l/Ta7DnlHK86hmC5L1F5r0tt0UxM/PMM3UuocsmqkujTg550WDQ9tS7igAOQXmb zLZOxCqvvQbIsJ72zTdzDLLRE+IU5ZtWkC5jt/8C5oKT9TQzwOkuWT1J2b4PxrZieDu6cgkIjJr ZTzPfPpG2DCyd2jf1p1kfIRBazP2SSwY201Hr4VkyDFLiLg+wxiSaRrCT/axAfj8YFqWvmvtOZ3 Qd71zNAv/j+WrSaXbMUkQRX0W7G5Sg5J/aDlCSb1iWc2yRpnzTTrhpXF5zhVehIZEzI9il/eD5d MjWWoWBfNHkwCG8uHwYsnIxrMS/1AecFO52oXhz9oU2xPbvQv/sVeVHW1rzvJ+wFWwVMIy/9Hhz qjuHL5nM1vuGgoAap6CjcZphqrg7WTfymww9gvPieE8jqKg73d X-Received: by 2002:a05:600c:a4d:b0:493:e46e:157d with SMTP id 5b1f17b1804b1-4980c693eaemr164544645e9.19.1785703470644; Sun, 02 Aug 2026 13:44:30 -0700 (PDT) Received: from krava ([176.74.159.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49807b8d04fsm218215135e9.3.2026.08.02.13.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 13:44:29 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Sun, 2 Aug 2026 22:44: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> <3f8e64b4-e60a-4eba-afb6-5af668ac1f85@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: <3f8e64b4-e60a-4eba-afb6-5af668ac1f85@linux.dev> On Fri, Jul 31, 2026 at 10:30:37AM +0800, Leon Hwang wrote: > 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. please paste the link/subject for that thread thanks, jirka