Skip to contentSkip to conversation

Bitmap bindings for rust

PATCH In review Yury Norov 4 participants 9 messages Feb 24, 2025 – Feb 28, 2025

Subsystems (2)
lore
Share & tools
lore

Yury Norov

author maintainer
#0 lore raw

v2 cover Bitmap bindings for rust

The bindings and a new maintenance entry together with the API changes policy.

v1: https://lore.kernel.org/all/[email protected]/T/
v2:
- export alloc_cpumask_var() @ Viresh;
- clarify that the maintenance rules apply to all bitmap interfaces, including those not mentioned explicitly in the helpers @ Miguel.

Viresh Kumar (1):
rust: Add cpumask helpers

Yury Norov [NVIDIA] (1):
MAINTAINERS: add rust bindings entry for bitmap API

 MAINTAINERS                     |  5 ++++
 rust/bindings/bindings_helper.h |  1 +
 rust/helpers/cpumask.c          | 45 +++++++++++++++++++++++++++++++++
 rust/helpers/helpers.c          |  1 +
 4 files changed, 52 insertions(+)
 create mode 100644 rust/helpers/cpumask.c
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/2 rust: Add cpumask helpers

From: Viresh Kumar <[email protected]>

In order to prepare for adding Rust abstractions for cpumask, add the required helpers for inline cpumask functions that cannot be called by rust code directly.

---
 rust/bindings/bindings_helper.h |  1 +
 rust/helpers/cpumask.c          | 45 +++++++++++++++++++++++++++++++++
 rust/helpers/helpers.c          |  1 +
 3 files changed, 47 insertions(+)
 create mode 100644 rust/helpers/cpumask.c
rust/bindings/bindings_helper.h +1 -0
index f46cf3bb7069..2396ca1cf8fb 100644
@@ -10,6 +10,7 @@
 #include <linux/blk-mq.h>
 #include <linux/blk_types.h>
 #include <linux/blkdev.h>
+#include <linux/cpumask.h>
 #include <linux/cred.h>
 #include <linux/device/faux.h>
 #include <linux/errname.h>
rust/helpers/cpumask.c new file +45 -0

45 lines not on this page · raw message

rust/helpers/helpers.c +1 -0
index 0640b7e115be..de2341cfd917 100644
@@ -11,6 +11,7 @@
 #include "bug.c"
 #include "build_assert.c"
 #include "build_bug.c"
+#include "cpumask.c"
 #include "cred.c"
 #include "device.c"
 #include "err.c"
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH 1/2] rust: Add cpumask helpers

In reply to Yury Norov

Hi Yury,

Quoted 7 lines · Yury Norov

From: Viresh Kumar <[email protected]>

In order to prepare for adding Rust abstractions for cpumask, add the required helpers for inline cpumask functions that cannot be called by rust code directly.

I don’t understand what is going on here. You apparently did not provide the Rust code itself.

Usually, when I see a “in order to prepare for …” I expect the actual patch to follow in the same series.

Right now - and correct me if I'm wrong - it seems like you’ve essentially added dead code.

— Daniel

#4 lore raw

Re: [PATCH 1/2] rust: Add cpumask helpers

Quoted 8 lines · Daniel Almeida

I don’t understand what is going on here. You apparently did not provide the Rust code itself.

Usually, when I see a “in order to prepare for …” I expect the actual patch to follow in the same series.

Right now - and correct me if I'm wrong - it seems like you’ve essentially added dead code.

Rust abstractions:

https://lore.kernel.org/all/[email protected]/

Signature · 1 line
viresh
author maintainer
#5 lore raw

Re: [PATCH 1/2] rust: Add cpumask helpers

Quoted 7 lines · Viresh Kumar
Quoted 6 lines · Daniel Almeida

I don’t understand what is going on here. You apparently did not provide the Rust code itself.

Usually, when I see a “in order to prepare for …” I expect the actual patch to follow in the same series.

Quoted 6 lines
Quoted 2 lines

Right now - and correct me if I'm wrong - it seems like you’ve essentially added dead code.

Rust abstractions:

https://lore.kernel.org/all/[email protected]/

Yes, it's a dead code.

Cpumasks is a library, and people sometimes submit library code separately from their main projects, so it becomes unused for a while. GENMASK_U128() is one recent example.

I'm not happy about it, but I understand why people do so - it's important for them to have stable API, and their big project may take longer to get upstreamed.

