rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
       [not found] <202510030449.VfSaAjvd-lkp@intel.com>
@ 2025-10-02 21:19 ` Andrew Morton
  2025-10-02 21:42   ` Miguel Ojeda
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Morton @ 2025-10-02 21:19 UTC (permalink / raw)
  To: kernel test robot
  Cc: Jakub Acs, llvm, oe-kbuild-all, Linux Memory Management List,
	rust-for-linux

On Fri, 3 Oct 2025 04:52:48 +0800 kernel test robot <lkp@intel.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   7396732143a22b42bb97710173d598aaf50daa89
> commit: 8355c2312fdfe590a296b8abf9414ab7ecb49d1d [13069/13300] mm/ksm: fix flag-dropping behavior in ksm_madvise
> config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20251003/202510030449.VfSaAjvd-lkp@intel.com/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251003/202510030449.VfSaAjvd-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202510030449.VfSaAjvd-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
> >> error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
>    --> rust/kernel/mm/virt.rs:471:49
>    |
>    471  |     pub const MERGEABLE: vm_flags_t = bindings::VM_MERGEABLE as vm_flags_t;
>    |                                                 ^^^^^^^^^^^^ help: a constant with a similar name exists: `MMF_VM_MERGEABLE`
>    |
>    ::: rust/bindings/bindings_generated.rs:7936:1
>    |
>    7936 | pub const MMF_VM_MERGEABLE: u32 = 16;
>    | ------------------------------- similarly named constant `MMF_VM_MERGEABLE` defined here

No idea.  Let me cc rust-for-linux.

It's a one-line patch:

--- a/include/linux/mm.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise
+++ a/include/linux/mm.h
@@ -296,7 +296,7 @@ extern unsigned int kobjsize(const void
 #define VM_MIXEDMAP	0x10000000	/* Can contain "struct page" and pure PFN pages */
 #define VM_HUGEPAGE	0x20000000	/* MADV_HUGEPAGE marked this vma */
 #define VM_NOHUGEPAGE	0x40000000	/* MADV_NOHUGEPAGE marked this vma */
-#define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
+#define VM_MERGEABLE	BIT(31)		/* KSM may merge identical pages */
 
 #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
 #define VM_HIGH_ARCH_BIT_0	32	/* bit only usable on 64-bit architectures */
_


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 21:19 ` [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings` Andrew Morton
@ 2025-10-02 21:42   ` Miguel Ojeda
  2025-10-02 21:51     ` John Hubbard
  2025-10-02 22:27     ` Andrew Morton
  0 siblings, 2 replies; 14+ messages in thread
From: Miguel Ojeda @ 2025-10-02 21:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Thu, Oct 2, 2025 at 11:19 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> No idea.  Let me cc rust-for-linux.
>
> It's a one-line patch:
>
> --- a/include/linux/mm.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise
> +++ a/include/linux/mm.h
> @@ -296,7 +296,7 @@ extern unsigned int kobjsize(const void
>  #define VM_MIXEDMAP    0x10000000      /* Can contain "struct page" and pure PFN pages */
>  #define VM_HUGEPAGE    0x20000000      /* MADV_HUGEPAGE marked this vma */
>  #define VM_NOHUGEPAGE  0x40000000      /* MADV_NOHUGEPAGE marked this vma */
> -#define VM_MERGEABLE   0x80000000      /* KSM may merge identical pages */
> +#define VM_MERGEABLE   BIT(31)         /* KSM may merge identical pages */
>
>  #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
>  #define VM_HIGH_ARCH_BIT_0     32      /* bit only usable on 64-bit architectures */

Yeah, non-trivial macros confuse `bindgen`.

For the moment, you can do e.g. [1].

Other times, we have changed `#define`s into `enum`s -- that also works.

I hope that helps.

Cheers,
Miguel

[1]

diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index 5128e2f12038..918f4c74067b 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -106,3 +106,5 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;

 const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
 const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
+
+const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 21:42   ` Miguel Ojeda
@ 2025-10-02 21:51     ` John Hubbard
  2025-10-02 22:11       ` Miguel Ojeda
  2025-10-02 22:27     ` Andrew Morton
  1 sibling, 1 reply; 14+ messages in thread
From: John Hubbard @ 2025-10-02 21:51 UTC (permalink / raw)
  To: Miguel Ojeda, Andrew Morton
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On 10/2/25 2:42 PM, Miguel Ojeda wrote:
> On Thu, Oct 2, 2025 at 11:19 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>>
>> No idea.  Let me cc rust-for-linux.
>>
>> It's a one-line patch:
>>
>> --- a/include/linux/mm.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise
>> +++ a/include/linux/mm.h
>> @@ -296,7 +296,7 @@ extern unsigned int kobjsize(const void
>>  #define VM_MIXEDMAP    0x10000000      /* Can contain "struct page" and pure PFN pages */
>>  #define VM_HUGEPAGE    0x20000000      /* MADV_HUGEPAGE marked this vma */
>>  #define VM_NOHUGEPAGE  0x40000000      /* MADV_NOHUGEPAGE marked this vma */
>> -#define VM_MERGEABLE   0x80000000      /* KSM may merge identical pages */
>> +#define VM_MERGEABLE   BIT(31)         /* KSM may merge identical pages */
>>
>>  #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
>>  #define VM_HIGH_ARCH_BIT_0     32      /* bit only usable on 64-bit architectures */
> 
> Yeah, non-trivial macros confuse `bindgen`.
> 
> For the moment, you can do e.g. [1].
> 
> Other times, we have changed `#define`s into `enum`s -- that also works.

It seems like bindgen's --clang-macro-fallback argument can avoid the
entire class of problems, is there some reason Rust for Linux has avoided
that option?

Although, in order to make it work with fixdep, additional somewhat complex
build system changes are required. I've got it to almost work locally just
now... :)

thanks,
John Hubbard

> 
> I hope that helps.
> 
> Cheers,
> Miguel
> 
> [1]
> 
> diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
> index 5128e2f12038..918f4c74067b 100644
> --- a/rust/bindings/bindings_helper.h
> +++ b/rust/bindings/bindings_helper.h
> @@ -106,3 +106,5 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;
> 
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> +
> +const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 21:51     ` John Hubbard
@ 2025-10-02 22:11       ` Miguel Ojeda
  0 siblings, 0 replies; 14+ messages in thread
From: Miguel Ojeda @ 2025-10-02 22:11 UTC (permalink / raw)
  To: John Hubbard
  Cc: Andrew Morton, kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux, John Baublitz

On Thu, Oct 2, 2025 at 11:52 PM John Hubbard <jhubbard@nvidia.com> wrote:
>
> It seems like bindgen's --clang-macro-fallback argument can avoid the
> entire class of problems, is there some reason Rust for Linux has avoided
> that option?
>
> Although, in order to make it work with fixdep, additional somewhat complex
> build system changes are required. I've got it to almost work locally just
> now... :)

I am glad you ask! ;)

We were the ones pushing for the option -- John implemented a
workaround that I suggested, with optimizations on performance:

     https://github.com/rust-lang/rust-bindgen/issues/753#issuecomment-1674833380
    https://github.com/rust-lang/rust-bindgen/pull/2779

I think the last time I tried it was early this year -- here is the
test patch I had:

    https://lore.kernel.org/rust-for-linux/CANiq72m20pom+B9EmWO+91E8fjbMEob3JmvHRQ6UaXe_JmatfA@mail.gmail.com/

It is in my backlog to go back to the option, test it again and so on.
In any case, note that we will need to increase the minimum, so it may
take some time.

Further context at:

    https://github.com/Rust-for-Linux/linux/issues/353

I hope that clarifies.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 21:42   ` Miguel Ojeda
  2025-10-02 21:51     ` John Hubbard
@ 2025-10-02 22:27     ` Andrew Morton
  2025-10-02 22:32       ` Alice Ryhl
  2025-10-02 22:39       ` Miguel Ojeda
  1 sibling, 2 replies; 14+ messages in thread
From: Andrew Morton @ 2025-10-02 22:27 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Thu, 2 Oct 2025 23:42:59 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> On Thu, Oct 2, 2025 at 11:19 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > No idea.  Let me cc rust-for-linux.
> >
> > It's a one-line patch:
> >
> > --- a/include/linux/mm.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise
> > +++ a/include/linux/mm.h
> > @@ -296,7 +296,7 @@ extern unsigned int kobjsize(const void
> >  #define VM_MIXEDMAP    0x10000000      /* Can contain "struct page" and pure PFN pages */
> >  #define VM_HUGEPAGE    0x20000000      /* MADV_HUGEPAGE marked this vma */
> >  #define VM_NOHUGEPAGE  0x40000000      /* MADV_NOHUGEPAGE marked this vma */
> > -#define VM_MERGEABLE   0x80000000      /* KSM may merge identical pages */
> > +#define VM_MERGEABLE   BIT(31)         /* KSM may merge identical pages */
> >
> >  #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
> >  #define VM_HIGH_ARCH_BIT_0     32      /* bit only usable on 64-bit architectures */
> 
> Yeah, non-trivial macros confuse `bindgen`.
> 
> For the moment, you can do e.g. [1].
> 
> Other times, we have changed `#define`s into `enum`s -- that also works.
> 
> ...
>
> --- a/rust/bindings/bindings_helper.h
> +++ b/rust/bindings/bindings_helper.h
> @@ -106,3 +106,5 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;
> 
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> +
> +const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;

Sorry, this is rather annoying.  Rust is breaking the build for a very
simple patch.  Many developers aren't rust-enabled and probably aren't
even able to test a fix - my attempt to get a rust build setup working
didn't end happily.

Jakub's patch fixes a kernel crash and needs to be merged into mainline
and -stable reasonably soon.  But that is now blocked until someone who
knows how to fix this error and how to test it gets down and does those
things.

Jakub's patch is present in current linux-next.  Can someone please
send us a fix?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 22:27     ` Andrew Morton
@ 2025-10-02 22:32       ` Alice Ryhl
  2025-10-02 22:39       ` Miguel Ojeda
  1 sibling, 0 replies; 14+ messages in thread
From: Alice Ryhl @ 2025-10-02 22:32 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Miguel Ojeda, kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Fri, Oct 3, 2025 at 12:28 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Thu, 2 Oct 2025 23:42:59 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
>
> > On Thu, Oct 2, 2025 at 11:19 PM Andrew Morton <akpm@linux-foundation.org> wrote:
> > >
> > > No idea.  Let me cc rust-for-linux.
> > >
> > > It's a one-line patch:
> > >
> > > --- a/include/linux/mm.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise
> > > +++ a/include/linux/mm.h
> > > @@ -296,7 +296,7 @@ extern unsigned int kobjsize(const void
> > >  #define VM_MIXEDMAP    0x10000000      /* Can contain "struct page" and pure PFN pages */
> > >  #define VM_HUGEPAGE    0x20000000      /* MADV_HUGEPAGE marked this vma */
> > >  #define VM_NOHUGEPAGE  0x40000000      /* MADV_NOHUGEPAGE marked this vma */
> > > -#define VM_MERGEABLE   0x80000000      /* KSM may merge identical pages */
> > > +#define VM_MERGEABLE   BIT(31)         /* KSM may merge identical pages */
> > >
> > >  #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
> > >  #define VM_HIGH_ARCH_BIT_0     32      /* bit only usable on 64-bit architectures */
> >
> > Yeah, non-trivial macros confuse `bindgen`.
> >
> > For the moment, you can do e.g. [1].
> >
> > Other times, we have changed `#define`s into `enum`s -- that also works.
> >
> > ...
> >
> > --- a/rust/bindings/bindings_helper.h
> > +++ b/rust/bindings/bindings_helper.h
> > @@ -106,3 +106,5 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;
> >
> >  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
> >  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> > +
> > +const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
>
> Sorry, this is rather annoying.  Rust is breaking the build for a very
> simple patch.  Many developers aren't rust-enabled and probably aren't
> even able to test a fix - my attempt to get a rust build setup working
> didn't end happily.
>
> Jakub's patch fixes a kernel crash and needs to be merged into mainline
> and -stable reasonably soon.  But that is now blocked until someone who
> knows how to fix this error and how to test it gets down and does those
> things.
>
> Jakub's patch is present in current linux-next.  Can someone please
> send us a fix?

