* [PATCH] rust: adds bindings for bitmap.c and bitops.c
@ 2025-03-19 11:27 Burak Emir
2025-03-19 12:46 ` Miguel Ojeda
0 siblings, 1 reply; 6+ messages in thread
From: Burak Emir @ 2025-03-19 11:27 UTC (permalink / raw)
To: Yury Norov
Cc: Burak Emir, Rasmus Villemoes, Viresh Kumar, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel
Adds bindings are for inline non-atomic methods __set_bit and
__clear_bit (bitops) as well as bitmap_copy_and_extend.
Update MAINTAINERS.
These are needed for providing a Rust Bitmap API.
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Burak Emir <bqe@google.com>
---
Part of a series that introduces Rust Bitmap API that has received
a few rounds of review. Thanks for the helpful review comments.
Rebased on next-20250318 and split as requested in
https://lore.kernel.org/all/Z9nAVIokrWqoRiFR@thinkpad/
MAINTAINERS | 6 ++++++
rust/bindings/bindings_helper.h | 1 +
rust/helpers/bitmap.c | 9 +++++++++
rust/helpers/bitops.c | 13 +++++++++++++
rust/helpers/helpers.c | 2 ++
5 files changed, 31 insertions(+)
create mode 100644 rust/helpers/bitmap.c
create mode 100644 rust/helpers/bitops.c
diff --git a/MAINTAINERS b/MAINTAINERS
index ebf7fa9a814d..7cd15c25a43c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4111,6 +4111,7 @@ F: tools/lib/find_bit.c
BITMAP API BINDINGS [RUST]
M: Yury Norov <yury.norov@gmail.com>
S: Maintained
+F: rust/helpers/bitmap.c
F: rust/helpers/cpumask.c
BITOPS API
@@ -4127,6 +4128,11 @@ F: include/linux/bitops.h
F: lib/test_bitops.c
F: tools/*/bitops*
+BITOPS API BINDINGS [RUST]
+M: Yury Norov <yury.norov@gmail.com>
+S: Maintained
+F: rust/helpers/bitops.c
+
BLINKM RGB LED DRIVER
M: Jan-Simon Moeller <jansimon.moeller@gmx.de>
S: Maintained
diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index fcefe3068a28..4f9374c2d7e5 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -7,6 +7,7 @@
*/
#include <kunit/test.h>
+#include <linux/bitmap.h>
#include <linux/blk-mq.h>
#include <linux/blk_types.h>
#include <linux/blkdev.h>
diff --git a/rust/helpers/bitmap.c b/rust/helpers/bitmap.c
new file mode 100644
index 000000000000..a50e2f082e47
--- /dev/null
+++ b/rust/helpers/bitmap.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/bitmap.h>
+
+void rust_helper_bitmap_copy_and_extend(unsigned long *to, const unsigned long *from,
+ unsigned int count, unsigned int size)
+{
+ bitmap_copy_and_extend(to, from, count, size);
+}
diff --git a/rust/helpers/bitops.c b/rust/helpers/bitops.c
new file mode 100644
index 000000000000..0ea1611b95dc
--- /dev/null
+++ b/rust/helpers/bitops.c
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/bitops.h>
+
+void rust_helper___set_bit(unsigned int nr, unsigned long *addr)
+{
+ __set_bit(nr, addr);
+}
+
+void rust_helper___clear_bit(unsigned int nr, unsigned long *addr)
+{
+ __clear_bit(nr, addr);
+}
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index e1c21eba9b15..0c25cc86a52a 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -7,6 +7,8 @@
* Sorted alphabetically.
*/
+#include "bitmap.c"
+#include "bitops.c"
#include "blk.c"
#include "bug.c"
#include "build_assert.c"
--
2.49.0.395.g12beb8f557-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: adds bindings for bitmap.c and bitops.c
2025-03-19 11:27 [PATCH] rust: adds bindings for bitmap.c and bitops.c Burak Emir
@ 2025-03-19 12:46 ` Miguel Ojeda
2025-03-19 13:58 ` Burak Emir
0 siblings, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2025-03-19 12:46 UTC (permalink / raw)
To: Burak Emir
Cc: Yury Norov, Rasmus Villemoes, Viresh Kumar, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel
On Wed, Mar 19, 2025 at 12:31 PM Burak Emir <bqe@google.com> wrote:
>
> Part of a series that introduces Rust Bitmap API that has received
> a few rounds of review. Thanks for the helpful review comments.
>
> Rebased on next-20250318 and split as requested in
> https://lore.kernel.org/all/Z9nAVIokrWqoRiFR@thinkpad/
I am not sure Yury meant to make it an independent patch, but rather a
different patch in the series.
Doing it this way means we add helpers that are unused, which I don't
think he would like, and we also normally don't do that either.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: adds bindings for bitmap.c and bitops.c
2025-03-19 12:46 ` Miguel Ojeda
@ 2025-03-19 13:58 ` Burak Emir
2025-03-19 15:43 ` Miguel Ojeda
0 siblings, 1 reply; 6+ messages in thread
From: Burak Emir @ 2025-03-19 13:58 UTC (permalink / raw)
To: Miguel Ojeda, Yury Norov
Cc: Rasmus Villemoes, Viresh Kumar, Miguel Ojeda, Alex Gaynor,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-for-linux,
linux-kernel
On Wed, Mar 19, 2025 at 1:46 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Wed, Mar 19, 2025 at 12:31 PM Burak Emir <bqe@google.com> wrote:
> >
> > Part of a series that introduces Rust Bitmap API that has received
> > a few rounds of review. Thanks for the helpful review comments.
> >
> > Rebased on next-20250318 and split as requested in
> > https://lore.kernel.org/all/Z9nAVIokrWqoRiFR@thinkpad/
>
> I am not sure Yury meant to make it an independent patch, but rather a
> different patch in the series.
>
> Doing it this way means we add helpers that are unused, which I don't
> think he would like, and we also normally don't do that either.
Thanks, I was unsure about this. I understand the desire to not add dead code.
Yet, next-20250318 does now contain helpers for `cpumask.c` without
corresponding `cpumask.rs`
So, I will include this in v5 of the rebased series, but with BITOPS
API BINDINGS [RUST] in its own patch.
Thanks for bearing with me : )
- Burak
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: adds bindings for bitmap.c and bitops.c
2025-03-19 13:58 ` Burak Emir
@ 2025-03-19 15:43 ` Miguel Ojeda
2025-03-19 16:06 ` Yury Norov
0 siblings, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2025-03-19 15:43 UTC (permalink / raw)
To: Burak Emir
Cc: Yury Norov, Rasmus Villemoes, Viresh Kumar, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel
On Wed, Mar 19, 2025 at 2:58 PM Burak Emir <bqe@google.com> wrote:
>
> Thanks, I was unsure about this. I understand the desire to not add dead code.
> Yet, next-20250318 does now contain helpers for `cpumask.c` without
> corresponding `cpumask.rs`
>
> So, I will include this in v5 of the rebased series, but with BITOPS
> API BINDINGS [RUST] in its own patch.
> Thanks for bearing with me : )
No worries at all! Perhaps wait a bit in case I misunderstood and Yury
wants to clarify.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: adds bindings for bitmap.c and bitops.c
2025-03-19 15:43 ` Miguel Ojeda
@ 2025-03-19 16:06 ` Yury Norov
2025-03-19 16:11 ` Burak Emir
0 siblings, 1 reply; 6+ messages in thread
From: Yury Norov @ 2025-03-19 16:06 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Burak Emir, Rasmus Villemoes, Viresh Kumar, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel
On Wed, Mar 19, 2025 at 04:43:50PM +0100, Miguel Ojeda wrote:
> On Wed, Mar 19, 2025 at 2:58 PM Burak Emir <bqe@google.com> wrote:
> >
> > Thanks, I was unsure about this. I understand the desire to not add dead code.
> > Yet, next-20250318 does now contain helpers for `cpumask.c` without
> > corresponding `cpumask.rs`
> >
> > So, I will include this in v5 of the rebased series, but with BITOPS
> > API BINDINGS [RUST] in its own patch.
> > Thanks for bearing with me : )
>
> No worries at all! Perhaps wait a bit in case I misunderstood and Yury
> wants to clarify.
Yes, the general idea is to be able look through the all software pieces
in a single series - from C wrappers all the way down to rust end users.
This way I'll make sure you are using the API in a right way. And I
think I already helped you in that department, right?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: adds bindings for bitmap.c and bitops.c
2025-03-19 16:06 ` Yury Norov
@ 2025-03-19 16:11 ` Burak Emir
0 siblings, 0 replies; 6+ messages in thread
From: Burak Emir @ 2025-03-19 16:11 UTC (permalink / raw)
To: Yury Norov
Cc: Miguel Ojeda, Rasmus Villemoes, Viresh Kumar, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel
On Wed, Mar 19, 2025 at 5:07 PM Yury Norov <yury.norov@gmail.com> wrote:
>
> On Wed, Mar 19, 2025 at 04:43:50PM +0100, Miguel Ojeda wrote:
> > On Wed, Mar 19, 2025 at 2:58 PM Burak Emir <bqe@google.com> wrote:
> > >
> > > Thanks, I was unsure about this. I understand the desire to not add dead code.
> > > Yet, next-20250318 does now contain helpers for `cpumask.c` without
> > > corresponding `cpumask.rs`
> > >
> > > So, I will include this in v5 of the rebased series, but with BITOPS
> > > API BINDINGS [RUST] in its own patch.
> > > Thanks for bearing with me : )
> >
> > No worries at all! Perhaps wait a bit in case I misunderstood and Yury
> > wants to clarify.
>
> Yes, the general idea is to be able look through the all software pieces
> in a single series - from C wrappers all the way down to rust end users.
>
> This way I'll make sure you are using the API in a right way. And I
> think I already helped you in that department, right?
Yep, thank you for the timely reviews with the comments. The series got
quite a few better. I'd love to be as timely with sending back the new versions,
still getting used to the conventions, workflow and limitations of the
infrastructure.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-19 16:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 11:27 [PATCH] rust: adds bindings for bitmap.c and bitops.c Burak Emir
2025-03-19 12:46 ` Miguel Ojeda
2025-03-19 13:58 ` Burak Emir
2025-03-19 15:43 ` Miguel Ojeda
2025-03-19 16:06 ` Yury Norov
2025-03-19 16:11 ` Burak Emir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox