From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (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 EFFA3280035 for ; Wed, 10 Dec 2025 03:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765337562; cv=none; b=RobJfxQSz9X4eLhuExLplwYQV4wxecFARpV5/amJsfZSAW9vGcuPA+BkTCKj58gsE7tZaAD2UjcVsnxQRqqmgyu6C8uy+oNrKkI+m7ipdETTgo3P6dkPl+nZlOA7QUsYF7qadEEsLPc5QSfOXA4+dcZheU5bQ7OwX+zPMjZo9Mc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765337562; c=relaxed/simple; bh=T9WCLU2heQLPYVuJVNA9WnOL1ESb6KLpEYEyRkAYZiM=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=T4qonFyND/bv9I84gczchJDzekdrRvaMcLGruvYup4xVh59NSxATjPNF3qoV6ak9vP07S3B+JmmwX5BjUfldgBDBV0FJxaIbjMSpnCzHzyVsCJt3OM17lDMUhHTeuaiwobAiqyiyTz19rs+00jKmH/E+VPMTrgwF6Zm1BQoYkVc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=GSX9bEbU; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="GSX9bEbU" Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5B9MSimg4154876 for ; Tue, 9 Dec 2025 19:32:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=s2048-2025-q2; bh=rFO2YsjMGZcIIj/uFguu FKsd93GM4jw6C5He4DUQsWI=; b=GSX9bEbU1T40Xg/fyJSnktm0HsBJK+CMPYIN t9wR08wCdaha9QamKdHgCoGMJsEpuKtf8wPgsKIWrtOxDS27Z7WCvz8PyCMrrb7A P4N5uah6NcshkPdG6UHTQ2oS+Dj/h35cBe1LetVqsxqW80I+ORxHkWxSTdzmo46o OAJ27v50viTa1rBcBW6TThZeccvzOnW6bNNMMUKyGUpazszAFJiBpOagJUXidh4a b91tOy7KY5KvvpLYOxTPP+QpSlzv9Fs9/hGjSO84tC3wBhDXtwzHAwI/066hHrcu LQ7t2/NSozEdz9Fn5QYC8/WnG4cmmKy6fexwfnjrron4HtJWcg== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 4axr25vagn-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 09 Dec 2025 19:32:38 -0800 (PST) Received: from twshared13861.04.snb2.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c08b:78::c78f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.29; Wed, 10 Dec 2025 03:32:35 +0000 Received: by devbig071.cco5.facebook.com (Postfix, from userid 704538) id 76794B4122FC; Tue, 9 Dec 2025 19:32:29 -0800 (PST) Date: Tue, 9 Dec 2025 19:32:29 -0800 From: Ben Niu To: Mark Rutland CC: Ben Niu , Ben Niu , Catalin Marinas , Will Deacon , , , , Subject: Withdraw [PATCH v2] tracing: Enable kprobe for selected Arm64 assembly Message-ID: References: <20251103185237.2284456-1-benniu@meta.com> 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: X-FB-Internal: Safe X-Proofpoint-GUID: JAVIjUA7pWSmwhFm9kCTFpuGq1A48PYI X-Authority-Analysis: v=2.4 cv=V+1wEOni c=1 sm=1 tr=0 ts=6938e9d6 cx=c_pps a=CB4LiSf2rd0gKozIdrpkBw==:117 a=CB4LiSf2rd0gKozIdrpkBw==:17 a=kj9zAlcOel0A:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=9AdMxfjQAAAA:20 a=o1Hv5u3xvNx8kE97pkcA:9 a=CjuIK1q_8ugA:10 a=bA3UWDv6hWIuX7UZL3qL:22 X-Proofpoint-ORIG-GUID: JAVIjUA7pWSmwhFm9kCTFpuGq1A48PYI X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjEwMDAyOSBTYWx0ZWRfXzDuCDuEGdeWY 9ga8TfAWK7QAI8JUamAtPuV6FXv6Zrfx5LFBDYbTCRQdH4clQvonzaEORG14rY9WyXT1g1rUaPE BluJ6yE4z5+wxH+T2F+qOAFV333PTnawXz61lRVbj5YPsWiS1IGfhfJSt/0VaZ8j/Cezp6Xt93Z +62xd9M50wk4PPejmA0S/TSxVhO4EWMDAC7orFGhBtNHa9u9+CGQ4oKQvp+9VSDtIdccmWhfoqD nw4Mwr7vQ9rBiH36N5jBqPuB/b5OcKXPwQR3sJ6GuxpiYjz7qo2wpOE3mQLn8mT6dziXQw64VOm NCmjJFlucLcyK89J1+CmakJLHEciDzohPw4J7o3DpYlrJqeN56mizjZdWNb4w2PFZElrzedJX1C 6Cv3lZFhLelKeN1iwtKPc4sI5Yq6Mw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-09_05,2025-12-09_03,2025-10-01_01 On Mon, Nov 17, 2025 at 10:14:25AM +0000, Mark Rutland wrote: > On Mon, Nov 03, 2025 at 10:52:35AM -0800, Ben Niu wrote: > > When ftrace is enabled, a function can only be kprobe'd if > > (1) the function has proper nops inserted at the beginning > > (2) the first inserted nop's address is added in section > > __patchable_function_entries. > > > > See function within_notrace_func in kernel/trace/trace_kprobe.c > > for more details. > > As mentioned last time, this isn't accurate, and this is at the wrong > level of abstraction. You're conflating kprobes with kprobes-based trace > evnts, and you're describing the implementation details of ftrace rather > than the logical situation that the function needs to be traceable via > ftrace > > This would be better summarized as: > > While kprobes can be placed on most kernel functions, kprobes-based > trace events can only be placed on functions which are traceable via > ftrace (unless CONFIG_KPROBE_EVENTS_ON_NOTRACE=y). Thanks. I'm withdrawing this patch because my colleague suggested a workaround that could trace __arch_copy_to_user/__arch_copy_from_user without any changes for the kernel: bpftrace -q -e ' BEGIN { printf("Attaching to __arch_copy_to_user...\n"); } watchpoint:'"0x$(grep ' __arch_copy_to_user$' /proc/kallsyms | awk '{print $1}')"':4:x { $n = reg("r2"); @__arch_copy_to_user_sizes = hist($n); }' > IIUC from last time you only want this so that you can introspect > __arch_copy_to_user() and __arch_copy_from_user(), so why can't you > select CONFIG_KPROBE_EVENTS_ON_NOTRACE in your test kernel? That would > require zero kernel changes AFAICT. CONFIG_KPROBE_EVENTS_ON_NOTRACE has this help message, see https://github.com/torvalds/linux/blob/c9b47175e9131118e6f221cc8fb81397d62e7c91/kernel/trace/Kconfig#L798, that discourages production enablement, so we didn't turn it on. > I'm not keen on doing this unless absolutely necessary, and as above it > looks like we already have suitable options to make this possible for > your use-case. This patch is no longer needed. > > This patch adds a new asm function macro SYM_FUNC_START_TRACE > > that makes an asm funtion satisfy the above two conditions so that > > it can be kprobe'd. In addition, the macro is applied to > > __arch_copy_to_user and __arch_copy_from_user, which were found > > to be hot in certain workloads. > > > > Note: although this patch unblocks kprobe tracing, fentry is still > > broken because no BTF info gets generated from assembly files. A > > separate patch is needed to fix that. > > As above, I'm not keen on doing this, and if it's largely incomplete, I > think that's another nail in the coffin. > > [...] > > > +#ifdef CONFIG_ARM64_BTI_KERNEL > > +#define BTI_C bti c; > > +#else > > +#define BTI_C > > +#endif > > Please note that we deliberately chose to always output BTI for asm > functions to avoid a performance vaiability depending on whether BTI was > enabled, so if we're going to change that, we must do that as a > preparatory step with a clear rationale. Ok, thanks for clarifying that. > Mark.