[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eea05d26-653e-9cf7-57ce-c5f725e8d6d1@gmail.com>
Date: Fri, 14 Jul 2023 11:57:58 -0300
From: Martin Rodriguez Reboredo <yakoyoku@...il.com>
To: Asahi Lina <lina@...hilina.net>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Masahiro Yamada <masahiroy@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nicolas Schier <nicolas@...sle.eu>, Tom Rix <trix@...hat.com>,
Daniel Vetter <daniel@...ll.ch>
Cc: Hector Martin <marcan@...can.st>, Sven Peter <sven@...npeter.dev>,
Alyssa Rosenzweig <alyssa@...enzweig.io>,
asahi@...ts.linux.dev, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH RFC 05/11] rust: sync: Add dummy LockClassKey
implementation for !CONFIG_LOCKDEP
On 7/14/23 06:13, Asahi Lina wrote:
> Lock classes aren't used without lockdep. The C side declares the key
> as an empty struct in that case, but let's make it an explicit ZST in
> Rust, implemented in a separate module. This allows us to more easily
> guarantee that the lockdep code will be trivially optimized out without
> CONFIG_LOCKDEP, including LockClassKey arguments that are passed around.
>
> Depending on whether CONFIG_LOCKDEP is enabled or not, we then import
> the real lockdep implementation or the dummy one.
>
> Signed-off-by: Asahi Lina <lina@...hilina.net>
> ---
> rust/kernel/sync.rs | 29 ++++++++---------------------
> rust/kernel/sync/lockdep.rs | 27 +++++++++++++++++++++++++++
> rust/kernel/sync/no_lockdep.rs | 19 +++++++++++++++++++
> 3 files changed, 54 insertions(+), 21 deletions(-)
>
> diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
> index d219ee518eff..352472c6b77a 100644
> --- a/rust/kernel/sync.rs
> +++ b/rust/kernel/sync.rs
> @@ -5,37 +5,24 @@
> //! This module contains the kernel APIs related to synchronisation that have been ported or
> //! wrapped for usage by Rust code in the kernel.
>
> -use crate::types::Opaque;
> -
> mod arc;
> mod condvar;
> pub mod lock;
> mod locked_by;
>
> +#[cfg(CONFIG_LOCKDEP)]
> +mod lockdep;
> +#[cfg(not(CONFIG_LOCKDEP))]
> +mod no_lockdep;
Some care must be taken wrt how is it going to appear in the resulting
documentation, I think it can lead to missing details. `#[cfg(doc)]`
should be considered.
> +#[cfg(not(CONFIG_LOCKDEP))]
> +use no_lockdep as lockdep;
> [...]
Powered by blists - more mailing lists