I don't have my git-send-mail-capable laptop with me right now, but
the diff Miguel shared that adds one line to
rust/bindings/bindings_helper.h will fix this build error.

Alice

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 22:27     ` Andrew Morton
  2025-10-02 22:32       ` Alice Ryhl
@ 2025-10-02 22:39       ` Miguel Ojeda
  2025-10-02 22:43         ` Andrew Morton
  1 sibling, 1 reply; 14+ messages in thread
From: Miguel Ojeda @ 2025-10-02 22:39 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Fri, Oct 3, 2025 at 12:27 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> Sorry, this is rather annoying.  Rust is breaking the build for a very
> simple patch.  Many developers aren't rust-enabled and probably aren't
> even able to test a fix - my attempt to get a rust build setup working
> didn't end happily.
>
> Jakub's patch fixes a kernel crash and needs to be merged into mainline
> and -stable reasonably soon.  But that is now blocked until someone who
> knows how to fix this error and how to test it gets down and does those
> things.
>
> Jakub's patch is present in current linux-next.  Can someone please
> send us a fix?

I am not sure I follow -- the diff I gave you should work.

If you have a branch you want me to test and/or give you a formal
patch on top of that or similar, I can do that.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 22:39       ` Miguel Ojeda
@ 2025-10-02 22:43         ` Andrew Morton
  2025-10-02 22:50           ` Alice Ryhl
                             ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Andrew Morton @ 2025-10-02 22:43 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Fri, 3 Oct 2025 00:39:16 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> On Fri, Oct 3, 2025 at 12:27 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > Sorry, this is rather annoying.  Rust is breaking the build for a very
> > simple patch.  Many developers aren't rust-enabled and probably aren't
> > even able to test a fix - my attempt to get a rust build setup working
> > didn't end happily.
> >
> > Jakub's patch fixes a kernel crash and needs to be merged into mainline
> > and -stable reasonably soon.  But that is now blocked until someone who
> > knows how to fix this error and how to test it gets down and does those
> > things.
> >
> > Jakub's patch is present in current linux-next.  Can someone please
> > send us a fix?
> 
> I am not sure I follow -- the diff I gave you should work.

It would be nice if someone were to test it!

> If you have a branch you want me to test and/or give you a formal
> patch on top of that or similar, I can do that.

Thanks.  As mentioned, today's linux-next is where the problem is being
observed.

I'm queueing the below as a fixup against Jakub's original.  This should
appear in tomorrow's linux-next.  Or the day after - it's a timezone
thing.

From: Andrew Morton <akpm@linux-foundation.org>
Subject: mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
Date: Thu Oct  2 03:37:47 PM PDT 2025

Rust bindgen wasn't able to handle the BIT() macro.  Add a helper (from
Miguel) to fix this.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202510030449.VfSaAjvd-lkp@intel.com/
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jakub Acs <acsjakub@amazon.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: SeongJae Park <sj@kernel.org>
Cc: Xu Xin <xu.xin16@zte.com.cn>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 rust/bindings/bindings_helper.h |    1 +
 1 file changed, 1 insertion(+)

--- a/rust/bindings/bindings_helper.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
+++ a/rust/bindings/bindings_helper.h
@@ -99,3 +99,4 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRE
 
 const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
 const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
+const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
_


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 22:43         ` Andrew Morton
@ 2025-10-02 22:50           ` Alice Ryhl
  2025-10-02 22:50           ` Miguel Ojeda
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Alice Ryhl @ 2025-10-02 22:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Miguel Ojeda, kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Fri, Oct 3, 2025 at 12:43 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Fri, 3 Oct 2025 00:39:16 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
>
> > On Fri, Oct 3, 2025 at 12:27 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> > >
> > > Sorry, this is rather annoying.  Rust is breaking the build for a very
> > > simple patch.  Many developers aren't rust-enabled and probably aren't
> > > even able to test a fix - my attempt to get a rust build setup working
> > > didn't end happily.
> > >
> > > Jakub's patch fixes a kernel crash and needs to be merged into mainline
> > > and -stable reasonably soon.  But that is now blocked until someone who
> > > knows how to fix this error and how to test it gets down and does those
> > > things.
> > >
> > > Jakub's patch is present in current linux-next.  Can someone please
> > > send us a fix?
> >
> > I am not sure I follow -- the diff I gave you should work.
>
> It would be nice if someone were to test it!
>
> > If you have a branch you want me to test and/or give you a formal
> > patch on top of that or similar, I can do that.
>
> Thanks.  As mentioned, today's linux-next is where the problem is being
> observed.
>
> I'm queueing the below as a fixup against Jakub's original.  This should
> appear in tomorrow's linux-next.  Or the day after - it's a timezone
> thing.
>
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> Date: Thu Oct  2 03:37:47 PM PDT 2025
>
> Rust bindgen wasn't able to handle the BIT() macro.  Add a helper (from
> Miguel) to fix this.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202510030449.VfSaAjvd-lkp@intel.com/
> Cc: Axel Rasmussen <axelrasmussen@google.com>
> Cc: Chengming Zhou <chengming.zhou@linux.dev>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Jakub Acs <acsjakub@amazon.de>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: SeongJae Park <sj@kernel.org>
> Cc: Xu Xin <xu.xin16@zte.com.cn>
> Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> Cc: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
>  rust/bindings/bindings_helper.h |    1 +
>  1 file changed, 1 insertion(+)
>
> --- a/rust/bindings/bindings_helper.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> +++ a/rust/bindings/bindings_helper.h
> @@ -99,3 +99,4 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRE
>
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> +const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;

Tested-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 22:43         ` Andrew Morton
  2025-10-02 22:50           ` Alice Ryhl
@ 2025-10-02 22:50           ` Miguel Ojeda
  2025-10-02 23:16           ` Miguel Ojeda
  2025-10-03  0:24           ` John Hubbard
  3 siblings, 0 replies; 14+ messages in thread
From: Miguel Ojeda @ 2025-10-02 22:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Fri, Oct 3, 2025 at 12:43 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> It would be nice if someone were to test it!

I did...

(but on a different branch, by applying your diff, reproducing the
issue, and then my diff)

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 22:43         ` Andrew Morton
  2025-10-02 22:50           ` Alice Ryhl
  2025-10-02 22:50           ` Miguel Ojeda
@ 2025-10-02 23:16           ` Miguel Ojeda
  2025-10-03  0:24           ` John Hubbard
  3 siblings, 0 replies; 14+ messages in thread
From: Miguel Ojeda @ 2025-10-02 23:16 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On Fri, Oct 3, 2025 at 12:43 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> Thanks.  As mentioned, today's linux-next is where the problem is being
> observed.

You're welcome -- yeah, I see it in my one of my CIs (the
rust.docs.kernel.org that runs more often), but really, I think we
should help you enable the Rust build -- you take patches for many
things across the tree, so that would be very useful...

Nowadays it should be fairly easy to enable, i.e. even the packages
from some distros work.

I have build-tested the patch on top of mm-hotfixes-unstable now too
(since I don't see it applied yet), so please feel free to pick tags
like:

Tested-by: Miguel Ojeda <ojeda@kernel.org>

Or even:

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

I test every day -next, so I will see this in my 20251002 run and will
notice if it doesn't go away.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-02 22:43         ` Andrew Morton
                             ` (2 preceding siblings ...)
  2025-10-02 23:16           ` Miguel Ojeda
@ 2025-10-03  0:24           ` John Hubbard
  2025-10-07  7:07             ` Jakub Acs
  3 siblings, 1 reply; 14+ messages in thread
From: John Hubbard @ 2025-10-03  0:24 UTC (permalink / raw)
  To: Andrew Morton, Miguel Ojeda
  Cc: kernel test robot, Jakub Acs, llvm, oe-kbuild-all,
	Linux Memory Management List, rust-for-linux

On 10/2/25 3:43 PM, Andrew Morton wrote:
> On Fri, 3 Oct 2025 00:39:16 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
>> On Fri, Oct 3, 2025 at 12:27 AM Andrew Morton <akpm@linux-foundation.org> wrote:
...
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> Date: Thu Oct  2 03:37:47 PM PDT 2025
> 
> Rust bindgen wasn't able to handle the BIT() macro.  Add a helper (from
> Miguel) to fix this.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202510030449.VfSaAjvd-lkp@intel.com/
> Cc: Axel Rasmussen <axelrasmussen@google.com>
> Cc: Chengming Zhou <chengming.zhou@linux.dev>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Jakub Acs <acsjakub@amazon.de>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: SeongJae Park <sj@kernel.org>
> Cc: Xu Xin <xu.xin16@zte.com.cn>
> Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> Cc: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  rust/bindings/bindings_helper.h |    1 +
>  1 file changed, 1 insertion(+)
> 
> --- a/rust/bindings/bindings_helper.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> +++ a/rust/bindings/bindings_helper.h
> @@ -99,3 +99,4 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRE
>  
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
>  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> +const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
> _

Yes, this fixes the build on my system too, so:

Tested-by: John Hubbard <jhubbard@nvidia.com>

...of course, we'll have to undo this later, as part of the fix
for the Rust for Linux build system, to handle BIT() and similar
macros in bindgen.


thanks,
-- 
John Hubbard


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-03  0:24           ` John Hubbard
@ 2025-10-07  7:07             ` Jakub Acs
  2025-10-07  7:15               ` Alice Ryhl
  0 siblings, 1 reply; 14+ messages in thread
From: Jakub Acs @ 2025-10-07  7:07 UTC (permalink / raw)
  To: John Hubbard
  Cc: Andrew Morton, Miguel Ojeda, kernel test robot, llvm,
	oe-kbuild-all, Linux Memory Management List, rust-for-linux

On Thu, Oct 02, 2025 at 05:24:48PM -0700, John Hubbard wrote:
> On 10/2/25 3:43 PM, Andrew Morton wrote:
> > On Fri, 3 Oct 2025 00:39:16 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
> >> On Fri, Oct 3, 2025 at 12:27 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> ...
> > From: Andrew Morton <akpm@linux-foundation.org>
> > Subject: mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> > Date: Thu Oct  2 03:37:47 PM PDT 2025
> > 
> > Rust bindgen wasn't able to handle the BIT() macro.  Add a helper (from
> > Miguel) to fix this.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202510030449.VfSaAjvd-lkp@intel.com/
> > Cc: Axel Rasmussen <axelrasmussen@google.com>
> > Cc: Chengming Zhou <chengming.zhou@linux.dev>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Jakub Acs <acsjakub@amazon.de>
> > Cc: Peter Xu <peterx@redhat.com>
> > Cc: SeongJae Park <sj@kernel.org>
> > Cc: Xu Xin <xu.xin16@zte.com.cn>
> > Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> > Cc: Alice Ryhl <aliceryhl@google.com>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > ---
> > 
> >  rust/bindings/bindings_helper.h |    1 +
> >  1 file changed, 1 insertion(+)
> > 
> > --- a/rust/bindings/bindings_helper.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> > +++ a/rust/bindings/bindings_helper.h
> > @@ -99,3 +99,4 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRE
> >  
> >  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
> >  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> > +const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
> > _
> 
> Yes, this fixes the build on my system too, so:
> 
> Tested-by: John Hubbard <jhubbard@nvidia.com>
> 
> ...of course, we'll have to undo this later, as part of the fix
> for the Rust for Linux build system, to handle BIT() and similar
> macros in bindgen.
> 

Hi, 

sorry for the issues this has caused. We're also changing the other
defines to BIT() for consistency, it was applied to mm-new in [1]. I
assume this will have the same breaking effect. Not sure what is the
solution - whether to wait for the fix mentioned by John or add similar
defintions to a/rust/bindings/bindings_helper.h for all consts?

[1]: https://lore.kernel.org/all/20251002202112.C2293C4CEF4@smtp.kernel.org/

Kind Regards,
Jakub



Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christian Schlaeger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings`
  2025-10-07  7:07             ` Jakub Acs
@ 2025-10-07  7:15               ` Alice Ryhl
  0 siblings, 0 replies; 14+ messages in thread
