From: Andreas Hindborg <nmi@metaspace.dk>
To: Jens Axboe <axboe@kernel.dk>, Miguel Ojeda <ojeda@kernel.org>,
Alex Gaynor <alex.gaynor@gmail.com>,
Wedson Almeida Filho <wedsonaf@gmail.com>
Cc: "Andreas Hindborg" <a.hindborg@samsung.com>,
"Behme Dirk (XC-CP/ESB5)" <Dirk.Behme@de.bosch.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Alice Ryhl" <aliceryhl@google.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] rust: block: fix wrong usage of lockdep API
Date: Thu, 15 Aug 2024 07:49:43 +0000 [thread overview]
Message-ID: <20240815074519.2684107-3-nmi@metaspace.dk> (raw)
In-Reply-To: <20240815074519.2684107-1-nmi@metaspace.dk>
From: Andreas Hindborg <a.hindborg@samsung.com>
When allocating `struct gendisk`, `GenDiskBuilder` is using a dynamic lock
class key without registering the key. This is incorrect use of the API,
which causes a `WARN` trace. This patch fixes the issue by using a static
lock class key, which is more appropriate for the situation anyway.
Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")
Reported-by: "Behme Dirk (XC-CP/ESB5)" <Dirk.Behme@de.bosch.com>
Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/6.2E11.2E0-rc1.3A.20rust.2Fkernel.2Fblock.2Fmq.2Ers.3A.20doctest.20lock.20warning
Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com>
---
rust/kernel/block/mq/gen_disk.rs | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index f548a6199847..dbe560b09953 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -6,7 +6,7 @@
//! C header: [`include/linux/blk_mq.h`](srctree/include/linux/blk_mq.h)
use crate::block::mq::{raw_writer::RawWriter, Operations, TagSet};
-use crate::error;
+use crate::{error, static_lock_class};
use crate::{bindings, error::from_err_ptr, error::Result, sync::Arc};
use core::fmt::{self, Write};
@@ -93,8 +93,6 @@ pub fn build<T: Operations>(
name: fmt::Arguments<'_>,
tagset: Arc<TagSet<T>>,
) -> Result<GenDisk<T>> {
- let lock_class_key = crate::sync::LockClassKey::new();
-
// SAFETY: `bindings::queue_limits` contain only fields that are valid when zeroed.
let mut lim: bindings::queue_limits = unsafe { core::mem::zeroed() };
@@ -110,7 +108,7 @@ pub fn build<T: Operations>(
tagset.raw_tag_set(),
&mut lim,
core::ptr::null_mut(),
- lock_class_key.as_ptr(),
+ static_lock_class!().as_ptr(),
)
})?;
--
2.46.0
next prev parent reply other threads:[~2024-08-15 7:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 7:49 [PATCH 0/2] rust: fix erranous use of lock class key in rust block device bindings Andreas Hindborg
2024-08-15 7:49 ` Andreas Hindborg [this message]
2024-08-15 8:04 ` [PATCH 2/2] rust: block: fix wrong usage of lockdep API Alice Ryhl
2024-08-15 19:05 ` Benno Lossin
2024-08-15 19:15 ` Benno Lossin
2024-08-15 21:34 ` Boqun Feng
2024-08-15 19:07 ` Gary Guo
2024-08-15 21:32 ` Boqun Feng
2024-08-15 21:42 ` Gary Guo
2024-08-16 13:08 ` Benno Lossin
2024-08-15 10:02 ` Dirk Behme
2024-08-16 15:59 ` Benno Lossin
2024-08-15 14:22 ` [PATCH 0/2] rust: fix erranous use of lock class key in rust block device bindings Jens Axboe
2024-08-15 15:31 ` Miguel Ojeda
2024-08-15 16:00 ` Jens Axboe
2024-08-16 8:54 ` Miguel Ojeda
2024-08-21 10:50 ` Miguel Ojeda
2024-08-21 11:36 ` Miguel Ojeda
2024-08-21 11:54 ` Miguel Ojeda
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=20240815074519.2684107-3-nmi@metaspace.dk \
--to=nmi@metaspace.dk \
--cc=Dirk.Behme@de.bosch.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=axboe@kernel.dk \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/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
all inboxes | Powered by JetHome®