[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yurhktr8WEpn2k9h@boqun-archlinux>
Date: Wed, 3 Aug 2022 13:58:58 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
Jarkko Sakkinen <jarkko@...nel.org>,
Wedson Almeida Filho <wedsonaf@...gle.com>,
Alex Gaynor <alex.gaynor@...il.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
Waiman Long <longman@...hat.com>
Subject: Re: [PATCH v8 07/31] locking/spinlock: introduce `__spin_lock_init`
On Tue, Aug 02, 2022 at 03:49:54AM +0200, Miguel Ojeda wrote:
> From: Wedson Almeida Filho <wedsonaf@...gle.com>
>
> A Rust helper (introduced in a later patch) needs to call
> `spin_lock_init` with a passed key, rather than define
> one in place.
>
> In order to do that, this changes the `spin_lock_init` macro
> to call a new `__spin_lock_init` function which takes the key
> as an extra parameter.
>
> Co-developed-by: Alex Gaynor <alex.gaynor@...il.com>
> Signed-off-by: Alex Gaynor <alex.gaynor@...il.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf@...gle.com>
> Co-developed-by: Miguel Ojeda <ojeda@...nel.org>
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>
Acked-by: Boqun Feng <boqun.feng@...il.com>
Peter, Will & Waiman, could you take a look at this patch and patch #8?
These two are needed because currently there is no way to convert a C
macro to a Rust macro, a C macro can be called as a function on Rust
side, but that's not quite for generating a static key of lockdep. As
a result, __spin_lock_init() needs to be exposed.
I think these are tiny and harmless, but looking forwards to your
insight ;-)
Regards,
Boqun
> ---
> include/linux/spinlock.h | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> index 5c0c5174155d..ad1c91884ed8 100644
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -326,12 +326,17 @@ static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
>
> #ifdef CONFIG_DEBUG_SPINLOCK
>
> +static inline void __spin_lock_init(spinlock_t *lock, const char *name,
> + struct lock_class_key *key)
> +{
> + __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
> +}
> +
> # define spin_lock_init(lock) \
> do { \
> static struct lock_class_key __key; \
> \
> - __raw_spin_lock_init(spinlock_check(lock), \
> - #lock, &__key, LD_WAIT_CONFIG); \
> + __spin_lock_init(lock, #lock, &__key); \
> } while (0)
>
> #else
> --
> 2.37.1
>
>
Powered by blists - more mailing lists