Re: linux-next: manual merge of the slab tree with the rcu tree

Boqun Feng <[email protected]> Fri, 31 Jul 2026 13:07:43 -0700
Newsgroups org.kernel.vger.linux-next,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Fri, Jul 31, 2026 at 09:56:44AM +0200, Miguel Ojeda wrote:
> On Thu, 30 Jul 2026 15:38:48 +0100 Mark Brown <[email protected]> wrote:
> >
> > Today's linux-next merge of the slab tree got a conflict in:
> >
> >   mm/slab_common.c
> >
> > between commit:
> >
> >   736084507faa3 ("rcu: Rename struct rcu_gp_oldstate to rcu_gp_seq")
> >
> > from the rcu tree and commit:
> >
> >   bdd0cc9f0ffc3 ("mm/slab: introduce struct kvfree_rcu_head for kvfree_rcu batching")
> >
> > from the slab tree.
> 
> The slab one semantically conflicts as well with commit:
> 
>   e5e86df8b666 ("rust: poll: use kfree_rcu() for PollCondVar")
> 
> from the char-misc tree:
> 
>     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
>          --> rust/bindings/bindings_generated.rs:90407:12
>           |
>     90407 |     pub fn kvfree_call_rcu(head: *mut kvfree_rcu_head, ptr: *mut ffi::c_void);
>           |            ^^^^^^^^^^^^^^^
> 
> The C API was not meant to have a visible effect, but we don't use the
> `kvfree_rcu()` macro, so we notice the change. We can add a similar cast
> to the C side:
> 
>     diff --git a/rust/kernel/sync/poll.rs b/rust/kernel/sync/poll.rs
>     index 684dfa242b1a..79d7e08215b0 100644
>     --- a/rust/kernel/sync/poll.rs
>     +++ b/rust/kernel/sync/poll.rs
>     @@ -172,6 +172,6 @@ fn drop(&mut self) {
>              unsafe { bindings::__wake_up_pollfree((*ptr).inner.inner.wait_queue_head.get()) };
> 
>              // SAFETY: This was allocated using `KBox::pin_init`, so it can be freed with `kvfree`.
>     -        unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get(), ptr.cast::<ffi::c_void>()) };
>     +        unsafe { bindings::kvfree_call_rcu((*ptr).rcu.get().cast(), ptr.cast::<ffi::c_void>()) };
>          }
>      }
> 
> Clippy doesn't complain about the "unneeded" `cast()` under
> `CONFIG_KVFREE_RCU_BATCHED=n`, so it should be fine.
> 
> Cc: Alice Ryhl <[email protected]>
> Cc: Boqun Feng <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Harry Yoo (Oracle) <[email protected]>
> Cc: Vlastimil Babka (SUSE) <[email protected]>
> 

Cc Nathan & Bert because of:

	https://lore.kernel.org/rust-for-linux/20260731192522.GA1014697@ax162/

I actually prefer Nathan's fix, since it's more explicit about the
kvfree_rcu_head requirement. Alice & Miguel, thoughts?

Regards,
Boqun

> Cheers,
> Miguel