Re: [PATCH 3/5] rust: add pr_*_ratelimit! macros for printing

From: Alice Ryhl

Date: Tue Jul 07 2026 - 09:19:39 EST


On Thu, Jul 02, 2026 at 02:15:35PM +0800, Alvin Sun wrote:
>
> On 6/23/26 23:38, Alice Ryhl wrote:
> > Printing can be very expensive if it occurs often, so printing that can
> > be triggered by userspace should be rate limited. For this purpose, add
> > a Rust wrapper around `struct ratelimit_state` and use it in the new
> > macros.
> >
> > Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
>
> Tested-by: Alvin Sun <alvin.sun@xxxxxxxxx>
>
> The binder-related patches couldn't be applied to the mainline
> repository. I wrote a simple misc device to test pr_warn_ratelimited:
>
> [   80.655483] misc misc_test: Opening Rust Misc Test Device
> [   80.655546] Rust: 1990 callbacks suppressed
> [   80.656102] rust_misc_test: pr_warn_ratelimited triggered (0) from
> /dev/misc_test
> [   80.656137] rust_misc_test: pr_warn_ratelimited triggered (1) from
> /dev/misc_test

Thanks!

Alice