So, if nobody's strongly opposite, I will move it myself. Alternatively, we can ask Viresh to take over the patches and move them together with his series.

Thanks,
Yury

author maintainer
#6 lore raw

PATCH v2 2/2 MAINTAINERS: add rust bindings entry for bitmap API

In reply to Yury Norov

From: "Yury Norov [NVIDIA]" <[email protected]>

This entry enumerates bitmap and related APIs listed in BITMAP API entry that rust requires but cannot use directly (i.e. inlined functions and macros).

The "Rust kernel policy" (https://rust-for-linux.com/rust-kernel-policy)
document describes the special status of rust support:

"Exceptionally, for Rust, a subsystem may allow to temporarily
break Rust code."

Accordingly, the following policy applies to all interfaces under the BITMAP API entry that are used in rust codebase, including those not listed explicitly here.

Bitmap developers do their best to keep the API stable. When API or user-visible behavior needs to be changed such that it breaks rust, bitmap and rust developers collaborate as follows:
- bitmap developers don't consider rust bindings as a blocker for the API change;
- bindings maintainer (me) makes sure that kernel build doesn't break with CONFIG_RUST=y. This implies fixes in the binding layer, but not in rust codebase;
- rust developers adopt new version of API in their codebase and remove unused bindings timely.

CC Danilo Krummrich <[email protected]>
CC Miguel Ojeda <[email protected]>
CC Viresh Kumar <[email protected]>
---
 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
index efee40ea589f..315cff76df29 100644
@@ -4021,6 +4021,11 @@ F:	tools/include/vdso/bits.h
 F:	tools/lib/bitmap.c
 F:	tools/lib/find_bit.c
 
+BITMAP API BINDINGS [RUST]
+M:	Yury Norov <[email protected]>
+S:	Maintained
+F:	rust/helpers/cpumask.c
+
 BITOPS API
 M:	Yury Norov <[email protected]>
 R:	Rasmus Villemoes <[email protected]>
Signature · 1 line
2.43.0
Reviewed-by on v2 2/2
#7 lore raw

Re: [PATCH 2/2] MAINTAINERS: add rust bindings entry for bitmap API

Quoted 27 lines · Yury Norov

From: "Yury Norov [NVIDIA]" <[email protected]>

This entry enumerates bitmap and related APIs listed in BITMAP API entry that rust requires but cannot use directly (i.e. inlined functions and macros).

The "Rust kernel policy" (https://rust-for-linux.com/rust-kernel-policy)
document describes the special status of rust support:

"Exceptionally, for Rust, a subsystem may allow to temporarily
break Rust code."

Accordingly, the following policy applies to all interfaces under the BITMAP API entry that are used in rust codebase, including those not listed explicitly here.

Bitmap developers do their best to keep the API stable. When API or user-visible behavior needs to be changed such that it breaks rust, bitmap and rust developers collaborate as follows:
- bitmap developers don't consider rust bindings as a blocker for the API change;
- bindings maintainer (me) makes sure that kernel build doesn't break with CONFIG_RUST=y. This implies fixes in the binding layer, but not in rust codebase;
- rust developers adopt new version of API in their codebase and remove unused bindings timely.

Quoted 7 lines
CC Danilo Krummrich <[email protected]>
CC Miguel Ojeda <[email protected]>
CC Viresh Kumar <[email protected]>
---
 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)
Signature · 1 line
viresh
author maintainer
#8 lore raw
In reply to Yury Norov
Quoted 8 lines · Yury Norov

The bindings and a new maintenance entry together with the API changes policy.

v1: https://lore.kernel.org/all/[email protected]/T/
v2:
- export alloc_cpumask_var() @ Viresh;
- clarify that the maintenance rules apply to all bitmap interfaces, including those not mentioned explicitly in the helpers @ Miguel.

OK, adding in bitmap-for-next for testing.

Thanks,
Yury

Quoted 15 lines

Viresh Kumar (1):
rust: Add cpumask helpers

Yury Norov [NVIDIA] (1):
MAINTAINERS: add rust bindings entry for bitmap API

 MAINTAINERS                     |  5 ++++
 rust/bindings/bindings_helper.h |  1 +
 rust/helpers/cpumask.c          | 45 +++++++++++++++++++++++++++++++++
 rust/helpers/helpers.c          |  1 +
 4 files changed, 52 insertions(+)
 create mode 100644 rust/helpers/cpumask.c
Signature · 1 line
2.43.0