Linux-Next discussions
 help / color / mirror / Atom feed
From: Boqun Feng <boqun@kernel.org>
To: Gary Guo <gary@garyguo.net>
Cc: Nathan Chancellor <nathan@kernel.org>,
	Bert Karwatzki <spasswolf@web.de>, Harry Yoo <harry@kernel.org>,
	linux-kernel@vger.kernel.org, linux-next@vger.kernel.org,
	Vlastimil Babka <vbabka@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	rust-for-linux@vger.kernel.org
Subject: Re: rust compile failure in next-20260730
Date: Mon, 3 Aug 2026 07:23:40 -0700	[thread overview]
Message-ID: <anCkbMyUIscmAheK@tardis.local> (raw)
In-Reply-To: <DKFD0ZKHC2I8.19PUYUR6N6KFN@garyguo.net>

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
> 

  reply	other threads:[~2026-08-03 14:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=anCkbMyUIscmAheK@tardis.local \
    --to=boqun@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=harry@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=spasswolf@web.de \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox