Skip to contentSkip to conversation

rust compile failure in next-20260730

DISCUSSION Bert Karwatzki 10 participants 15 messages Jul 31 – Aug 6

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

With next-20260730 building a kernel with CONFIG_RUST=y fails with the following error:

RUSTC L rust/kernel.o
error[E0308]: mismatched types

     --> rust/kernel/sync/poll.rs:175:44
      |
  175 |         unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get(), ptr.cast::<ffi::c_void>()) };
      |                  ------------------------- ^^^^^^^^^^^^^^^^ expected `*mut kvfree_rcu_head`, found `*mut callback_head`
      |                  |
      |                  arguments to this function are incorrect
      |
      = note: expected raw pointer `*mut bindings::kvfree_rcu_head`
                 found raw pointer `*mut bindings::callback_head`
note: function defined here
     --> /mnt/data/linux-forest/linux-next/rust/bindings/bindings_generated.rs:73708:12
      |
73708 |     pub fn kvfree_call_rcu(head: *mut kvfree_rcu_head, ptr: *mut ffi::c_void);
      |            ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308. make[5]: *** [rust/Makefile:781: rust/kernel.o] Fehler 1 make[4]: *** [Makefile:1420: prepare] Fehler 2
make[3]: *** [debian/rules:80: build-arch] Fehler 2

Reverting the following commits:
ef32a74f8f6a ("mm/slab: introduce kfree_rcu_nolock()")
bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching")

make the compilation work again.

Bert Karwatzki

#1 lore raw
Quoted 2 lines · Bert Karwatzki

With next-20260730 building a kernel with CONFIG_RUST=y fails with the following error:

Ran into this, too. Fixing this is discussed in this thread:
https://lore.kernel.org/all/[email protected]/

Quoted 31 lines

RUSTC L rust/kernel.o
error[E0308]: mismatched types

     --> rust/kernel/sync/poll.rs:175:44
      |
  175 |         unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get(), ptr.cast::<ffi::c_void>()) };
      |                  ------------------------- ^^^^^^^^^^^^^^^^ expected `*mut kvfree_rcu_head`, found `*mut callback_head`
      |                  |
      |                  arguments to this function are incorrect
      |
      = note: expected raw pointer `*mut bindings::kvfree_rcu_head`
                 found raw pointer `*mut bindings::callback_head`
note: function defined here
     --> /mnt/data/linux-forest/linux-next/rust/bindings/bindings_generated.rs:73708:12
      |
73708 |     pub fn kvfree_call_rcu(head: *mut kvfree_rcu_head, ptr: *mut ffi::c_void);
      |            ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308. make[5]: *** [rust/Makefile:781: rust/kernel.o] Fehler 1 make[4]: *** [Makefile:1420: prepare] Fehler 2
make[3]: *** [debian/rules:80: build-arch] Fehler 2

Reverting the following commits:
ef32a74f8f6a ("mm/slab: introduce kfree_rcu_nolock()")
bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching")

make the compilation work again.

Bert Karwatzki

#2 lore raw

Noticed this too

Den fre 31 juli 2026 kl 15:21 skrev Thorsten Leemhuis <[email protected]>:

Quoted 41 lines · Bert Karwatzki
Quoted 2 lines

With next-20260730 building a kernel with CONFIG_RUST=y fails with the following error:

Ran into this, too. Fixing this is discussed in this thread:
https://lore.kernel.org/all/[email protected]/

Quoted 31 lines

RUSTC L rust/kernel.o
error[E0308]: mismatched types

     --> rust/kernel/sync/poll.rs:175:44
      |
  175 |         unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get(), ptr.cast::<ffi::c_void>()) };
      |                  ------------------------- ^^^^^^^^^^^^^^^^ expected `*mut kvfree_rcu_head`, found `*mut callback_head`
      |                  |
      |                  arguments to this function are incorrect
      |
      = note: expected raw pointer `*mut bindings::kvfree_rcu_head`
                 found raw pointer `*mut bindings::callback_head`
note: function defined here
     --> /mnt/data/linux-forest/linux-next/rust/bindings/bindings_generated.rs:73708:12
      |
73708 |     pub fn kvfree_call_rcu(head: *mut kvfree_rcu_head, ptr: *mut ffi::c_void);
      |            ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308. make[5]: *** [rust/Makefile:781: rust/kernel.o] Fehler 1 make[4]: *** [Makefile:1420: prepare] Fehler 2
make[3]: *** [debian/rules:80: build-arch] Fehler 2

Reverting the following commits:
ef32a74f8f6a ("mm/slab: introduce kfree_rcu_nolock()")
bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching")

make the compilation work again.

Bert Karwatzki

#3 lore raw
In reply to Bert Karwatzki

+ folks from e5e86df8b666

Quoted 27 lines · Bert Karwatzki

With next-20260730 building a kernel with CONFIG_RUST=y fails with the following error:

RUSTC L rust/kernel.o
error[E0308]: mismatched types

     --> rust/kernel/sync/poll.rs:175:44
      |
  175 |         unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get(), ptr.cast::<ffi::c_void>()) };
      |                  ------------------------- ^^^^^^^^^^^^^^^^ expected `*mut kvfree_rcu_head`, found `*mut callback_head`
      |                  |
      |                  arguments to this function are incorrect
      |
      = note: expected raw pointer `*mut bindings::kvfree_rcu_head`
                 found raw pointer `*mut bindings::callback_head`
note: function defined here
     --> /mnt/data/linux-forest/linux-next/rust/bindings/bindings_generated.rs:73708:12
      |
73708 |     pub fn kvfree_call_rcu(head: *mut kvfree_rcu_head, ptr: *mut ffi::c_void);
      |            ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308. make[5]: *** [rust/Makefile:781: rust/kernel.o] Fehler 1 make[4]: *** [Makefile:1420: prepare] Fehler 2
make[3]: *** [debian/rules:80: build-arch] Fehler 2

Quoted 5 lines

Reverting the following commits:
ef32a74f8f6a ("mm/slab: introduce kfree_rcu_nolock()")
bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching")

make the compilation work again.

This is a collision between commit e5e86df8b666 ("rust: poll: use kfree_rcu() for PollCondVar") in the char-misc tree and the aforementioned commit bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching") in the slab tree.

Something like this avoids the error for me but I am not sure if it is a proper fix.

rust/kernel/sync/poll.rs +3 -0
index 684dfa242b1a..5b12d5d4e9af 100644
@@ -124,6 +124,9 @@ pub struct PollCondVarBox {
 struct PollCondVarBoxInner {
     #[pin]
     inner: PollCondVar,
+    #[cfg(CONFIG_KVFREE_RCU_BATCHED)]
+    rcu: Opaque<bindings::kvfree_rcu_head>,
+    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
     rcu: Opaque<bindings::callback_head>,
 }
 
Signature · 2 lines
Cheers,
Nathan
maintainer
#4 lore raw
Quoted 49 lines · Nathan Chancellor

+ folks from e5e86df8b666

Quoted 27 lines · Bert Karwatzki

With next-20260730 building a kernel with CONFIG_RUST=y fails with the following error:

RUSTC L rust/kernel.o
error[E0308]: mismatched types

     --> rust/kernel/sync/poll.rs:175:44
      |
  175 |         unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get(), ptr.cast::<ffi::c_void>()) };
      |                  ------------------------- ^^^^^^^^^^^^^^^^ expected `*mut kvfree_rcu_head`, found `*mut callback_head`
      |                  |
      |                  arguments to this function are incorrect
      |
      = note: expected raw pointer `*mut bindings::kvfree_rcu_head`
                 found raw pointer `*mut bindings::callback_head`
note: function defined here
     --> /mnt/data/linux-forest/linux-next/rust/bindings/bindings_generated.rs:73708:12
      |
73708 |     pub fn kvfree_call_rcu(head: *mut kvfree_rcu_head, ptr: *mut ffi::c_void);
      |            ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308. make[5]: *** [rust/Makefile:781: rust/kernel.o] Fehler 1 make[4]: *** [Makefile:1420: prepare] Fehler 2
make[3]: *** [debian/rules:80: build-arch] Fehler 2

Quoted 5 lines

Reverting the following commits:
ef32a74f8f6a ("mm/slab: introduce kfree_rcu_nolock()")
bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching")

make the compilation work again.

This is a collision between commit e5e86df8b666 ("rust: poll: use kfree_rcu() for PollCondVar") in the char-misc tree and the aforementioned commit bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching") in the slab tree.

Something like this avoids the error for me but I am not sure if it is a proper fix.

rust/kernel/sync/poll.rs +0 -0
index 684dfa242b1a..5b12d5d4e9af 100644

rust/kernel/sync/poll.rs pub struct PollCondVarBox { · line 130

Quoted 7 lines
rust/kernel/sync/poll.rs +3 -0
@@ -124,6 +124,9 @@ pub struct PollCondVarBox {
 struct PollCondVarBoxInner {
     #[pin]
     inner: PollCondVar,
+    #[cfg(CONFIG_KVFREE_RCU_BATCHED)]
+    rcu: Opaque<bindings::kvfree_rcu_head>,
+    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
     rcu: Opaque<bindings::callback_head>,

We could also unconditionally use kvfree_rcu_head here, and add

    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

(Or even better, changing #define to typedef so bindgen takes care of everything).

Best,
Gary

maintainer
#5 lore raw
Quoted 61 lines · Gary Guo
Quoted 49 lines · Nathan Chancellor

+ folks from e5e86df8b666

Quoted 27 lines · Bert Karwatzki

With next-20260730 building a kernel with CONFIG_RUST=y fails with the following error:

RUSTC L rust/kernel.o
error[E0308]: mismatched types

     --> rust/kernel/sync/poll.rs:175:44
      |
  175 |         unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get(), ptr.cast::<ffi::c_void>()) };
      |                  ------------------------- ^^^^^^^^^^^^^^^^ expected `*mut kvfree_rcu_head`, found `*mut callback_head`
      |                  |
      |                  arguments to this function are incorrect
      |
      = note: expected raw pointer `*mut bindings::kvfree_rcu_head`
                 found raw pointer `*mut bindings::callback_head`
note: function defined here
     --> /mnt/data/linux-forest/linux-next/rust/bindings/bindings_generated.rs:73708:12
      |
73708 |     pub fn kvfree_call_rcu(head: *mut kvfree_rcu_head, ptr: *mut ffi::c_void);
      |            ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308. make[5]: *** [rust/Makefile:781: rust/kernel.o] Fehler 1 make[4]: *** [Makefile:1420: prepare] Fehler 2
make[3]: *** [debian/rules:80: build-arch] Fehler 2

Quoted 5 lines

Reverting the following commits:
ef32a74f8f6a ("mm/slab: introduce kfree_rcu_nolock()")
bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching")

make the compilation work again.

This is a collision between commit e5e86df8b666 ("rust: poll: use kfree_rcu() for PollCondVar") in the char-misc tree and the aforementioned commit bdd0cc9f0ffc ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching") in the slab tree.

Something like this avoids the error for me but I am not sure if it is a proper fix.

rust/kernel/sync/poll.rs +0 -0
index 684dfa242b1a..5b12d5d4e9af 100644

rust/kernel/sync/poll.rs pub struct PollCondVarBox { · line 130

Quoted 7 lines
rust/kernel/sync/poll.rs +3 -0
@@ -124,6 +124,9 @@ pub struct PollCondVarBox {
 struct PollCondVarBoxInner {
     #[pin]
     inner: PollCondVar,
+    #[cfg(CONFIG_KVFREE_RCU_BATCHED)]
+    rcu: Opaque<bindings::kvfree_rcu_head>,
+    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
     rcu: Opaque<bindings::callback_head>,

We could also unconditionally use kvfree_rcu_head here, and add

Quoted 5 lines
    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this.

Quoted 3 lines

(Or even better, changing #define to typedef so bindgen takes care of everything).

Yes, this is better IMO, but it's up to slab maintainers. :-)

Regards,
Boqun

Quoted 3 lines

Best,
Gary

#6 lore raw
Quoted 11 lines · Boqun Feng
Quoted 9 lines · Gary Guo

We could also unconditionally use kvfree_rcu_head here, and add

    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

Quoted 8 lines

This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this.

Quoted 3 lines

(Or even better, changing #define to typedef so bindgen takes care of everything).

Yes, this is better IMO, but it's up to slab maintainers. :-)

Can you elaborate a bit please, how would that look like?

Quoted 6 lines

Regards,
Boqun

Quoted 3 lines

Best,
Gary

maintainer
#7 lore raw
Quoted 15 lines · Vlastimil Babka (SUSE)
Quoted 14 lines · Boqun Feng
Quoted 9 lines · Gary Guo

We could also unconditionally use kvfree_rcu_head here, and add

    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

(Or even better, changing #define to typedef so bindgen takes care of everything).

Yes, this is better IMO, but it's up to slab maintainers. :-)

Can you elaborate a bit please, how would that look like?

I was thinking of doing typedef struct rcu_head kvfree_rcu_head; but of course that didn't work because you can't use typedef to create kvfree_rcu_head :)

However, something like this could work?

    #ifdef CONFIG_KVFREE_RCU_BATCHED
    ...
    #else
    struct kvfree_rcu_head {
        struct rcu_head head;
    };
    #endif

and everywhere add a cast everywhere that expects kvfree_rcu_head == rcu_head.

but this would indeed be more complex :(

It's a bit unfortunate that C doesn't have a better way of doing struct type aliases without doing textual replacement with macro.

Another approach is to have:

    #ifdef __BINDGEN__
    typedef struct rcu_head kvfree_rcu_head;
    #endif
    #define kvfree_rcu_head rcu_head

so bindgen can still see the typedef while it doesn't have effect for C users. But this doesn't look perfect either.

Best,
Gary

#8 lore raw
Quoted 37 lines · Gary Guo
Quoted 15 lines · Vlastimil Babka (SUSE)
Quoted 14 lines · Boqun Feng
Quoted 9 lines · Gary Guo

We could also unconditionally use kvfree_rcu_head here, and add

    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

(Or even better, changing #define to typedef so bindgen takes care of everything).

Yes, this is better IMO, but it's up to slab maintainers. :-)

Can you elaborate a bit please, how would that look like?

I was thinking of doing typedef struct rcu_head kvfree_rcu_head; but of course that didn't work because you can't use typedef to create kvfree_rcu_head :)

However, something like this could work?

    #ifdef CONFIG_KVFREE_RCU_BATCHED
    ...
    #else
    struct kvfree_rcu_head {
        struct rcu_head head;
    };
    #endif
Quoted 3 lines

and everywhere add a cast everywhere that expects kvfree_rcu_head == rcu_head.

but this would indeed be more complex :(

So you mean like this? Doesn't seem so complex and seems to compile here with CONFIG_KVFREE_RCU_BATCHED both disabled and enabled.
I can apply the slab part in slab tree, but AFAICS the poll.rs change still needs to be done in the merge commit. Unless there's some way to make things conditional on whether kvfree_rcu_head exists?

include/linux/types.h +3 -1
index 79bf419c69e4..53e0adca4b9f 100644
@@ -262,7 +262,9 @@ struct kvfree_rcu_head {
 	struct kvfree_rcu_head *next;
 };
 #else
-#define kvfree_rcu_head rcu_head
+struct kvfree_rcu_head {
+	struct rcu_head head;
+};
 #endif
 
 typedef void (*rcu_callback_t)(struct rcu_head *head);
mm/slab_common.c +2 -2
index 64845ac81b79..aecbe9b9df4c 100644
@@ -1325,11 +1325,11 @@ EXPORT_SYMBOL_GPL(kfree_call_rcu_nolock);
 
 #ifndef CONFIG_KVFREE_RCU_BATCHED
 
-void kvfree_call_rcu(struct rcu_head *head, void *ptr)
+void kvfree_call_rcu(struct kvfree_rcu_head *head, void *ptr)
 {
 	if (head) {
 		kasan_record_aux_stack(ptr);
-		call_rcu(head, kvfree_rcu_cb);
+		call_rcu(&head->head, kvfree_rcu_cb);
 		return;
 	}
 
rust/kernel/sync/poll.rs +1 -1
index 684dfa242b1a..f3cdf95db12d 100644
@@ -124,7 +124,7 @@ pub struct PollCondVarBox {
 struct PollCondVarBoxInner {
     #[pin]
     inner: PollCondVar,
-    rcu: Opaque<bindings::callback_head>,
+    rcu: Opaque<bindings::kvfree_rcu_head>,
 }
 
 // SAFETY: PollCondVar is Send
maintainer
#9 lore raw
Quoted 38 lines · Vlastimil Babka (SUSE)
Quoted 37 lines · Gary Guo
Quoted 15 lines · Vlastimil Babka (SUSE)
Quoted 14 lines · Boqun Feng
Quoted 9 lines · Gary Guo

We could also unconditionally use kvfree_rcu_head here, and add

    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

(Or even better, changing #define to typedef so bindgen takes care of everything).

Yes, this is better IMO, but it's up to slab maintainers. :-)

Can you elaborate a bit please, how would that look like?

I was thinking of doing typedef struct rcu_head kvfree_rcu_head; but of course that didn't work because you can't use typedef to create kvfree_rcu_head :)

However, something like this could work?

    #ifdef CONFIG_KVFREE_RCU_BATCHED
    ...
    #else
    struct kvfree_rcu_head {
        struct rcu_head head;
    };
    #endif
Quoted 6 lines
Quoted 3 lines

and everywhere add a cast everywhere that expects kvfree_rcu_head == rcu_head.

but this would indeed be more complex :(

So you mean like this? Doesn't seem so complex and seems to compile here with CONFIG_KVFREE_RCU_BATCHED both disabled and enabled.

I thought that a lot more places have to be updated, but it looks from your diff below that this is simple enough.

Best,
Gary

Quoted 50 lines

I can apply the slab part in slab tree, but AFAICS the poll.rs change still needs to be done in the merge commit. Unless there's some way to make things conditional on whether kvfree_rcu_head exists?

include/linux/types.h +3 -1
index 79bf419c69e4..53e0adca4b9f 100644
@@ -262,7 +262,9 @@ struct kvfree_rcu_head {
 	struct kvfree_rcu_head *next;
 };
 #else
-#define kvfree_rcu_head rcu_head
+struct kvfree_rcu_head {
+	struct rcu_head head;
+};
 #endif
 
 typedef void (*rcu_callback_t)(struct rcu_head *head);
mm/slab_common.c +2 -2
index 64845ac81b79..aecbe9b9df4c 100644
@@ -1325,11 +1325,11 @@ EXPORT_SYMBOL_GPL(kfree_call_rcu_nolock);
 
 #ifndef CONFIG_KVFREE_RCU_BATCHED
 
-void kvfree_call_rcu(struct rcu_head *head, void *ptr)
+void kvfree_call_rcu(struct kvfree_rcu_head *head, void *ptr)
 {
 	if (head) {
 		kasan_record_aux_stack(ptr);
-		call_rcu(head, kvfree_rcu_cb);
+		call_rcu(&head->head, kvfree_rcu_cb);
 		return;
 	}
 
rust/kernel/sync/poll.rs +1 -1
index 684dfa242b1a..f3cdf95db12d 100644
@@ -124,7 +124,7 @@ pub struct PollCondVarBox {
 struct PollCondVarBoxInner {
     #[pin]
     inner: PollCondVar,
-    rcu: Opaque<bindings::callback_head>,
+    rcu: Opaque<bindings::kvfree_rcu_head>,
 }
 
 // SAFETY: PollCondVar is Send
#10 lore raw
Quoted 41 lines · Gary Guo
Quoted 40 lines · Vlastimil Babka (SUSE)
Quoted 39 lines · Gary Guo
Quoted 15 lines · Vlastimil Babka (SUSE)
Quoted 14 lines · Boqun Feng
Quoted 9 lines · Gary Guo

We could also unconditionally use kvfree_rcu_head here, and add

    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

(Or even better, changing #define to typedef so bindgen takes care of everything).

Yes, this is better IMO, but it's up to slab maintainers. :-)

Can you elaborate a bit please, how would that look like?

I was thinking of doing typedef struct rcu_head kvfree_rcu_head; but of course that didn't work because you can't use typedef to create kvfree_rcu_head :)

However, something like this could work?

    #ifdef CONFIG_KVFREE_RCU_BATCHED
    ...
    #else
    struct kvfree_rcu_head {
        struct rcu_head head;
    };
    #endif

and everywhere add a cast everywhere that expects kvfree_rcu_head == rcu_head.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

but this would indeed be more complex :(

So you mean like this? Doesn't seem so complex and seems to compile here with CONFIG_KVFREE_RCU_BATCHED both disabled and enabled.

I thought that a lot more places have to be updated, but it looks from your diff below that this is simple enough.

Thanks. The slab/for-next branch now includes the slab changes. The merge commit should thus perform the rust/kernel/sync/poll.rs change.

Quoted 55 lines

Best,
Gary

Quoted 50 lines

I can apply the slab part in slab tree, but AFAICS the poll.rs change still needs to be done in the merge commit. Unless there's some way to make things conditional on whether kvfree_rcu_head exists?

include/linux/types.h +3 -1
index 79bf419c69e4..53e0adca4b9f 100644
@@ -262,7 +262,9 @@ struct kvfree_rcu_head {
 	struct kvfree_rcu_head *next;
 };
 #else
-#define kvfree_rcu_head rcu_head
+struct kvfree_rcu_head {
+	struct rcu_head head;
+};
 #endif
 
 typedef void (*rcu_callback_t)(struct rcu_head *head);
mm/slab_common.c +2 -2
index 64845ac81b79..aecbe9b9df4c 100644
@@ -1325,11 +1325,11 @@ EXPORT_SYMBOL_GPL(kfree_call_rcu_nolock);
 
 #ifndef CONFIG_KVFREE_RCU_BATCHED
 
-void kvfree_call_rcu(struct rcu_head *head, void *ptr)
+void kvfree_call_rcu(struct kvfree_rcu_head *head, void *ptr)
 {
 	if (head) {
 		kasan_record_aux_stack(ptr);
-		call_rcu(head, kvfree_rcu_cb);
+		call_rcu(&head->head, kvfree_rcu_cb);
 		return;
 	}
 
rust/kernel/sync/poll.rs +1 -1
index 684dfa242b1a..f3cdf95db12d 100644
@@ -124,7 +124,7 @@ pub struct PollCondVarBox {
 struct PollCondVarBoxInner {
     #[pin]
     inner: PollCondVar,
-    rcu: Opaque<bindings::callback_head>,
+    rcu: Opaque<bindings::kvfree_rcu_head>,
 }
 
 // SAFETY: PollCondVar is Send
#11 lore raw
Quoted 3 lines · Vlastimil Babka (SUSE)

Thanks. The slab/for-next branch now includes the slab changes. The merge commit should thus perform the rust/kernel/sync/poll.rs change.

I don't see it in next-20260805 -- Mark, could we please get the last diff hunk from:

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

applied tomorrow in the char-misc-next merge? i.e.

- rcu: Opaque<bindings::callback_head>,
+ rcu: Opaque<bindings::kvfree_rcu_head>,

in rust/kernel/sync/poll.rs.

Thanks!

Cheers,
Miguel

#12 lore raw
Quoted 9 lines · Miguel Ojeda
Quoted 3 lines · Vlastimil Babka (SUSE)

Thanks. The slab/for-next branch now includes the slab changes. The merge commit should thus perform the rust/kernel/sync/poll.rs change.

I don't see it in next-20260805 -- Mark, could we please get the last diff hunk from:

Quoted 8 lines

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

applied tomorrow in the char-misc-next merge? i.e.

- rcu: Opaque<bindings::callback_head>,
+ rcu: Opaque<bindings::kvfree_rcu_head>,

in rust/kernel/sync/poll.rs.

I was just asking Mark about it on IRC and sent the fix as he asked:
https://lore.kernel.org/all/[email protected]/

Quoted 4 lines

Thanks!

Cheers,
Miguel

maintainer
#13 lore raw
In reply to Miguel Ojeda
Quoted 11 lines · Miguel Ojeda

I don't see it in next-20260805 -- Mark, could we please get the last diff hunk from:

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

applied tomorrow in the char-misc-next merge? i.e.

- rcu: Opaque<bindings::callback_head>,
+ rcu: Opaque<bindings::kvfree_rcu_head>,

in rust/kernel/sync/poll.rs.

Could someone please send me the exact merge fixup you want applying as a patch, together with a description of which merge you want it applying to (or at least a description of the two trees affected so I can work it out)? That's going to be less error prone...

maintainer
#14 lore raw
In reply to Vlastimil Babka (SUSE)
Quoted 44 lines · Vlastimil Babka (SUSE)
Quoted 43 lines · Gary Guo
Quoted 42 lines · Vlastimil Babka (SUSE)
Quoted 40 lines · Gary Guo
Quoted 15 lines · Vlastimil Babka (SUSE)
Quoted 14 lines · Boqun Feng
Quoted 9 lines · Gary Guo

We could also unconditionally use kvfree_rcu_head here, and add

    #[cfg(not(CONFIG_KVFREE_RCU_BATCHED))]
    pub type kvfree_rcu_head = callback_head;

to bindings.rs?

This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

(Or even better, changing #define to typedef so bindgen takes care of everything).

Yes, this is better IMO, but it's up to slab maintainers. :-)

Can you elaborate a bit please, how would that look like?

I was thinking of doing typedef struct rcu_head kvfree_rcu_head; but of course that didn't work because you can't use typedef to create kvfree_rcu_head :)

However, something like this could work?

    #ifdef CONFIG_KVFREE_RCU_BATCHED
    ...
    #else
    struct kvfree_rcu_head {
        struct rcu_head head;
    };
    #endif

and everywhere add a cast everywhere that expects kvfree_rcu_head == rcu_head.

but this would indeed be more complex :(

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

So you mean like this? Doesn't seem so complex and seems to compile here with CONFIG_KVFREE_RCU_BATCHED both disabled and enabled.

I thought that a lot more places have to be updated, but it looks from your diff below that this is simple enough.

Thanks. The slab/for-next branch now includes the slab changes.

The slab changes looks good to me, thanks!

Signature · 2 lines
Cheers,
Harry / Hyeonggon