Skip to content

`Zeroable` improvements & bindings integration

Benno Lossin dri-devel linux-acpi linux-block linux-devicetree linux-pm linux-security-module lkml netdev rust-for-linux 2 versions – Applied

Status from this message: Applied these #1, #2 and #11 to `rust-next` -- thanks everyone!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest11 patches 17 repliesApplied
  2. v213 patches 13 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/11rust: add `pin-init` as a dependency to `bindings` and `uapi`rust/Makefile scripts/generate_rust_analyzer.py+10 -81 reply
2/11rust: derive `Zeroable` for all structs & unions generated by bindgen where possiblerust/bindgen_parameters rust/bindings/lib.rs rust/uapi/lib.rs+14 -01 reply
3/11rust: miscdevice: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`rust/kernel/miscdevice.rs+3 -50 replies
4/11rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`rust/kernel/net/phy.rs+1 -30 replies
5/11rust: block: replace `core::mem::zeroed` with `pin_init::zeroed`rust/kernel/block/mq/gen_disk.rs rust/kernel/block/mq/tag_set.rs+2 -51 reply
6/11rust: of: replace `core::mem::zeroed` with `pin_init::zeroed`rust/kernel/of.rs+1 -30 replies
7/11rust: security: replace `core::mem::zeroed` with `pin_init::zeroed`rust/kernel/security.rs+1 -29 replies
8/11rust: drm: replace `core::mem::zeroed` with `pin_init::zeroed`rust/kernel/drm/gem/mod.rs+1 -30 replies
9/11rust: auxiliary: replace `core::mem::zeroed` with `pin_init::zeroed`rust/kernel/auxiliary.rs+1 -50 replies
10/11rust: acpi: replace `core::mem::zeroed` with `pin_init::zeroed`rust/kernel/acpi.rs+1 -30 replies
11/11rust: cpufreq: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`rust/kernel/cpufreq.rs+1 -31 reply

Reviews trailers per patch

4 of 11 patches have a Reviewed-by or Acked-by.

PatchViresh KumarAlice RyhlAndreas Hindborg
1/11R-b
2/11R-b
3/11
4/11
5/11A-b
6/11
7/11
8/11
9/11
10/11
11/11A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/11] `Zeroable` improvements & bindings integration

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/[email protected]

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

Signature · 1 line
2.50.1