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

From: Alice Ryhl

Date: Fri Jul 31 2026 - 17:16:27 EST


On Fri, Jul 31, 2026 at 10:07 PM Boqun Feng <boqun@xxxxxxxxxx> wrote:
>
> On Fri, Jul 31, 2026 at 09:56:44AM +0200, Miguel Ojeda wrote:
> > On Thu, 30 Jul 2026 15:38:48 +0100 Mark Brown <broonie@xxxxxxxxxx> 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 <aliceryhl@xxxxxxxxxx>
> > Cc: Boqun Feng <boqun@xxxxxxxxxx>
> > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > Cc: Harry Yoo (Oracle) <harry@xxxxxxxxxx>
> > Cc: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> >
>
> 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?

I like Nathan's fix as well.

Not sure if it needs to be done in the merge commit, or if we can
apply it as a patch to char-misc despite the unknown CFG_*?

Alice