[PATCH v2 0/5] Rate limited printing for Rust

From: Alice Ryhl

Date: Thu Jul 16 2026 - 08:35:10 EST


To avoid DoS on the kernel log, the Rust Binder driver is being switched
to rate limited printing. But before we can do that, we must first
implement rate limited printing for Rust. Thus, do that.

However, it turns out that before we can implement rate limited
printing, we must first implement the ability declare a raw_spinlock_t
in a global variable. Thus, do that too.

Based on top of:
https://lore.kernel.org/rust-for-linux/20260716-rust_binder_debug_mask-v4-0-3d7436c2d2f2@xxxxxxxxxx/
https://lore.kernel.org/rust-for-linux/20260707-binder-netlink-v7-0-42b40e4b1ac8@xxxxxxxxxx/

Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
Changes in v2:
- Rebase on top of binder_debug! patch series.
- As a consequence, the logic for printing the size of transaction
failures is changed to print the size of each piece of the
transaction, rather than the total buffer size.
- Add doc aliases for raw_spin_lock_unlocked.
- Make raw_spin_lock_unlocked and raw_lockdep_map private.
- Add Ratelimit::new_static.
- Add some missing links to docs.
- Link to v1: https://lore.kernel.org/r/20260623-pr-ratelimited-v1-0-cc922f544dc0@xxxxxxxxxx

---
Alice Ryhl (5):
rust: sync: move lockdep types to rust/kernel/sync/lockdep.rs
rust: sync: add const constructor for raw_spinlock_t
rust: add pr_*_ratelimit! macros for printing
rust_binder: consolidate transaction failure prints
rust_binder: use pr_*_ratelimited! for printing

drivers/android/binder/allocation.rs | 4 +-
drivers/android/binder/context.rs | 6 +-
drivers/android/binder/debug.rs | 4 +-
drivers/android/binder/error.rs | 4 -
drivers/android/binder/freeze.rs | 2 +-
drivers/android/binder/node.rs | 4 +-
drivers/android/binder/page_range.rs | 12 +-
drivers/android/binder/process.rs | 22 ++--
drivers/android/binder/thread.rs | 103 ++++++++--------
drivers/android/binder/transaction.rs | 24 +---
include/linux/spinlock_types_raw.h | 4 +
rust/bindings/lib.rs | 24 ++++
rust/helpers/helpers.c | 1 +
rust/helpers/ratelimit.c | 14 +++
rust/kernel/error.rs | 2 +-
rust/kernel/lib.rs | 1 +
rust/kernel/prelude.rs | 8 ++
rust/kernel/ratelimit.rs | 215 ++++++++++++++++++++++++++++++++++
rust/kernel/sync.rs | 135 +--------------------
rust/kernel/sync/lock/spinlock.rs | 30 +++++
rust/kernel/sync/lockdep.rs | 161 +++++++++++++++++++++++++
21 files changed, 543 insertions(+), 237 deletions(-)
---
base-commit: 542dc312f569ba52c71eb744db176ee44546f893
change-id: 20260619-pr-ratelimited-6e20fa89bd5b

Best regards,
--
Alice Ryhl <aliceryhl@xxxxxxxxxx>