From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 5CAB93CBE97 for ; Fri, 10 Jul 2026 22:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783721563; cv=none; b=Io7cIsi7MIvabwdMGVw0w5A7cST2aELtkDyfX/U8a+jHM0bOGAAeeKEfmkIOPqn2BHSNYswGGOiYuta6QE5FcohXY/pRVh/f7K7YDgMkaSFQvY6SQaWKXaBTUwpnu8DSPAJS+oEVivB2BMtVfvxM/gurRPsC9XYcJvM0doy9zdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783721563; c=relaxed/simple; bh=tmhfjL+7A+jarJnPQhyIwqYjI/s0zpjORzM9eSIVCtw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Par274OKxH8TSxwDTjjPmABu5a7AbxN3KNdMQuhi9IrZQLp73MIAx6B33yC3ggcYxDMHuOtDCfz5T/oIttRyMu93k7lW8W0OMV3gAhWEJL/YF7NrJsN2+W2GDz0hmxLpRg4PMDIfid2X6FhbNp6mEwNl/QKE8Kx2ZRpne2nABrc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ErcF2Wj3; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ErcF2Wj3" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2cb59f6ba26so35665ad.0 for ; Fri, 10 Jul 2026 15:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783721562; x=1784326362; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Vrj/KNeeXRo3F4qSEnUw4GznCEEs9Z+LOPo84ArtpU8=; b=ErcF2Wj3AoCk+mpzarjA4PCkWkn/dwXPVXPbjd9YVO74Vz5we/Qfb41Ab9xr4Qt0JF pCyVc8Bvr0Z4/Txp7JiCCUkswpd+VQg9ZhecIs5cVlVzE+Fl/DBcA8Q0ai06w6TkCLnK Dwc0bzDlhd15+xOP6PzooPAka2vyU1SBjgKWhETfQQCeH6fnQXuXaKjOsnwrLnureJ+2 yQbKhaKlgGdUDsNP8cYqBcGnrPTIxjDkUiK/ebQwipnl03XLqYHlKWAjcb0RnMcn9r39 lmQSC/l/tdQZvvbemxGMGh6yfST/LayHjsM1+Y4g1KkviHu4E9PgqZViayLU0pyQU1ac Nspg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783721562; x=1784326362; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Vrj/KNeeXRo3F4qSEnUw4GznCEEs9Z+LOPo84ArtpU8=; b=B/6c2RccXthmgDNhW3vfDEkN30QiVkicA2BvWTSvaujzcA1RqEhkP0dcnBDRzB/BEN FXCpanI3fzVUaJ6qWZSUSl/xAbORg4wu1K62rXvneqCj90k6RKipgcR4MT15WssCJBQI LtYkBugCe2tDw5p76CHk/qgpT6zwa8CVexA8veGE1FUK4pXafwNjBWK6hZ8ngiToxrYA HZIJ8BDAC0xCmSPbBsK/9EVcQO6nuExYMM9KAl8mCkUvH/DRGOOpUNuSWyQ2I+HJrsYf GO2oKl7/CWT392t0Lu6G4FGULCiXIeOxC2zhLs7GzsPbBGAb8Apnybdk/cwjdl4CXKgq IDBg== X-Forwarded-Encrypted: i=1; AHgh+Rq3XYL4P01xuMg2nPSNzES3Fu5dKO5mwVF2WuN7cZUnNpnaKP8YU1Pm5fDvo74WJkX5GNVSBqET7Bni2T8=@vger.kernel.org X-Gm-Message-State: AOJu0YzRbzf8Hy4+PH40eE55wZUtXqeb/fKueu9qo5rhXkoInXTHWpmg FcGe4sOGqEkBgHTIWmtx4EU1KKZBAnKH/4lK7gs3mql7Gh1vnyRfcPdcbjsyWzzjXw== X-Gm-Gg: AfdE7cltYLB3j3arypls+6uhc4O1PkCJQNKZncnYIPrmR3rA6xo52c7q6p5mYyhJXNB zERHU6bDcLc55K5L14gNdV4NT1iBJdl3S5ytteJByFR09enpFxmqU3tmlCROkgEYv6xF+mHdexW qczKFBE+E1nR432dZG4oMTzHdAMZSwozd2TFTgI6f+/SEfwsuov8VUm++h1xBmm+outORMPR/Qv y9X9qMbrObuXFx4FZtUewclr4525V03Yz1+3PFnFX6BXtnhGrs37oO/lMFfmeOKKOhZSLQW9LIr YbR07H/IZcpE6wBOzu58QTcPhnlWEQgNUM0DEaoeFbzNQr1/4o/RonfT18u8LPP/f8upTlTvBmj MultG8wP7p9DQfsVfL8OnMGZ46n14tDBtXOCPISv/mYKV3Xhz/6oEXIuWBk1T+Dv1UXVEkVQVeb R1201Dx4t1k1Xa4GN+pYvcUU5uzMGxqPkjqbME1mz7XvZvDmV65JJZaQQnnpSQXvSwJF7VQvBke pHA2BMXZMOsFI4xbzmK7FC+4PFDSaUkzpCv X-Received: by 2002:a17:903:2301:b0:2ca:ed25:9c2f with SMTP id d9443c01a7336-2ce9f292e51mr1293035ad.16.1783721561213; Fri, 10 Jul 2026 15:12:41 -0700 (PDT) Received: from google.com (112.174.16.34.bc.googleusercontent.com. [34.16.174.112]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38a5574ca88sm3281168a91.7.2026.07.10.15.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 15:12:40 -0700 (PDT) Date: Fri, 10 Jul 2026 22:12:35 +0000 From: Carlos Llamas To: Gary Guo Cc: jahnavimn@google.com, Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Christian Brauner , Alice Ryhl , Miguel Ojeda , Boqun Feng , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?iso-8859-1?Q?=D6zkan?= , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH v2 1/7] rust_binder: Add dynamic debug logging mask Message-ID: References: <20260710-rust_binder_debug_mask-v2-0-2846410e3ae6@google.com> <20260710-rust_binder_debug_mask-v2-1-2846410e3ae6@google.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: On Fri, Jul 10, 2026 at 09:27:37PM +0100, Gary Guo wrote: > On Fri Jul 10, 2026 at 8:47 PM BST, Carlos Llamas wrote: > > On Fri, Jul 10, 2026 at 02:32:52PM +0000, Jahnavi MN via B4 Relay wrote: > >> From: Jahnavi MN > >> > >> Implement a dynamic debug logging mask (`debug_mask`) for the > >> `rust_binder` module to allow dynamic runtime configuration of log > >> levels. This enables parity with the legacy C driver's debug mask. > >> > >> Since the Rust `module!` macro in the current kernel build does not yet > >> support declaring module parameters directly in Rust, we define the > >> `debug_mask` variable in a C companion file to expose it to the kernel > >> runtime and import it using FFI with volatile reads. > >> > >> To verify the setup, instrument process lifecycle events (open, flush, > >> and release) in `process.rs` under the new `BINDER_DEBUG_OPEN_CLOSE` > >> logging mask. These entry-point events are chosen for initial validation > >> because they represent the start of the Binder lifecycle and occur > >> at low frequency, allowing simple runtime verification of the dynamic > >> toggle without log noise. > >> > >> Signed-off-by: Jahnavi MN > >> --- > >> drivers/android/binder/debug.rs | 80 ++++++++++++++++++++++++++++++ > >> drivers/android/binder/process.rs | 7 ++- > >> drivers/android/binder/rust_binder_main.rs | 2 + > >> drivers/android/binder/rust_binderfs.c | 3 ++ > >> rust/kernel/task.rs | 7 +++ > >> 5 files changed, 98 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/android/binder/debug.rs b/drivers/android/binder/debug.rs > >> new file mode 100644 > >> index 000000000000..da48bce3df54 > >> --- /dev/null > >> +++ b/drivers/android/binder/debug.rs > >> @@ -0,0 +1,80 @@ > >> +// SPDX-License-Identifier: GPL-2.0 > >> +// Copyright (C) 2026 Google LLC. > >> + > >> +//! Binder debugging helpers. > >> + > >> +#![allow(dead_code)] > >> + > >> +kernel::impl_flags!( > >> + /// Represents multiple debug mask flags. > >> + #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)] > >> + pub struct DebugMasks(u32); > > > > Where is this being used? I can't find it on subsequent patches. > > Maybe leftover from previous implementation? > > impl_flags macro requires a type for a single flag and a type for flag masks. Oh I see. I was expecting the bitops to be peformed on this type somewhere. I guess the reason it wasn't is because of the issue with module parameters and their C macros. > > > > >> + > >> + /// Represents a single debug mask category. > >> + #[derive(Debug, Clone, Copy, PartialEq, Eq)] > >> + pub enum DebugMask { > >> + UserError = 1 << 0, > >> + FailedTransaction = 1 << 1, > >> + DeadTransaction = 1 << 2, > >> + OpenClose = 1 << 3, > >> + DeadBinder = 1 << 4, > >> + DeathNotification = 1 << 5, > >> + ReadWrite = 1 << 6, > >> + UserRefs = 1 << 7, > >> + Threads = 1 << 8, > >> + Transaction = 1 << 9, > >> + TransactionComplete = 1 << 10, > >> + FreeBuffer = 1 << 11, > >> + InternalRefs = 1 << 12, > >> + PriorityCap = 1 << 13, > >> + Spinlocks = 1 << 14, > >> + } > >> +); > >> diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/binder/rust_binder_main.rs > >> index df47aba05133..995e6131bb77 100644 > >> --- a/drivers/android/binder/rust_binder_main.rs > >> +++ b/drivers/android/binder/rust_binder_main.rs > >> @@ -31,6 +31,8 @@ > >> mod context; > >> mod deferred_close; > >> mod defs; > >> +#[macro_use] > >> +mod debug; > >> mod error; > >> mod netlink; > >> mod node; > >> diff --git a/drivers/android/binder/rust_binderfs.c b/drivers/android/binder/rust_binderfs.c > >> index ade1c4d92499..fa8b38465550 100644 > >> --- a/drivers/android/binder/rust_binderfs.c > >> +++ b/drivers/android/binder/rust_binderfs.c > >> @@ -51,6 +51,9 @@ DEFINE_SHOW_ATTRIBUTE(rust_binder_proc); > >> char *rust_binder_devices_param = CONFIG_ANDROID_BINDER_DEVICES; > >> module_param_named(rust_devices, rust_binder_devices_param, charp, 0444); > >> > >> +u32 rust_binder_debug_mask = 7; > > > > hmm, I'm not sure about this magic number. Do you think we can > > initialize on the rust end at init()? Or at least a comment about what > > flags we are setting as default here? > > It doesn't even need that, just a > > static rust_binder_debug_mask: Atomic = Atomic::new((FLAG_A as u32) | (FLAG_B as u32) | ...); > > and a `extern u32` on C side should do. ha sure, reversing the declaration and extern would also work.