From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9602D2D63F3 for ; Thu, 14 Aug 2025 09:31:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163864; cv=none; b=CpHTsCQRJ29gLKwHwBfwKk9dPFCEH4AzS5H9IV4LhzR6CReKF1TLzx4F4GpAWAzqDa5PeW/2TgTW3FAm1ZmJQca/DMKXJMRtce8gtKGHZ5OSqeYt488Rhr+F0HWGhm/HNLb+kIc3aKTIG1f0GfWszakxHqBZHVT0DSjw4L1zsvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163864; c=relaxed/simple; bh=f6id25YC4lGznzgiZVbzrP1QefpG8xvL+XSLDZNSUmI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jlKxxIDwYiBHCSkmE0Bw2zLrL0Kf9QtCMOKM3cD4IA2aSSCSCsaYrcY4H3G7MDZU/EMBDLI5Y+yhevhKKkEGPJuzAeER/XOOPIhNdBeRlfWuUkBd0HzOF/qf3E0Wdlac+N+ikJhBrmgWB7ZxWyeWQdpniO0weSe7w5eKPqm5BRY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NWGijxr/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NWGijxr/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D755EC4CEED; Thu, 14 Aug 2025 09:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755163864; bh=f6id25YC4lGznzgiZVbzrP1QefpG8xvL+XSLDZNSUmI=; h=From:To:Cc:Subject:Date:From; b=NWGijxr/Nuw6ubJcH8SetcHAoYbqQCf1fL70cdcrRC+FBpHDXpCG+NUoBYZzeDVzJ LhHWUNyfhE/sWt42Qc6Jza3zgqZ1Zu/xtS+sMHMfCfc6+oj79B3NL2ZMVT+wsKgbda 2C9+QcoKwrU6x5QrhmdbN6hAwC4935nwIhNYanMsR0xvgAKtt2ZiHAXRXekbYULE+B pxoKZxPCxwKy8HpM3AUazweHtUDhnxJZwWclPQ/po5pObDc0+iVLO/Am+f/U4ByZFe 1Jry7dOmsouFqvfRRUSJyBYH3BFVE5f5BzWyABhEIdvFaNGO+guvg6NtEUOhRWQIoS BH7E2XRHFKyHQ== From: Benno Lossin To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich Cc: rust-for-linux@vger.kernel.org Subject: [PATCH v3 00/11] `Zeroable` improvements & bindings integration Date: Thu, 14 Aug 2025 11:30:27 +0200 Message-ID: <20250814093046.2071971-1-lossin@kernel.org> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This came from a discussion at [1]. And I added some more useful parts to the original idea. I'm not sure on the impact of build times and rust-analyzer. We're adding a derive macro to every struct and union emitted by bindgen. Building using my test-config took 27.7s before and 28.2s after this change, but those are only two runs on my machine with a very reduced config (that enables all Rust code that we have at the moment). Maybe we have to reevaluate this when more C code is scanned by bindgen. [1]: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/Zeroable.20trait.20for.20C.20structs/with/509711564 Changelog ========= * v3: - removed already applied patches - added more patches replacing usage of `mem::zeroed` and `MaybeUninit::zeroed().assume_init()` with the new `pin_init::zeroed` - fix rusttest target * v2: - added patches with more extensive pin-init changes to `Zeroable` & related methods. for the upstream PR, see https://github.com/Rust-for-Linux/pin-init/pull/56 - added patches replacing usage of `mem::zeroed` and `MaybeUninit::zeroed().assume_init()` with the new `pin_init::zeroed` - fix rust-analyzer support - use import in `{uapi,bindings}/lib.rs` to avoid the `pin_init::` prefix * v1: https://lore.kernel.org/all/20250520192307.259142-1-lossin@kernel.org Benno Lossin (11): rust: add `pin-init` as a dependency to `bindings` and `uapi` rust: derive `Zeroable` for all structs & unions generated by bindgen where possible rust: miscdevice: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` rust: block: replace `core::mem::zeroed` with `pin_init::zeroed` rust: of: replace `core::mem::zeroed` with `pin_init::zeroed` rust: security: replace `core::mem::zeroed` with `pin_init::zeroed` rust: drm: replace `core::mem::zeroed` with `pin_init::zeroed` rust: auxiliary: replace `core::mem::zeroed` with `pin_init::zeroed` rust: acpi: replace `core::mem::zeroed` with `pin_init::zeroed` rust: cpufreq: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` rust/Makefile | 14 ++++++++------ rust/bindgen_parameters | 4 ++++ rust/bindings/lib.rs | 8 ++++++++ rust/kernel/acpi.rs | 4 +--- rust/kernel/auxiliary.rs | 6 +----- rust/kernel/block/mq/gen_disk.rs | 3 +-- rust/kernel/block/mq/tag_set.rs | 4 +--- rust/kernel/cpufreq.rs | 4 +--- rust/kernel/drm/gem/mod.rs | 4 +--- rust/kernel/miscdevice.rs | 8 +++----- rust/kernel/net/phy.rs | 4 +--- rust/kernel/of.rs | 4 +--- rust/kernel/security.rs | 3 +-- rust/uapi/lib.rs | 2 ++ scripts/generate_rust_analyzer.py | 4 ++-- 15 files changed, 36 insertions(+), 40 deletions(-) base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585 -- 2.50.1