From: Alice Ryhl @ 2025-10-07  7:15 UTC (permalink / raw)
  To: Jakub Acs
  Cc: John Hubbard, Andrew Morton, Miguel Ojeda, kernel test robot,
	llvm, oe-kbuild-all, Linux Memory Management List, rust-for-linux

On Tue, Oct 7, 2025 at 9:07 AM Jakub Acs <acsjakub@amazon.de> wrote:
>
> On Thu, Oct 02, 2025 at 05:24:48PM -0700, John Hubbard wrote:
> > On 10/2/25 3:43 PM, Andrew Morton wrote:
> > > On Fri, 3 Oct 2025 00:39:16 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
> > >> On Fri, Oct 3, 2025 at 12:27 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> > ...
> > > From: Andrew Morton <akpm@linux-foundation.org>
> > > Subject: mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> > > Date: Thu Oct  2 03:37:47 PM PDT 2025
> > >
> > > Rust bindgen wasn't able to handle the BIT() macro.  Add a helper (from
> > > Miguel) to fix this.
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202510030449.VfSaAjvd-lkp@intel.com/
> > > Cc: Axel Rasmussen <axelrasmussen@google.com>
> > > Cc: Chengming Zhou <chengming.zhou@linux.dev>
> > > Cc: David Hildenbrand <david@redhat.com>
> > > Cc: Jakub Acs <acsjakub@amazon.de>
> > > Cc: Peter Xu <peterx@redhat.com>
> > > Cc: SeongJae Park <sj@kernel.org>
> > > Cc: Xu Xin <xu.xin16@zte.com.cn>
> > > Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> > > Cc: Alice Ryhl <aliceryhl@google.com>
> > > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > > ---
> > >
> > >  rust/bindings/bindings_helper.h |    1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > --- a/rust/bindings/bindings_helper.h~mm-ksm-fix-flag-dropping-behavior-in-ksm_madvise-fix
> > > +++ a/rust/bindings/bindings_helper.h
> > > @@ -99,3 +99,4 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRE
> > >
> > >  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
> > >  const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> > > +const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
> > > _
> >
> > Yes, this fixes the build on my system too, so:
> >
> > Tested-by: John Hubbard <jhubbard@nvidia.com>
> >
> > ...of course, we'll have to undo this later, as part of the fix
> > for the Rust for Linux build system, to handle BIT() and similar
> > macros in bindgen.
> >
>
> Hi,
>
> sorry for the issues this has caused. We're also changing the other
> defines to BIT() for consistency, it was applied to mm-new in [1]. I
> assume this will have the same breaking effect. Not sure what is the
> solution - whether to wait for the fix mentioned by John or add similar
> defintions to a/rust/bindings/bindings_helper.h for all consts?
>
> [1]: https://lore.kernel.org/all/20251002202112.C2293C4CEF4@smtp.kernel.org/

You have two options: either add all of the constants to
bindings_helper.h, or use an enum similar to commit 3634783be125
("binder: use enum for binder ioctls").

Regarding John's mention, don't expect that for a while. It requires
support in bindgen, which is shipped by your distribution, not Linux.
Therefore, it takes time for improvements to become available to
everyone.

Alice

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-10-07  7:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <202510030449.VfSaAjvd-lkp@intel.com>
2025-10-02 21:19 ` [linux-next:master 13069/13300] error[E0425]: cannot find value `VM_MERGEABLE` in crate `bindings` Andrew Morton
2025-10-02 21:42   ` Miguel Ojeda
2025-10-02 21:51     ` John Hubbard
2025-10-02 22:11       ` Miguel Ojeda
2025-10-02 22:27     ` Andrew Morton
2025-10-02 22:32       ` Alice Ryhl
2025-10-02 22:39       ` Miguel Ojeda
2025-10-02 22:43         ` Andrew Morton
2025-10-02 22:50           ` Alice Ryhl
2025-10-02 22:50           ` Miguel Ojeda
2025-10-02 23:16           ` Miguel Ojeda
2025-10-03  0:24           ` John Hubbard
2025-10-07  7:07             ` Jakub Acs
2025-10-07  7:15               ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).