From nobody Thu Apr 9 14:10:28 2026 Received: from outbound.pv.icloud.com (p-west1-cluster2-host3-snip4-6.eps.apple.com [57.103.64.237]) (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 CED0C242D86 for ; Sun, 8 Mar 2026 01:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.64.237 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772933162; cv=none; b=eNwR6TeTxIpdiQcm4g7M7EpOCDPp2nKANcEH/m10toDnGjIAUa2dg0/0RdZ9PE3TzAkXr4CNfwdsvg+y4opWk+ghLIg0owlhcLSvJClDFI+/9ZwISbfkeuiD5TmiLlxSta+HKU2UagtAAHG79QNzpDoFdOxeaRX3Gr3j+G+przQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772933162; c=relaxed/simple; bh=2lDNrix/6JgqqUUUGOJfMZrt3Exx/bNMvx/UEJxjQGU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XtK6cpJDEqs8MC+RKv02slnXGFaqiDAM060YRElEJnYWJAgTfHBqMRZItiM6VwqBB4bfkLDeMAHf+z2MCTlkgcL90Kn/kypHPF5SlXJTePBchljdYBj47GS/EzSb6rATjHbPZSnuDc2mb0JFzXD0QjJE6WJiArIg9WI9VNjJ1Fc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sdhn.cc; spf=pass smtp.mailfrom=sdhn.cc; dkim=pass (2048-bit key) header.d=sdhn.cc header.i=@sdhn.cc header.b=WJxUOpih; arc=none smtp.client-ip=57.103.64.237 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sdhn.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sdhn.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sdhn.cc header.i=@sdhn.cc header.b="WJxUOpih" Received: from outbound.pv.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-1a-100-percent-15 (Postfix) with ESMTPS id 60D13180009C; Sun, 8 Mar 2026 01:25:56 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sdhn.cc; s=sig1; t=1772933160; x=1775525160; bh=fiN/I4ahZLWYZQLjbE17jqLD4OgjZ+buF9TxmZMk6Qk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=WJxUOpihffNRIpGTUAAqOzzngmZb9O74QEu9myhId2h0F10DhEAzlg/P45nOm5+DSxhVqoDCTY1mZAmoPLi5LiYRkOibT87zwMVGVjUELso7zUOjCUZHRgPQm5E7izHOQ7Z2OadswEFueGurup8AQVjwhUa+ylFXSI0MO3S123Eu3ptNrZGhhHsQxJ3DeQ+0kESr/2TTcTXOzxNvVrudwKlKibuz8ks/bTxR57V3t6eDJvMzJh4msgPDh3egAWtDMgCa/jjhx6XSEVnYc0kzW15QQHtFEpEPK7bmheLm+Sr9UwIuMsz2IPL6lyZCVa1LbpgK4Z4XdmJ4NVFMlYCgiA== mail-alias-created-date: 1772007648188 Received: from [127.0.0.1] (unknown [17.56.9.36]) by p00-icloudmta-asmtp-us-west-1a-100-percent-15 (Postfix) with ESMTPSA id 0D68B180009D; Sun, 8 Mar 2026 01:25:51 +0000 (UTC) From: Mohamad Alsadhan Date: Sun, 08 Mar 2026 04:24:34 +0300 Subject: [PATCH v2 1/3] rust_binder: remove "rust_" prefix from tracepoints 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260308-rust-binder-trace-v2-1-9e38637a2193@sdhn.cc> References: <20260308-rust-binder-trace-v2-0-9e38637a2193@sdhn.cc> In-Reply-To: <20260308-rust-binder-trace-v2-0-9e38637a2193@sdhn.cc> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: Alice Ryhl , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Mohamad Alsadhan X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2539; i=mo@sdhn.cc; h=from:subject:message-id; bh=2lDNrix/6JgqqUUUGOJfMZrt3Exx/bNMvx/UEJxjQGU=; b=owGbwMvMwCV2WSbwWIGm61bG02pJDJlrLkgHh7Te4NMJvNrb1PX4/2Xjz7f/BJ9e+/5IyjPxm M+Pj6rP7ShlYRDjYpAVU2R5ft776MEfN8zOnN97CmYOKxPIEAYuTgGYyOlpjAyT1ScG+Th/i7uz j78nRu9G+aZf8my114W+P2JRCr3mbbGK4a/wBKsKrfP9/zskfff1vnu9tsW/d1HibaWIO9OP3PZ +uo0HAA== X-Developer-Key: i=mo@sdhn.cc; a=openpgp; fpr=E7CF4BC5C1F8D836CCCFBDCAD31C51C6702945B5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA4MDAxMSBTYWx0ZWRfX28Wvf833dC1A lRMQu2/z1z1LecyDPYulk1bPwGpyPtrvF4rSl6lIsrCdiE27eSVlJfuWSYm9MEyyEc0VPV/9IFz H9aIjY+IjpGg35WkrdCIEwDmDIVnsxl4hxXknFadZvsP5Mce6pccfNSQ0no02IG3Z5WvRvT3/CF E2U8d0qBY0O2BcjKm7PyzW1zBS9fW/sZjkTngpvqZKHvsuU2RtOYKE5AP1T8FOCx0tGf8Pxot71 UMvwaEs5/3uYDesERVFM8L7irg39yVXcxtTA+U3jka5oyKpctMIbNFLBKrqY8mdtvc4ERs1ognd pW0g6wA8+FYgfdguPpEO11CLIbpbQYuYNQuqokwuel5I1091BI46+vnw4PBueo= X-Authority-Info-Out: v=2.4 cv=PL0COPqC c=1 sm=1 tr=0 ts=69acd025 cx=c_apl:c_pps:t_out a=azHRBMxVc17uSn+fyuI/eg==:117 a=azHRBMxVc17uSn+fyuI/eg==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=NEAV23lmAAAA:8 a=1XWaLZrsAAAA:8 a=9KE4tSwBFA36Xu7-v7wA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: JwOowl9hEmu5_oL8NkJRGgWGoArDilxP X-Proofpoint-ORIG-GUID: JwOowl9hEmu5_oL8NkJRGgWGoArDilxP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-07_08,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=617 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 clxscore=1030 lowpriorityscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603080011 Remove the "rust_" prefix as the name is part of the uapi, and userspace expects tracepoints to have the old names. Link: https://github.com/Rust-for-Linux/linux/issues/1226 Suggested-by: Alice Ryhl Signed-off-by: Mohamad Alsadhan Reviewed-by: Alice Ryhl --- drivers/android/binder/rust_binder_events.h | 4 ++-- drivers/android/binder/trace.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/android/binder/rust_binder_events.h b/drivers/android/= binder/rust_binder_events.h index 8ad785c6b..e3adfb931 100644 --- a/drivers/android/binder/rust_binder_events.h +++ b/drivers/android/binder/rust_binder_events.h @@ -15,7 +15,7 @@ =20 #include =20 -TRACE_EVENT(rust_binder_ioctl, +TRACE_EVENT(binder_ioctl, TP_PROTO(unsigned int cmd, unsigned long arg), TP_ARGS(cmd, arg), =20 @@ -30,7 +30,7 @@ TRACE_EVENT(rust_binder_ioctl, TP_printk("cmd=3D0x%x arg=3D0x%lx", __entry->cmd, __entry->arg) ); =20 -TRACE_EVENT(rust_binder_transaction, +TRACE_EVENT(binder_transaction, TP_PROTO(bool reply, rust_binder_transaction t, struct task_struct *threa= d), TP_ARGS(reply, t, thread), TP_STRUCT__entry( diff --git a/drivers/android/binder/trace.rs b/drivers/android/binder/trace= .rs index 9839901c7..d54b18ab7 100644 --- a/drivers/android/binder/trace.rs +++ b/drivers/android/binder/trace.rs @@ -10,8 +10,8 @@ use kernel::tracepoint::declare_trace; =20 declare_trace! { - unsafe fn rust_binder_ioctl(cmd: c_uint, arg: c_ulong); - unsafe fn rust_binder_transaction(reply: bool, t: rust_binder_transact= ion, thread: *mut task_struct); + unsafe fn binder_ioctl(cmd: c_uint, arg: c_ulong); + unsafe fn binder_transaction(reply: bool, t: rust_binder_transaction, = thread: *mut task_struct); } =20 #[inline] @@ -22,7 +22,7 @@ fn raw_transaction(t: &Transaction) -> rust_binder_transa= ction { #[inline] pub(crate) fn trace_ioctl(cmd: u32, arg: usize) { // SAFETY: Always safe to call. - unsafe { rust_binder_ioctl(cmd, arg as c_ulong) } + unsafe { binder_ioctl(cmd, arg as c_ulong) } } =20 #[inline] @@ -33,5 +33,5 @@ pub(crate) fn trace_transaction(reply: bool, t: &Transact= ion, thread: Option<&Ta }; // SAFETY: The raw transaction is valid for the duration of this call.= The thread pointer is // valid or null. - unsafe { rust_binder_transaction(reply, raw_transaction(t), thread) } + unsafe { binder_transaction(reply, raw_transaction(t), thread) } } --=20 2.52.0 From nobody Thu Apr 9 14:10:28 2026 Received: from outbound.pv.icloud.com (p-west1-cluster2-host4-snip4-10.eps.apple.com [57.103.64.251]) (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 03EB42494ED for ; Sun, 8 Mar 2026 01:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.64.251 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772933175; cv=none; b=PpsRsWYKiJgReVUvckz4vXAO+Lp+E+vafNHmDLt33ULfudjyIAhogC4PB2OvhsXh/iNlrHThI0ZY1cQQPp2HD4Ni8HSVdGHD1A11UF2U6fm/ewy6l7mbK/W8zipwEnmrzRgsQ7fESez5bDdJt6OChRSaARt3vu5znQwQ4DAcZj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772933175; c=relaxed/simple; bh=DqypF3Sy33qTYdmfEG2YtjBufra49mHQVtOVhw5H9nU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iyL3dREI/5awEuslxxChjqydySckJlggg5WLvlXbWUZSthqu5jcQ2rdZeguhelxikGQNzqj1to/fXiuuq6OX+FfK7XzRz+BYpSVc7Ld1tOnjVJ5s1/WDIPLix2JASJ98s/7l57oeeccePeoAa1sVw008QAxxfTPRHi6Vj1qQkDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sdhn.cc; spf=pass smtp.mailfrom=sdhn.cc; dkim=pass (2048-bit key) header.d=sdhn.cc header.i=@sdhn.cc header.b=pbvNeJfu; arc=none smtp.client-ip=57.103.64.251 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sdhn.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sdhn.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sdhn.cc header.i=@sdhn.cc header.b="pbvNeJfu" Received: from outbound.pv.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-1a-100-percent-15 (Postfix) with ESMTPS id C8435180009D; Sun, 8 Mar 2026 01:26:00 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sdhn.cc; s=sig1; t=1772933162; x=1775525162; bh=6FRYIU22hrDWHinjngzx8OKYcZUq9ZSqBuZEM7NraoM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=pbvNeJfuMUugIr2GK2yYP9oCF7EndNIFFP7vuSCz8FCfLXDordeoPY4PnbnI5/35evzEdwxLOiK5MpRalp0WZ5ErOTTaqEiDqx8DxkxlQubFh3njUbnj7JHbO0I5jX+OeQDWGeaznCBpzBXr+4fNFfEHhtLPBhLipXorgP+meJjXxLS1fTlTxSNm8lkSMh/yY6J2XSmPWUoA+umRWYg9kLPHsGEX8V0BZEng5tURQeRyAWwfVbaBHrDfc046aeJfZD7u9EcMUM5qJn/BZOMf80mw8bTAGXnA+/6JOs4lwg0gwOtQouL78L8KjsQbC/GFu702ABXplE86Kd+vFut6qg== mail-alias-created-date: 1772007648188 Received: from [127.0.0.1] (unknown [17.56.9.36]) by p00-icloudmta-asmtp-us-west-1a-100-percent-15 (Postfix) with ESMTPSA id 7AA64180024A; Sun, 8 Mar 2026 01:25:56 +0000 (UTC) From: Mohamad Alsadhan Date: Sun, 08 Mar 2026 04:24:35 +0300 Subject: [PATCH v2 2/3] rust_binder: add Rust binder tracepoints 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260308-rust-binder-trace-v2-2-9e38637a2193@sdhn.cc> References: <20260308-rust-binder-trace-v2-0-9e38637a2193@sdhn.cc> In-Reply-To: <20260308-rust-binder-trace-v2-0-9e38637a2193@sdhn.cc> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: Alice Ryhl , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Mohamad Alsadhan X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=11966; i=mo@sdhn.cc; h=from:subject:message-id; bh=DqypF3Sy33qTYdmfEG2YtjBufra49mHQVtOVhw5H9nU=; b=owGbwMvMwCV2WSbwWIGm61bG02pJDJlrLkj/Cvhrzbi4o1dF+tjOrP9nytO3567WEc8OOB6Ts cRPuOlnRykLgxgXg6yYIsvz895HD/64YXbm/N5TMHNYmUCGMHBxCsBELtQzMhy0rFnCo3aTZVXL KwGLjfxqFiz13x4fyW/ccUHO6Jf33iRGhsVWpaLlmjyLXvzoeX2k5uLev1N2FNdeeOyx2t90Hqe vICMA X-Developer-Key: i=mo@sdhn.cc; a=openpgp; fpr=E7CF4BC5C1F8D836CCCFBDCAD31C51C6702945B5 X-Authority-Info-Out: v=2.4 cv=Uo5u9uwB c=1 sm=1 tr=0 ts=69acd029 cx=c_apl:c_pps:t_out a=azHRBMxVc17uSn+fyuI/eg==:117 a=azHRBMxVc17uSn+fyuI/eg==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=NEAV23lmAAAA:8 a=1XWaLZrsAAAA:8 a=yrdkZQJbEJeQb0U9HD0A:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA4MDAxMSBTYWx0ZWRfX6MNFS7d6oDIT HNljIUeBufXWYSDLVyrCNbPcm/lLZHErdu7uZKaJyozya3G3cYKf8LlMvp4Es99cgTl0b+xABFL ZVP0Pghaoo3hEnR4vEQiGavWWKpj3xzWWnrqkShJ9TQvH8rnIzxl5K8ukRPJLRPsA5ePIQvbtOQ dS5D5svx/CzfmmOo3v63GP2LxFCdU8RATdC0tfz80Ug6BDGwTRjwRXjS/Fo2V3uhuG5rPI174ZJ tmVBsl5zFl/Z06mh/Da4wdLG8r181fP7JZHNo3WTB3C2PPCu1dyymYHB40M9X+0XIbfqq6TGVtp lvDiGlTcwWwOFpeDTUsUYQTu9uFb1z9/M0u64YQTuzBM4C5IbyBWxRnq5qoL04= X-Proofpoint-ORIG-GUID: uJzht-3TQbCvuiu8nr8pHi43zkrJmujE X-Proofpoint-GUID: uJzht-3TQbCvuiu8nr8pHi43zkrJmujE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-07_08,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 clxscore=1030 lowpriorityscore=0 spamscore=0 malwarescore=0 mlxlogscore=993 bulkscore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603080011 New tracepoints: `{ioctl,read,write}_done`, `wait_for_work`, `transaction_received`, `transaction_fd_{send,recv}`, `{alloc,free}_lru_{start,end}`, `alloc_page_{start,end}`, `unmap_{user,kernel}_{start,end}`, `command` and `return`. Link: https://github.com/Rust-for-Linux/linux/issues/1226 Suggested-by: Alice Ryhl Signed-off-by: Mohamad Alsadhan --- drivers/android/binder/rust_binder.h | 5 + drivers/android/binder/rust_binder_events.h | 172 ++++++++++++++++++++++++= ++++ drivers/android/binder/trace.rs | 109 +++++++++++++++++- 3 files changed, 284 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder/rust_binder.h b/drivers/android/binder/= rust_binder.h index d2284726c..3936b9d0b 100644 --- a/drivers/android/binder/rust_binder.h +++ b/drivers/android/binder/rust_binder.h @@ -99,4 +99,9 @@ static inline size_t rust_binder_node_debug_id(rust_binde= r_node t) return *(size_t *) (t + RUST_BINDER_LAYOUT.n.debug_id); } =20 +static inline binder_uintptr_t rust_binder_node_ptr(rust_binder_node t) +{ + return *(binder_uintptr_t *) (t + RUST_BINDER_LAYOUT.n.ptr); +} + #endif diff --git a/drivers/android/binder/rust_binder_events.h b/drivers/android/= binder/rust_binder_events.h index e3adfb931..6725453f5 100644 --- a/drivers/android/binder/rust_binder_events.h +++ b/drivers/android/binder/rust_binder_events.h @@ -30,6 +30,45 @@ TRACE_EVENT(binder_ioctl, TP_printk("cmd=3D0x%x arg=3D0x%lx", __entry->cmd, __entry->arg) ); =20 +DECLARE_EVENT_CLASS(binder_function_return_class, + TP_PROTO(int ret), + TP_ARGS(ret), + TP_STRUCT__entry( + __field(int, ret) + ), + TP_fast_assign( + __entry->ret =3D ret; + ), + TP_printk("ret=3D%d", __entry->ret) +); + +#define DEFINE_RBINDER_FUNCTION_RETURN_EVENT(name) \ +DEFINE_EVENT(binder_function_return_class, name, \ + TP_PROTO(int ret), \ + TP_ARGS(ret)) + +DEFINE_RBINDER_FUNCTION_RETURN_EVENT(binder_ioctl_done); +DEFINE_RBINDER_FUNCTION_RETURN_EVENT(binder_read_done); +DEFINE_RBINDER_FUNCTION_RETURN_EVENT(binder_write_done); + +TRACE_EVENT(binder_wait_for_work, + TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo), + TP_ARGS(proc_work, transaction_stack, thread_todo), + TP_STRUCT__entry( + __field(bool, proc_work) + __field(bool, transaction_stack) + __field(bool, thread_todo) + ), + TP_fast_assign( + __entry->proc_work =3D proc_work; + __entry->transaction_stack =3D transaction_stack; + __entry->thread_todo =3D thread_todo; + ), + TP_printk("proc_work=3D%d transaction_stack=3D%d thread_todo=3D%d", + __entry->proc_work, __entry->transaction_stack, + __entry->thread_todo) +); + TRACE_EVENT(binder_transaction, TP_PROTO(bool reply, rust_binder_transaction t, struct task_struct *threa= d), TP_ARGS(reply, t, thread), @@ -60,6 +99,139 @@ TRACE_EVENT(binder_transaction, __entry->reply, __entry->flags, __entry->code) ); =20 +TRACE_EVENT(binder_transaction_received, + TP_PROTO(rust_binder_transaction t), + TP_ARGS(t), + TP_STRUCT__entry( + __field(int, debug_id) + ), + TP_fast_assign( + __entry->debug_id =3D rust_binder_transaction_debug_id(t); + ), + TP_printk("transaction=3D%d", __entry->debug_id) +); + +TRACE_EVENT(binder_transaction_fd_send, + TP_PROTO(int t_debug_id, int fd, size_t offset), + TP_ARGS(t_debug_id, fd, offset), + TP_STRUCT__entry( + __field(int, debug_id) + __field(int, fd) + __field(size_t, offset) + ), + TP_fast_assign( + __entry->debug_id =3D t_debug_id; + __entry->fd =3D fd; + __entry->offset =3D offset; + ), + TP_printk("transaction=3D%d src_fd=3D%d offset=3D%zu", + __entry->debug_id, __entry->fd, __entry->offset) +); + +TRACE_EVENT(binder_transaction_fd_recv, + TP_PROTO(int t_debug_id, int fd, size_t offset), + TP_ARGS(t_debug_id, fd, offset), + TP_STRUCT__entry( + __field(int, debug_id) + __field(int, fd) + __field(size_t, offset) + ), + TP_fast_assign( + __entry->debug_id =3D t_debug_id; + __entry->fd =3D fd; + __entry->offset =3D offset; + ), + TP_printk("transaction=3D%d dest_fd=3D%d offset=3D%zu", + __entry->debug_id, __entry->fd, __entry->offset) +); + +DECLARE_EVENT_CLASS(binder_lru_page_class, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index), + TP_STRUCT__entry( + __field(int, proc) + __field(size_t, page_index) + ), + TP_fast_assign( + __entry->proc =3D pid; + __entry->page_index =3D page_index; + ), + TP_printk("proc=3D%d page_index=3D%zu", + __entry->proc, __entry->page_index) +); + +DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_start, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_alloc_lru_end, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_free_lru_start, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_free_lru_end, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_start, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_alloc_page_end, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_start, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_unmap_user_end, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_start, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +DEFINE_EVENT(binder_lru_page_class, binder_unmap_kernel_end, + TP_PROTO(int pid, size_t page_index), + TP_ARGS(pid, page_index)); + +TRACE_EVENT(binder_command, + TP_PROTO(uint32_t cmd), + TP_ARGS(cmd), + TP_STRUCT__entry( + __field(uint32_t, cmd) + ), + TP_fast_assign( + __entry->cmd =3D cmd; + ), + TP_printk("cmd=3D0x%x %s", + __entry->cmd, + _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? + binder_command_strings[_IOC_NR(__entry->cmd)] : + "unknown") +); + +TRACE_EVENT(binder_return, + TP_PROTO(uint32_t cmd), + TP_ARGS(cmd), + TP_STRUCT__entry( + __field(uint32_t, cmd) + ), + TP_fast_assign( + __entry->cmd =3D cmd; + ), + TP_printk("cmd=3D0x%x %s", + __entry->cmd, + _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? + binder_return_strings[_IOC_NR(__entry->cmd)] : + "unknown") +); + #endif /* _RUST_BINDER_TRACE_H */ =20 /* This part must be outside protection */ diff --git a/drivers/android/binder/trace.rs b/drivers/android/binder/trace= .rs index d54b18ab7..8bfe7f882 100644 --- a/drivers/android/binder/trace.rs +++ b/drivers/android/binder/trace.rs @@ -5,13 +5,33 @@ use crate::transaction::Transaction; =20 use kernel::bindings::{rust_binder_transaction, task_struct}; -use kernel::ffi::{c_uint, c_ulong}; -use kernel::task::Task; +use kernel::error::Result; +use kernel::ffi::{c_int, c_uint, c_ulong}; +use kernel::task::{Pid, Task}; use kernel::tracepoint::declare_trace; =20 declare_trace! { unsafe fn binder_ioctl(cmd: c_uint, arg: c_ulong); + unsafe fn binder_ioctl_done(ret: c_int); + unsafe fn binder_read_done(ret: c_int); + unsafe fn binder_write_done(ret: c_int); + unsafe fn binder_wait_for_work(proc_work: bool, transaction_stack: boo= l, thread_todo: bool); unsafe fn binder_transaction(reply: bool, t: rust_binder_transaction, = thread: *mut task_struct); + unsafe fn binder_transaction_received(t: rust_binder_transaction); + unsafe fn binder_transaction_fd_send(t_debug_id: c_int, fd: c_int, off= set: usize); + unsafe fn binder_transaction_fd_recv(t_debug_id: c_int, fd: c_int, off= set: usize); + unsafe fn binder_alloc_lru_start(pid: c_int, page_index: usize); + unsafe fn binder_alloc_lru_end(pid: c_int, page_index: usize); + unsafe fn binder_free_lru_start(pid: c_int, page_index: usize); + unsafe fn binder_free_lru_end(pid: c_int, page_index: usize); + unsafe fn binder_alloc_page_start(pid: c_int, page_index: usize); + unsafe fn binder_alloc_page_end(pid: c_int, page_index: usize); + unsafe fn binder_unmap_user_start(pid: c_int, page_index: usize); + unsafe fn binder_unmap_user_end(pid: c_int, page_index: usize); + unsafe fn binder_unmap_kernel_start(pid: c_int, page_index: usize); + unsafe fn binder_unmap_kernel_end(pid: c_int, page_index: usize); + unsafe fn binder_command(cmd: u32); + unsafe fn binder_return(ret: u32); } =20 #[inline] @@ -19,12 +39,42 @@ fn raw_transaction(t: &Transaction) -> rust_binder_tran= saction { t as *const Transaction as rust_binder_transaction } =20 +#[inline] +fn to_errno(ret: Result) -> i32 { + match ret { + Ok(()) =3D> 0, + Err(err) =3D> err.to_errno(), + } +} + #[inline] pub(crate) fn trace_ioctl(cmd: u32, arg: usize) { // SAFETY: Always safe to call. unsafe { binder_ioctl(cmd, arg as c_ulong) } } =20 +#[inline] +pub(crate) fn trace_ioctl_done(ret: Result) { + // SAFETY: Always safe to call. + unsafe { binder_ioctl_done(to_errno(ret)) } +} +#[inline] +pub(crate) fn trace_read_done(ret: Result) { + // SAFETY: Always safe to call. + unsafe { binder_read_done(to_errno(ret)) } +} +#[inline] +pub(crate) fn trace_write_done(ret: Result) { + // SAFETY: Always safe to call. + unsafe { binder_write_done(to_errno(ret)) } +} + +#[inline] +pub(crate) fn trace_wait_for_work(proc_work: bool, transaction_stack: bool= , thread_todo: bool) { + // SAFETY: Always safe to call. + unsafe { binder_wait_for_work(proc_work, transaction_stack, thread_tod= o) } +} + #[inline] pub(crate) fn trace_transaction(reply: bool, t: &Transaction, thread: Opti= on<&Task>) { let thread =3D match thread { @@ -35,3 +85,58 @@ pub(crate) fn trace_transaction(reply: bool, t: &Transac= tion, thread: Option<&Ta // valid or null. unsafe { binder_transaction(reply, raw_transaction(t), thread) } } + +#[inline] +pub(crate) fn trace_transaction_received(t: &Transaction) { + // SAFETY: The raw transaction is valid for the duration of this call. + unsafe { binder_transaction_received(raw_transaction(t)) } +} + +#[inline] +pub(crate) fn trace_transaction_fd_send(t_debug_id: usize, fd: u32, offset= : usize) { + // SAFETY: This function is always safe to call. + unsafe { binder_transaction_fd_send(t_debug_id as c_int, fd as c_int, = offset) } +} +#[inline] +pub(crate) fn trace_transaction_fd_recv(t_debug_id: usize, fd: u32, offset= : usize) { + // SAFETY: This function is always safe to call. + unsafe { binder_transaction_fd_recv(t_debug_id as c_int, fd as c_int, = offset) } +} + +macro_rules! define_wrapper_lru_page_class { + ($($name:ident),* $(,)?) =3D> { + $( + kernel::macros::paste! { + #[inline] + pub(crate) fn [](pid: Pid, page_index: usize= ) { + // SAFETY: Always safe to call. + unsafe { [](pid as c_int, page_index) } + } + } + )* + }; +} + +define_wrapper_lru_page_class!( + alloc_lru_start, + alloc_lru_end, + free_lru_start, + free_lru_end, + alloc_page_start, + alloc_page_end, + unmap_user_start, + unmap_user_end, + unmap_kernel_start, + unmap_kernel_end, +); + +#[inline] +pub(crate) fn trace_command(cmd: u32) { + // SAFETY: This function is always safe to call. + unsafe { binder_command(cmd) } +} +#[inline] +pub(crate) fn trace_return(ret: u32) { + // SAFETY: This function is always safe to call. + unsafe { binder_return(ret) } +} --=20 2.52.0 From nobody Thu Apr 9 14:10:28 2026 Received: from outbound.pv.icloud.com (p-west1-cluster2-host8-snip4-6.eps.apple.com [57.103.64.207]) (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 B014323ABBF for ; Sun, 8 Mar 2026 01:26:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.64.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772933174; cv=none; b=Qcm5fAgtLjLOU+cJXMrWYsUlUlOZqTOFTxxq/YNpP/568GFfjynpJr3tzmKBGDBcUl/eQ+y3Wbo6xtagA7Pc35bIOPa0BYyXizf05k8jilk+ZimheCrg9WUJT8Aox5RS6QMH699SZFUeW2oXdt/9D2Q7ZBE7IlsGkSLgve9QfaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772933174; c=relaxed/simple; bh=1urO3W+tXQpxz7/cygxJHgwN7ArPo0nOtZjl1ZP95Z4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iZdNsAYDvpYKY6KRaoFHn9F2HCVc6kNNOolJBuQfffHsd+ADW9zdczUH45elWO+Cxsxwef0MuQKEdVQPf8bIHauVrHoXWkpi7/QyfvsvJZNwEx0+zgNUJ0UYq0ozKqBIpEsO7ZTv9b5lMTWufFQHQGMypBzmQbUvca5t1Loeqhs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sdhn.cc; spf=pass smtp.mailfrom=sdhn.cc; dkim=pass (2048-bit key) header.d=sdhn.cc header.i=@sdhn.cc header.b=SlKrFJhF; arc=none smtp.client-ip=57.103.64.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sdhn.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sdhn.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sdhn.cc header.i=@sdhn.cc header.b="SlKrFJhF" Received: from outbound.pv.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-1a-100-percent-15 (Postfix) with ESMTPS id 26BE718002D8; Sun, 8 Mar 2026 01:26:05 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sdhn.cc; s=sig1; t=1772933172; x=1775525172; bh=XdHlyaAEEcdA5hKeorywmqGd2sIe7DLH+uuYf9TpebA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:x-icloud-hme; b=SlKrFJhFFn7lnUcGhNdcphc01dTQVKvqD11/LmAPddtMVCWZY3pYcj0uP8I7QSYCVj7fiStyDeNuthiZnTnVCCu5YcBsPT9Z3g8NBOtEaFgCij3riyuyiGprLH0Wh+0O6HBG4Ryvz5yb7zzw5N2pprjTJN6cEmBsMNcneu6OB2g1Je/CXQGLxzQzIKWmgrnzsVLwPjSLx4O3U7m3zimk76NNJgAiKtiSPFuwW5G2XKliUvf/Ojji3fJVb9FcoD0j15Rhtq/XFXm6sRaFWUAaV8P69E+xJzsgrSL0QDCSwfesIl2Pnj6ezt3GuUDfvT95XxaDl0ORlVfaTL+pYiddNA== mail-alias-created-date: 1772007648188 Received: from [127.0.0.1] (unknown [17.56.9.36]) by p00-icloudmta-asmtp-us-west-1a-100-percent-15 (Postfix) with ESMTPSA id E798218000A4; Sun, 8 Mar 2026 01:26:00 +0000 (UTC) From: Mohamad Alsadhan Date: Sun, 08 Mar 2026 04:24:36 +0300 Subject: [PATCH v2 3/3] rust_binder: add in the new tracepoint calls 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260308-rust-binder-trace-v2-3-9e38637a2193@sdhn.cc> References: <20260308-rust-binder-trace-v2-0-9e38637a2193@sdhn.cc> In-Reply-To: <20260308-rust-binder-trace-v2-0-9e38637a2193@sdhn.cc> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: Alice Ryhl , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Mohamad Alsadhan X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=10445; i=mo@sdhn.cc; h=from:subject:message-id; bh=1urO3W+tXQpxz7/cygxJHgwN7ArPo0nOtZjl1ZP95Z4=; b=owGbwMvMwCV2WSbwWIGm61bG02pJDJlrLkg/XN1S8dnCxodnSqUHz0drtqZd9zUalX5sCd6oL n1BN/JTRykLgxgXg6yYIsvz895HD/64YXbm/N5TMHNYmUCGMHBxCsBE7Kcx/LPpYMmLKsr7/WO9 QO6F+gVcN2tqJF3SOc4y+fZ/FWy/s4DhNyunlrPAhq/lcUdS3DkNQmfnvVUMCj+0btNyhvcc5yq z2QE= X-Developer-Key: i=mo@sdhn.cc; a=openpgp; fpr=E7CF4BC5C1F8D836CCCFBDCAD31C51C6702945B5 X-Proofpoint-GUID: CpN1_YRrx-cTn2sf5QqXZSDzagSwSK58 X-Proofpoint-ORIG-GUID: CpN1_YRrx-cTn2sf5QqXZSDzagSwSK58 X-Authority-Info-Out: v=2.4 cv=TZObdBQh c=1 sm=1 tr=0 ts=69acd031 cx=c_apl:c_pps:t_out a=azHRBMxVc17uSn+fyuI/eg==:117 a=azHRBMxVc17uSn+fyuI/eg==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=zAWbjIijrVrU-cM0pgIA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA4MDAxMSBTYWx0ZWRfX4y4DYj/GxE45 T0y4mIKPrYBt4J/hkKPmSYwLguGIugrsGqfH7BKFe6b95B8ETs1eJ8yEjel70NLcDCOdEblpj+k ovdIkcyZRGOcx47vJKPm/WYvxHC8ixYJnZje3wS9O45QF0hISB5MoBTMNuZGu+dP4iIjwtQQuw3 gDnLzIILdXV6NSQYvoOQGtaskxkOhq614vYusY0qbkrW5bJQYwYidnQtjofJJLITVcxbbHQNer2 lpRUyjnK/aLyPkgaardnj6Pk/qpoI3U+9gXrZRUGMiYicc2y4JBvbGNzhgRaQL+c7/bkQkCIJJe RhxoLOVaThSuASkWptBr9319QJP4Hf2vANZp1kyL+kLQb4YifFnqtVGA10Iha8= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-07_08,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603080011 Wire the new Rust Binder tracepoints into live execution paths. Hook trace calls into: - ioctl entry/exit (`binder_ioctl`, `binder_ioctl_done`) - command parsing and return writes (`binder_command`, `binder_return`) - read/write completion (`binder_read_done`, `binder_write_done`) - wait (`binder_wait_for_work`) - transaction (`binder_transaction_received`) - fd translation (`binder_transaction_fd_{send,recv}`) - buffer/page lifecycle (`binder_alloc_*`, `binder_free_*`, `binder_unmap_*`) Signed-off-by: Mohamad Alsadhan Suggested-by: Alice Ryhl --- drivers/android/binder/allocation.rs | 1 + drivers/android/binder/page_range.rs | 17 +++++++++++++++++ drivers/android/binder/process.rs | 7 +++++-- drivers/android/binder/rust_binder_main.rs | 1 + drivers/android/binder/thread.rs | 15 +++++++++++++-- drivers/android/binder/transaction.rs | 2 ++ 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/android/binder/allocation.rs b/drivers/android/binder/= allocation.rs index 7f65a9c3a..8c0f94463 100644 --- a/drivers/android/binder/allocation.rs +++ b/drivers/android/binder/allocation.rs @@ -208,6 +208,7 @@ pub(crate) fn translate_fds(&mut self) -> Result { let res =3D FileDescriptorReservation::get_unused_fd_flags(bin= dings::O_CLOEXEC)?; let fd =3D res.reserved_fd(); self.write::(file_info.buffer_offset, &fd)?; + crate::trace::trace_transaction_fd_recv(self.debug_id, fd, fil= e_info.buffer_offset); =20 reservations.push( Reservation { diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/= page_range.rs index fdd97112e..43fe23907 100644 --- a/drivers/android/binder/page_range.rs +++ b/drivers/android/binder/page_range.rs @@ -327,6 +327,8 @@ pub(crate) fn use_range(&self, start: usize, end: usize= ) -> Result<()> { =20 // SAFETY: The pointer is valid, and we hold the lock so readi= ng from the page is okay. if let Some(page) =3D unsafe { PageInfo::get_page(page_info) }= { + crate::trace::trace_alloc_lru_start(self.pid, i); + // Since we're going to use the page, we should remove it = from the lru list so that // the shrinker will not free it. // @@ -335,9 +337,12 @@ pub(crate) fn use_range(&self, start: usize, end: usiz= e) -> Result<()> { // The shrinker can't free the page between the check and = this call to // `list_lru_del` because we hold the lock. unsafe { PageInfo::list_lru_del(page_info, page.nid(), sel= f.shrinker) }; + + crate::trace::trace_alloc_lru_end(self.pid, i); } else { // We have to allocate a new page. Use the slow path. drop(inner); + crate::trace::trace_alloc_page_start(self.pid, i); // SAFETY: `i < end <=3D inner.size` so `i` is in bounds. match unsafe { self.use_page_slow(i) } { Ok(()) =3D> {} @@ -346,6 +351,7 @@ pub(crate) fn use_range(&self, start: usize, end: usize= ) -> Result<()> { return Err(err); } } + crate::trace::trace_alloc_page_end(self.pid, i); inner =3D self.lock.lock(); } } @@ -448,8 +454,12 @@ pub(crate) fn stop_using_range(&self, start: usize, en= d: usize) { =20 // SAFETY: Okay for reading since we have the lock. if let Some(page) =3D unsafe { PageInfo::get_page(page_info) }= { + crate::trace::trace_free_lru_start(self.pid, i); + // SAFETY: The pointer is valid, and it's the right shrink= er. unsafe { PageInfo::list_lru_add(page_info, page.nid(), sel= f.shrinker) }; + + crate::trace::trace_free_lru_end(self.pid, i); } } } @@ -667,6 +677,7 @@ fn drop(self: Pin<&mut Self>) { let mmap_read; let mm_mutex; let vma_addr; + let pid; =20 { // CAST: The `list_head` field is first in `PageInfo`. @@ -700,7 +711,9 @@ fn drop(self: Pin<&mut Self>) { =20 // SAFETY: Both pointers are in bounds of the same allocation. page_index =3D unsafe { info.offset_from(inner.pages) } as usize; + pid =3D range.pid; =20 + crate::trace::trace_unmap_kernel_start(pid, page_index); // SAFETY: We hold the spinlock, so we can take the page. // // This sets the page pointer to zero before we unmap it from the = vma. However, we call @@ -709,6 +722,8 @@ fn drop(self: Pin<&mut Self>) { page =3D unsafe { PageInfo::take_page(info) }; vma_addr =3D inner.vma_addr; =20 + crate::trace::trace_unmap_kernel_end(pid, page_index); + // From this point on, we don't access this PageInfo or Shrinkable= PageRange again, because // they can be freed at any point after we unlock `lru_lock`. This= is with the exception of // `mm_mutex` which is kept alive by holding the lock. @@ -719,7 +734,9 @@ fn drop(self: Pin<&mut Self>) { =20 if let Some(vma) =3D mmap_read.vma_lookup(vma_addr) { let user_page_addr =3D vma_addr + (page_index << PAGE_SHIFT); + crate::trace::trace_unmap_user_start(pid, page_index); vma.zap_page_range_single(user_page_addr, PAGE_SIZE); + crate::trace::trace_unmap_user_end(pid, page_index); } =20 drop(mmap_read); diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/pro= cess.rs index 41de55931..4d7b165e7 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -1656,11 +1656,14 @@ pub(crate) fn ioctl(this: ArcBorrow<'_, Process>, f= ile: &File, cmd: u32, arg: us =20 const _IOC_READ_WRITE: u32 =3D _IOC_READ | _IOC_WRITE; =20 - match _IOC_DIR(cmd) { + let res =3D match _IOC_DIR(cmd) { _IOC_WRITE =3D> Self::ioctl_write_only(this, file, cmd, &mut u= ser_slice.reader()), _IOC_READ_WRITE =3D> Self::ioctl_write_read(this, file, cmd, u= ser_slice), _ =3D> Err(EINVAL), - } + }; + + crate::trace::trace_ioctl_done(res); + res } =20 pub(crate) fn mmap( diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/b= inder/rust_binder_main.rs index aa5f2a75a..1028e0a8a 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -116,6 +116,7 @@ fn new(writer: UserSliceWriter, thread: &'a Thread) -> = Self { /// Write a return code back to user space. /// Should be a `BR_` constant from [`defs`] e.g. [`defs::BR_TRANSACTI= ON_COMPLETE`]. fn write_code(&mut self, code: u32) -> Result { + crate::trace::trace_return(code); stats::GLOBAL_STATS.inc_br(code); self.thread.process.stats.inc_br(code); self.writer.write(&code) diff --git a/drivers/android/binder/thread.rs b/drivers/android/binder/thre= ad.rs index 0b62d24b2..ef7fba700 100644 --- a/drivers/android/binder/thread.rs +++ b/drivers/android/binder/thread.rs @@ -706,6 +706,7 @@ fn translate_object( core::mem::offset_of!(uapi::binder_fd_object, __bindge= n_anon_1.fd); =20 let field_offset =3D offset + FD_FIELD_OFFSET; + crate::trace::trace_transaction_fd_send(view.alloc.debug_i= d, fd, field_offset); =20 view.alloc.info_add_fd(file, field_offset, false)?; } @@ -1323,6 +1324,7 @@ fn write(self: &Arc, req: &mut BinderWriteRead)= -> Result { while reader.len() >=3D size_of::() && self.inner.lock().retu= rn_work.is_unused() { let before =3D reader.len(); let cmd =3D reader.read::()?; + crate::trace::trace_command(cmd); GLOBAL_STATS.inc_bc(cmd); self.process.stats.inc_bc(cmd); match cmd { @@ -1412,11 +1414,18 @@ fn read(self: &Arc, req: &mut BinderWriteRead= , wait: bool) -> Result { UserSlice::new(UserPtr::from_addr(read_start as _), read_len a= s _).writer(), self, ); - let (in_pool, use_proc_queue) =3D { + let (in_pool, has_transaction, thread_todo, use_proc_queue) =3D { let inner =3D self.inner.lock(); - (inner.is_looper(), inner.should_use_process_work_queue()) + ( + inner.is_looper(), + inner.current_transaction.is_some(), + !inner.work_list.is_empty(), + inner.should_use_process_work_queue(), + ) }; =20 + crate::trace::trace_wait_for_work(use_proc_queue, has_transaction,= thread_todo); + let getter =3D if use_proc_queue { Self::get_work } else { @@ -1482,6 +1491,7 @@ pub(crate) fn write_read(self: &Arc, data: User= Slice, wait: bool) -> Resul let mut ret =3D Ok(()); if req.write_size > 0 { ret =3D self.write(&mut req); + crate::trace::trace_write_done(ret); if let Err(err) =3D ret { pr_warn!( "Write failure {:?} in pid:{}", @@ -1498,6 +1508,7 @@ pub(crate) fn write_read(self: &Arc, data: User= Slice, wait: bool) -> Resul // Go through the work queue. if req.read_size > 0 { ret =3D self.read(&mut req, wait); + crate::trace::trace_read_done(ret); if ret.is_err() && ret !=3D Err(EINTR) { pr_warn!( "Read failure {:?} in pid:{}", diff --git a/drivers/android/binder/transaction.rs b/drivers/android/binder= /transaction.rs index 75e6f5fba..c43846bb7 100644 --- a/drivers/android/binder/transaction.rs +++ b/drivers/android/binder/transaction.rs @@ -430,6 +430,8 @@ fn do_work( =20 self.drop_outstanding_txn(); =20 + crate::trace::trace_transaction_received(&self); + // When this is not a reply and not a oneway transaction, update `= current_transaction`. If // it's a reply, `current_transaction` has already been updated ap= propriately. if self.target_node.is_some() && tr_sec.transaction_data.flags & T= F_ONE_WAY =3D=3D 0 { --=20 2.52.0