From patchwork Thu Aug 15 07:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Hindborg X-Patchwork-Id: 13764474 Received: from mail-0301.mail-europe.com (mail-0301.mail-europe.com [188.165.51.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2763017D8A6 for ; Thu, 15 Aug 2024 07:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.165.51.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723708189; cv=none; b=jFNLFno85wn6pjHeDb8U5Khtr7z2WIJ7QVJkfwIXp7ZrjhV69gTo87H+U1sT4DVGn5W4bw66nUTscWgCRwnQ8iK5aiMbJaeHGKLFEh3Ij8cesMsbCvFFfpOFONYtRiFaYO0iajawnXzEA/P34VBZHRfFJWtFTUUjZArqsCwdDm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723708189; c=relaxed/simple; bh=5nwVUuNYwKfVCpbEE+hUU9mFT7cu5aK8oxDDp7r0klc=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=aj2gW+FbavYdsCxPucC1oarvaWfihOeW5aNasHlEUDGeBhWgo2sMVmUQL4CWdoH1OzfGeS/+Lf9ne3PhAQdQmid/txBpr/qugfScaLPXo3eUQERW5G1BynwRhCLJBhAMUVwuStn8rEcHYFP5r+nnDfRL1Z1FNl0w2JhgXFYJvsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=metaspace.dk; spf=pass smtp.mailfrom=metaspace.dk; dkim=pass (2048-bit key) header.d=metaspace.dk header.i=@metaspace.dk header.b=luiBVcIL; arc=none smtp.client-ip=188.165.51.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=metaspace.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=metaspace.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=metaspace.dk header.i=@metaspace.dk header.b="luiBVcIL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=metaspace.dk; s=protonmail; t=1723708175; x=1723967375; bh=pIXY+KRFjfzm2ElAJyOBnCOo4x0siZc6A7HAj9o5HdY=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=luiBVcILTJT1FVlY8AKCrYNlcQDeG6ESjOFmw8nhdTiQ4U9C0oxD3zQ/dFycluFIu mOdJ0xKijQutqSrkMy1lHnm7RJBieKQxSHtt2+6oZ192Fp8sRWEQcGTdEJRdGqkFzG WGMH5Bs6V6eHKm/Ct/izUUJDuVaHIBsW86vO6WAvQ0pJGqT0CWN0Bf8MgEb4kZ1jXC b8ueHL+Z84YeR+WIvmsLZWkO7jiSXiUPeOc6RtPNm4LiHce2HuhZUOcKzY78VXVCdl XDHUSAU89gj4ssgPK/Pz7Da+CMLkwHO0RdRii8/9CCwnLBnbK1+5skB91fc4y1AyJc qqxRqM32oDlAA== Date: Thu, 15 Aug 2024 07:49:30 +0000 To: Jens Axboe , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho From: Andreas Hindborg Cc: Andreas Hindborg , Boqun Feng , Gary Guo , =?utf-8?q?B?= =?utf-8?q?j=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , "Behme Dirk (XC-CP/ESB5)" , "linux-block@vger.kernel.org" , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] rust: fix export of bss symbols Message-ID: <20240815074519.2684107-2-nmi@metaspace.dk> Feedback-ID: 113830118:user:proton X-Pm-Message-ID: efe389b12c330869968acf4e5341f24708aaf04c Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andreas Hindborg Symbols in the bss segment are not currently exported. This is a problem for rust modules that link against statics, that are resident in the kernel image. This patch enables export of symbols in the bss segment. Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support") Signed-off-by: Andreas Hindborg Reviewed-by: Alice Ryhl Tested-by: Alice Ryhl Reviewed-by: Gary Guo --- rust/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/Makefile b/rust/Makefile index 1f10f92737f2..c890ec4b3618 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -305,7 +305,7 @@ $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers.c FORCE quiet_cmd_exports = EXPORTS $@ cmd_exports = \ $(NM) -p --defined-only $< \ - | awk '/ (T|R|D) / {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$3}' > $@ + | awk '/ (T|R|D|B) / {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$3}' > $@ $(obj)/exports_core_generated.h: $(obj)/core.o FORCE $(call if_changed,exports) From patchwork Thu Aug 15 07:49:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Hindborg X-Patchwork-Id: 13764475 Received: from mail-4018.proton.ch (mail-4018.proton.ch [185.70.40.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7EF1199393; Thu, 15 Aug 2024 07:49:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.40.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723708192; cv=none; b=W5DivVQR+iUtMIu/8zKWt1ghgtISNQcZTkaeA5QXoDMMzGjmidVswev4V5pPl3yXVqO0jvgplp8pZPvZr1XloKLSpBEpd2Hnj8CANu5ajZ4+oN3kbugwFKt6sUi3e4xl8iivfX8yEVDoSw73255Ip5elsSwC6Bj02sEKDYX9nes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723708192; c=relaxed/simple; bh=J5y8uAimX4xtr2yE+uLu/aFPB+ejQEqX9bmDJAkAXiQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=saSE83b0YmZaEEE/oaTwO1Ecgdzmwx0o99UEkvhY+6dPXHuRLNymYP1OkC73K/XiDzsZBCDWyybJhhcKROOjTZHCT01pFIzhbfWDPsZh+maAuSxEigxUOsCnf04dUPIw9ewQfp6Be+kw40cySR/1XHtYd8yU36w2wJlOhz5YNUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=metaspace.dk; spf=pass smtp.mailfrom=metaspace.dk; dkim=pass (2048-bit key) header.d=metaspace.dk header.i=@metaspace.dk header.b=Gn6fAWTu; arc=none smtp.client-ip=185.70.40.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=metaspace.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=metaspace.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=metaspace.dk header.i=@metaspace.dk header.b="Gn6fAWTu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=metaspace.dk; s=protonmail; t=1723708187; x=1723967387; bh=tMjFdwYIY6C6jB1odGF7Z3jQj5z8jwdgu9RMhv9fvok=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Gn6fAWTuWn5k1JjallCtmi4z6szjz9LNdtgGbnQElbUsRGlClLQPiAuBs36UxNyct 18SFPrg0mgp11BXhJLfa9Zr5Ok/3Zzfy1an1d2RmM9OILRK/mpEETJwHTOF/Z35EFA n1sXv5gl4pAdO0NIw+W2syh5/PCk73RQmj2CH+gglDxeEYn5vyZ1GdPhok6hFnx1aX HXSh+UvSRnovW2W+7XGawx8/tsq7rhi9zI3knJMMINNfyRaUBibEkFZAwjv/lXdvWv TmEotzHZMQe5tfyS0cKv0ejzNmj3Nka7Wg02IQzwDADjhsWXRALzNO8oMYdLUKq8p3 6b1zePNN/phKA== Date: Thu, 15 Aug 2024 07:49:43 +0000 To: Jens Axboe , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho From: Andreas Hindborg Cc: Andreas Hindborg , "Behme Dirk (XC-CP/ESB5)" , Boqun Feng , Gary Guo , =?utf-8?q?B?= =?utf-8?q?j=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , "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 Message-ID: <20240815074519.2684107-3-nmi@metaspace.dk> In-Reply-To: <20240815074519.2684107-1-nmi@metaspace.dk> References: <20240815074519.2684107-1-nmi@metaspace.dk> Feedback-ID: 113830118:user:proton X-Pm-Message-ID: a38f9a24aeb93474486611d5e3c90e014f6b1790 Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andreas Hindborg 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)" 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 Reviewed-by: Alice Ryhl Tested-by: Dirk Behme Reviewed-by: Gary Guo Reviewed-by: Benno Lossin --- 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( name: fmt::Arguments<'_>, tagset: Arc>, ) -> Result> { - 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( tagset.raw_tag_set(), &mut lim, core::ptr::null_mut(), - lock_class_key.as_ptr(), + static_lock_class!().as_ptr(), ) })?;