From: "Gary Guo" <gary@garyguo.net>
To: "Alice Ryhl" <aliceryhl@google.com>, "Gary Guo" <gary@garyguo.net>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Boqun Feng" <boqun@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Benno Lossin" <lossin@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>, "Lyude Paul" <lyude@redhat.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Waiman Long" <longman@redhat.com>,
"Will Deacon" <will@kernel.org>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 2/5] rust: sync: add const constructor for raw_spinlock_t
Date: Tue, 07 Jul 2026 14:33:26 +0100 [thread overview]
Message-ID: <DJSDLLJAHFQC.3S56X1Q9MU2T2@garyguo.net> (raw)
In-Reply-To: <akz8g-zAeNuvBiF3@google.com>
On Tue Jul 7, 2026 at 2:17 PM BST, Alice Ryhl wrote:
> On Wed, Jul 01, 2026 at 05:15:55PM +0100, Gary Guo wrote:
>> On Tue Jun 23, 2026 at 4:38 PM BST, Alice Ryhl wrote:
>> > The abstractions for pr_*_ratelimited! need to construct a global
>> > `struct ratelimit_state`, which contains a `raw_spinlock_t` field. Thus,
>> > add a const constructor for the `raw_spinlock_t` type.
>> >
>> > The SPINLOCK_OWNER_INIT constant isn't mirrored via a const helper
>> > because bindgen generates a 'static mut' instead of a constant from the
>> > pointer constant.,
>> >
>> > The __ARCH_SPIN_LOCK_UNLOCKED constant cannot be translated by bindgen
>> > because it's a define for a struct without type annotations, so it's
>> > explicitly declared in Rust.
>> >
>> > Signed-off-by: Alice Ryhl <aliceryhl@google.com>
>
>> > +/// Helper for creating a raw unlocked `bindings::raw_spinlock_t`.
>> > +///
>> > +/// For use in statics containing raw spinlocks.
>> > +pub const fn raw_spin_lock_unlocked(name: &'static CStr) -> bindings::raw_spinlock_t {
>>
>> These functions (incl. raw_lockdep_map) should really be private functions.
>
> Hmm, I think there could be cases where a driver needs to interact with
> C code directly where this is useful. Even if use from drivers is
> discouraged, I don't think we need to go out of our way to prevent it.
> It's like the bindings crate.
I think a theoretical use case is not a justification for exporting such
low-level functions. If such need arises, we can export them by then.
Best,
Gary
next prev parent reply other threads:[~2026-07-07 13:33 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 15:38 [PATCH 0/5] Rate limited printing for Rust Alice Ryhl
2026-06-23 15:38 ` [PATCH 1/5] rust: sync: move lockdep types to rust/kernel/sync/lockdep.rs Alice Ryhl
2026-06-26 20:26 ` Carlos Llamas
2026-06-30 3:20 ` Boqun Feng
2026-07-01 16:10 ` Gary Guo
2026-06-23 15:38 ` [PATCH 2/5] rust: sync: add const constructor for raw_spinlock_t Alice Ryhl
2026-06-26 20:52 ` Carlos Llamas
2026-07-07 13:12 ` Alice Ryhl
2026-06-30 3:44 ` Boqun Feng
2026-07-07 13:13 ` Alice Ryhl
2026-07-01 16:15 ` Gary Guo
2026-07-07 13:17 ` Alice Ryhl
2026-07-07 13:33 ` Gary Guo [this message]
2026-07-07 13:52 ` Alice Ryhl
2026-06-23 15:38 ` [PATCH 3/5] rust: add pr_*_ratelimit! macros for printing Alice Ryhl
2026-06-23 15:55 ` Gary Guo
2026-06-23 19:11 ` Alice Ryhl
2026-06-23 19:53 ` Miguel Ojeda
2026-06-23 20:06 ` Gary Guo
2026-06-23 19:31 ` Miguel Ojeda
2026-06-23 20:05 ` Alice Ryhl
2026-06-26 23:12 ` Carlos Llamas
2026-07-01 16:20 ` Gary Guo
2026-07-01 17:02 ` Alice Ryhl
2026-07-01 17:14 ` Gary Guo
2026-07-02 7:50 ` Alice Ryhl
2026-07-02 6:15 ` Alvin Sun
2026-07-07 13:13 ` Alice Ryhl
2026-06-23 15:38 ` [PATCH 4/5] rust_binder: consolidate transaction failure prints Alice Ryhl
2026-06-26 23:28 ` Carlos Llamas
2026-07-07 13:18 ` Alice Ryhl
2026-06-23 15:38 ` [PATCH 5/5] rust_binder: use pr_*_ratelimited! for printing Alice Ryhl
2026-06-26 23:34 ` Carlos Llamas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DJSDLLJAHFQC.3S56X1Q9MU2T2@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=mingo@redhat.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=will@kernel.org \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox