* rust compile failure in next-20260730
@ 2026-07-31 12:28 Bert Karwatzki
2026-07-31 13:19 ` Thorsten Leemhuis
2026-07-31 19:25 ` Nathan Chancellor
0 siblings, 2 replies; 11+ messages in thread
From: Bert Karwatzki @ 2026-07-31 12:28 UTC (permalink / raw)
To: Harry Yoo; +Cc: Bert Karwatzki, linux-kernel, linux-next, Vlastimil Babka
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
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: rust compile failure in next-20260730 2026-07-31 12:28 rust compile failure in next-20260730 Bert Karwatzki @ 2026-07-31 13:19 ` Thorsten Leemhuis 2026-07-31 13:48 ` Luna Jernberg 2026-07-31 19:25 ` Nathan Chancellor 1 sibling, 1 reply; 11+ messages in thread From: Thorsten Leemhuis @ 2026-07-31 13:19 UTC (permalink / raw) To: Bert Karwatzki, Harry Yoo Cc: linux-kernel, linux-next, Vlastimil Babka, Linux kernel regressions list On 7/31/26 14:28, Bert Karwatzki wrote: > 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/20260731075644.20215-1-ojeda@kernel.org/ > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-07-31 13:19 ` Thorsten Leemhuis @ 2026-07-31 13:48 ` Luna Jernberg 0 siblings, 0 replies; 11+ messages in thread From: Luna Jernberg @ 2026-07-31 13:48 UTC (permalink / raw) To: Thorsten Leemhuis, spasswolf, Luna Jernberg Cc: Harry Yoo, linux-kernel, linux-next, Vlastimil Babka, Linux kernel regressions list Noticed this too Den fre 31 juli 2026 kl 15:21 skrev Thorsten Leemhuis <linux@leemhuis.info>: > > On 7/31/26 14:28, Bert Karwatzki wrote: > > 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/20260731075644.20215-1-ojeda@kernel.org/ > > > 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 > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-07-31 12:28 rust compile failure in next-20260730 Bert Karwatzki 2026-07-31 13:19 ` Thorsten Leemhuis @ 2026-07-31 19:25 ` Nathan Chancellor 2026-08-03 13:57 ` Gary Guo 1 sibling, 1 reply; 11+ messages in thread From: Nathan Chancellor @ 2026-07-31 19:25 UTC (permalink / raw) To: Bert Karwatzki Cc: Harry Yoo, linux-kernel, linux-next, Vlastimil Babka, Alice Ryhl, Boqun Feng, Greg Kroah-Hartman, rust-for-linux + folks from e5e86df8b666 On Fri, Jul 31, 2026 at 02:28:25PM +0200, Bert Karwatzki wrote: > 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. 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. diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs index 684dfa242b1a..5b12d5d4e9af 100644 --- a/rust/kernel/sync/poll.rs +++ b/rust/kernel/sync/poll.rs @@ -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>, } -- Cheers, Nathan ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-07-31 19:25 ` Nathan Chancellor @ 2026-08-03 13:57 ` Gary Guo 2026-08-03 14:23 ` Boqun Feng 0 siblings, 1 reply; 11+ messages in thread From: Gary Guo @ 2026-08-03 13:57 UTC (permalink / raw) To: Nathan Chancellor, Bert Karwatzki Cc: Harry Yoo, linux-kernel, linux-next, Vlastimil Babka, Alice Ryhl, Boqun Feng, Greg Kroah-Hartman, rust-for-linux On Fri Jul 31, 2026 at 8:25 PM BST, Nathan Chancellor wrote: > + folks from e5e86df8b666 > > On Fri, Jul 31, 2026 at 02:28:25PM +0200, Bert Karwatzki wrote: >> 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. > > 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. > > diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs > index 684dfa242b1a..5b12d5d4e9af 100644 > --- a/rust/kernel/sync/poll.rs > +++ b/rust/kernel/sync/poll.rs > @@ -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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-08-03 13:57 ` Gary Guo @ 2026-08-03 14:23 ` Boqun Feng 2026-08-03 15:10 ` Vlastimil Babka (SUSE) 0 siblings, 1 reply; 11+ messages in thread From: Boqun Feng @ 2026-08-03 14:23 UTC (permalink / raw) To: Gary Guo Cc: Nathan Chancellor, Bert Karwatzki, Harry Yoo, linux-kernel, linux-next, Vlastimil Babka, Alice Ryhl, Greg Kroah-Hartman, rust-for-linux On Mon, Aug 03, 2026 at 02:57:49PM +0100, Gary Guo wrote: > On Fri Jul 31, 2026 at 8:25 PM BST, Nathan Chancellor wrote: > > + folks from e5e86df8b666 > > > > On Fri, Jul 31, 2026 at 02:28:25PM +0200, Bert Karwatzki wrote: > >> 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. > > > > 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. > > > > diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs > > index 684dfa242b1a..5b12d5d4e9af 100644 > > --- a/rust/kernel/sync/poll.rs > > +++ b/rust/kernel/sync/poll.rs > > @@ -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? > This option is currently not maintainable unless it becomes a maintainer-aware way to handle things like this. > (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 > Best, > Gary > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-08-03 14:23 ` Boqun Feng @ 2026-08-03 15:10 ` Vlastimil Babka (SUSE) 2026-08-03 15:32 ` Gary Guo 0 siblings, 1 reply; 11+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-08-03 15:10 UTC (permalink / raw) To: Boqun Feng, Gary Guo Cc: Nathan Chancellor, Bert Karwatzki, Harry Yoo, linux-kernel, linux-next, Alice Ryhl, Greg Kroah-Hartman, rust-for-linux On 8/3/26 16:23, Boqun Feng wrote: > On Mon, Aug 03, 2026 at 02:57:49PM +0100, Gary Guo wrote: >> >> 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. > >> (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? > Regards, > Boqun > >> Best, >> Gary >> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-08-03 15:10 ` Vlastimil Babka (SUSE) @ 2026-08-03 15:32 ` Gary Guo 2026-08-03 21:04 ` Vlastimil Babka (SUSE) 0 siblings, 1 reply; 11+ messages in thread From: Gary Guo @ 2026-08-03 15:32 UTC (permalink / raw) To: Vlastimil Babka (SUSE), Boqun Feng, Gary Guo Cc: Nathan Chancellor, Bert Karwatzki, Harry Yoo, linux-kernel, linux-next, Alice Ryhl, Greg Kroah-Hartman, rust-for-linux On Mon Aug 3, 2026 at 4:10 PM BST, Vlastimil Babka (SUSE) wrote: > On 8/3/26 16:23, Boqun Feng wrote: >> On Mon, Aug 03, 2026 at 02:57:49PM +0100, Gary Guo wrote: >>> >>> 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. >> >>> (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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-08-03 15:32 ` Gary Guo @ 2026-08-03 21:04 ` Vlastimil Babka (SUSE) 2026-08-04 10:10 ` Gary Guo 0 siblings, 1 reply; 11+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-08-03 21:04 UTC (permalink / raw) To: Gary Guo, Boqun Feng Cc: Nathan Chancellor, Bert Karwatzki, Harry Yoo, linux-kernel, linux-next, Alice Ryhl, Greg Kroah-Hartman, rust-for-linux On 8/3/26 17:32, Gary Guo wrote: > On Mon Aug 3, 2026 at 4:10 PM BST, Vlastimil Babka (SUSE) wrote: >> On 8/3/26 16:23, Boqun Feng wrote: >>> On Mon, Aug 03, 2026 at 02:57:49PM +0100, Gary Guo wrote: >>>> >>>> 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. >>> >>>> (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 :( 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? diff --git a/include/linux/types.h b/include/linux/types.h index 79bf419c69e4..53e0adca4b9f 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -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); diff --git a/mm/slab_common.c b/mm/slab_common.c index 64845ac81b79..aecbe9b9df4c 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -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; } diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs index 684dfa242b1a..f3cdf95db12d 100644 --- a/rust/kernel/sync/poll.rs +++ b/rust/kernel/sync/poll.rs @@ -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 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-08-03 21:04 ` Vlastimil Babka (SUSE) @ 2026-08-04 10:10 ` Gary Guo 2026-08-04 10:35 ` Vlastimil Babka (SUSE) 0 siblings, 1 reply; 11+ messages in thread From: Gary Guo @ 2026-08-04 10:10 UTC (permalink / raw) To: Vlastimil Babka (SUSE), Gary Guo, Boqun Feng Cc: Nathan Chancellor, Bert Karwatzki, Harry Yoo, linux-kernel, linux-next, Alice Ryhl, Greg Kroah-Hartman, rust-for-linux On Mon Aug 3, 2026 at 10:04 PM BST, Vlastimil Babka (SUSE) wrote: > On 8/3/26 17:32, Gary Guo wrote: >> On Mon Aug 3, 2026 at 4:10 PM BST, Vlastimil Babka (SUSE) wrote: >>> On 8/3/26 16:23, Boqun Feng wrote: >>>> On Mon, Aug 03, 2026 at 02:57:49PM +0100, Gary Guo wrote: >>>>> >>>>> 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. >>>> >>>>> (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 :( > > 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 > 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? > > diff --git a/include/linux/types.h b/include/linux/types.h > index 79bf419c69e4..53e0adca4b9f 100644 > --- a/include/linux/types.h > +++ b/include/linux/types.h > @@ -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); > diff --git a/mm/slab_common.c b/mm/slab_common.c > index 64845ac81b79..aecbe9b9df4c 100644 > --- a/mm/slab_common.c > +++ b/mm/slab_common.c > @@ -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; > } > > diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs > index 684dfa242b1a..f3cdf95db12d 100644 > --- a/rust/kernel/sync/poll.rs > +++ b/rust/kernel/sync/poll.rs > @@ -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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: rust compile failure in next-20260730 2026-08-04 10:10 ` Gary Guo @ 2026-08-04 10:35 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 11+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-08-04 10:35 UTC (permalink / raw) To: Gary Guo, Boqun Feng Cc: Nathan Chancellor, Bert Karwatzki, Harry Yoo, linux-kernel, linux-next, Alice Ryhl, Greg Kroah-Hartman, rust-for-linux, Miguel Ojeda, Mark Brown On 8/4/26 12:10, Gary Guo wrote: > On Mon Aug 3, 2026 at 10:04 PM BST, Vlastimil Babka (SUSE) wrote: >> On 8/3/26 17:32, Gary Guo wrote: >>> On Mon Aug 3, 2026 at 4:10 PM BST, Vlastimil Babka (SUSE) wrote: >>>> On 8/3/26 16:23, Boqun Feng wrote: >>>>> On Mon, Aug 03, 2026 at 02:57:49PM +0100, Gary Guo wrote: >>>>>> >>>>>> 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. >>>>> >>>>>> (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 :( >> >> 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. > Best, > Gary > >> 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? >> >> diff --git a/include/linux/types.h b/include/linux/types.h >> index 79bf419c69e4..53e0adca4b9f 100644 >> --- a/include/linux/types.h >> +++ b/include/linux/types.h >> @@ -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); >> diff --git a/mm/slab_common.c b/mm/slab_common.c >> index 64845ac81b79..aecbe9b9df4c 100644 >> --- a/mm/slab_common.c >> +++ b/mm/slab_common.c >> @@ -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; >> } >> >> diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs >> index 684dfa242b1a..f3cdf95db12d 100644 >> --- a/rust/kernel/sync/poll.rs >> +++ b/rust/kernel/sync/poll.rs >> @@ -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 > > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-08-04 10:35 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-31 12:28 rust compile failure in next-20260730 Bert Karwatzki 2026-07-31 13:19 ` Thorsten Leemhuis 2026-07-31 13:48 ` Luna Jernberg 2026-07-31 19:25 ` Nathan Chancellor 2026-08-03 13:57 ` Gary Guo 2026-08-03 14:23 ` Boqun Feng 2026-08-03 15:10 ` Vlastimil Babka (SUSE) 2026-08-03 15:32 ` Gary Guo 2026-08-03 21:04 ` Vlastimil Babka (SUSE) 2026-08-04 10:10 ` Gary Guo 2026-08-04 10:35 ` Vlastimil Babka (SUSE)
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.