rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
       [not found] <20251002081247.51255-37-byungchul@sk.com>
@ 2025-10-02 10:06 ` Guangbo Cui
  2025-10-02 10:27   ` Danilo Krummrich
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Guangbo Cui @ 2025-10-02 10:06 UTC (permalink / raw)
  To: byungchul
  Cc: Liam.Howlett, amir73il, andi.shyti, andrii, boqun.feng, bsegall,
	gregkh, linaro-mm-sig, link, linux-kernel, mark.rutland,
	masahiroy, mathieu.desnoyers, matthew.brost, max.byungchul.park,
	mcgrof, melissa.srw, mgorman, mhocko, minchan, oleg, paulmck,
	penberg, peterz, petr.pavlu, torvalds, vincent.guittot, will,
	yeoreum.yun, ysk, rust-for-linux, ojeda, gary, lossin, a.hindborg,
	aliceryhl, dakr, alex.gaynor, bjorn3_gh, Guangbo Cui

> -extern void wait_for_completion(struct completion *);
> -extern void wait_for_completion_io(struct completion *);
> -extern int wait_for_completion_interruptible(struct completion *x);
> -extern int wait_for_completion_killable(struct completion *x);
> -extern int wait_for_completion_state(struct completion *x, unsigned int state);
> -extern unsigned long wait_for_completion_timeout(struct completion *x,
> +extern void __wait_for_completion(struct completion *);
> +extern void __wait_for_completion_io(struct completion *);
> +extern int __wait_for_completion_interruptible(struct completion *x);
> +extern int __wait_for_completion_killable(struct completion *x);
> +extern int __wait_for_completion_state(struct completion *x, unsigned int state);
> +extern unsigned long __wait_for_completion_timeout(struct completion *x,
>  						   unsigned long timeout);
> -extern unsigned long wait_for_completion_io_timeout(struct completion *x,
> +extern unsigned long __wait_for_completion_io_timeout(struct completion *x,
>  						    unsigned long timeout);
> -extern long wait_for_completion_interruptible_timeout(
> +extern long __wait_for_completion_interruptible_timeout(
>  	struct completion *x, unsigned long timeout);
> -extern long wait_for_completion_killable_timeout(
> +extern long __wait_for_completion_killable_timeout(
>  	struct completion *x, unsigned long timeout);
>  extern bool try_wait_for_completion(struct completion *x);
>  extern bool completion_done(struct completion *x);
> @@ -139,4 +134,79 @@ extern void complete(struct completion *);
>  extern void complete_on_current_cpu(struct completion *x);
>  extern void complete_all(struct completion *);
>  
> +#define wait_for_completion(x)						\
> +({									\
> +	sdt_might_sleep_start_timeout(NULL, -1L);			\
> +	__wait_for_completion(x);					\
> +	sdt_might_sleep_end();						\
> +})

The DEPT patch series changed `wait_for_completion` into a macro.
Because bindgen cannot handle function-like macros, this caused
Rust build errors. Add a helper function to fix it.

```
error[E0425]: cannot find function `wait_for_completion` in crate `bindings`
     --> rust/kernel/sync/completion.rs:110:28
      |
  110 |         unsafe { bindings::wait_for_completion(self.as_raw()) };
      |                            ^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `__wait_for_completion`
      |
     ::: /root/linux/rust/bindings/bindings_generated.rs:33440:5
      |
33440 |     pub fn __wait_for_completion(arg1: *mut completion);
      |     ---------------------------------------------------- similarly named function `__wait_for_completion` defined here

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0425`.
```

Signed-off-by: Guangbo Cui <2407018371@qq.com>
---
 rust/helpers/completion.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rust/helpers/completion.c b/rust/helpers/completion.c
index b2443262a2ae..5bae5e749def 100644
--- a/rust/helpers/completion.c
+++ b/rust/helpers/completion.c
@@ -6,3 +6,8 @@ void rust_helper_init_completion(struct completion *x)
 {
 	init_completion(x);
 }
+
+void rust_helper_wait_for_completion(struct completion *x)
+{
+	wait_for_completion(x);
+}
-- 
2.43.0


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

* Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
  2025-10-02 10:06 ` [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function Guangbo Cui
@ 2025-10-02 10:27   ` Danilo Krummrich
  2025-11-13  1:21     ` Byungchul Park
  2025-10-02 10:39   ` Miguel Ojeda
  2025-10-02 17:27   ` Boqun Feng
  2 siblings, 1 reply; 8+ messages in thread
From: Danilo Krummrich @ 2025-10-02 10:27 UTC (permalink / raw)
  To: Guangbo Cui
  Cc: byungchul, Liam.Howlett, amir73il, andi.shyti, andrii, boqun.feng,
	bsegall, gregkh, linaro-mm-sig, link, linux-kernel, mark.rutland,
	masahiroy, mathieu.desnoyers, matthew.brost, max.byungchul.park,
	mcgrof, melissa.srw, mgorman, mhocko, minchan, oleg, paulmck,
	penberg, peterz, petr.pavlu, torvalds, vincent.guittot, will,
	yeoreum.yun, ysk, rust-for-linux, ojeda, gary, lossin, a.hindborg,
	aliceryhl, alex.gaynor, bjorn3_gh

On Thu Oct 2, 2025 at 12:06 PM CEST, Guangbo Cui wrote:
> The DEPT patch series changed `wait_for_completion` into a macro.
> Because bindgen cannot handle function-like macros, this caused
> Rust build errors. Add a helper function to fix it.

Good catch!

Given that the latest version of this series was just posted, please squash this
fix into patch "dept: assign unique dept_key to each distinct
wait_for_completion() caller" [1].

Thanks,
Danilo

[1] https://lore.kernel.org/all/20251002081247.51255-37-byungchul@sk.com/

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

* Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
  2025-10-02 10:06 ` [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function Guangbo Cui
  2025-10-02 10:27   ` Danilo Krummrich
@ 2025-10-02 10:39   ` Miguel Ojeda
  2025-10-02 16:52     ` Guangbo Cui
  2025-10-02 17:27   ` Boqun Feng
  2 siblings, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2025-10-02 10:39 UTC (permalink / raw)
  To: Guangbo Cui
  Cc: byungchul, Liam.Howlett, amir73il, andi.shyti, andrii, boqun.feng,
	bsegall, gregkh, linaro-mm-sig, link, linux-kernel, mark.rutland,
	masahiroy, mathieu.desnoyers, matthew.brost, max.byungchul.park,
	mcgrof, melissa.srw, mgorman, mhocko, minchan, oleg, paulmck,
	penberg, peterz, petr.pavlu, torvalds, vincent.guittot, will,
	yeoreum.yun, ysk, rust-for-linux, ojeda, gary, lossin, a.hindborg,
	aliceryhl, dakr, alex.gaynor, bjorn3_gh

On Thu, Oct 2, 2025 at 12:12 PM Guangbo Cui <2407018371@qq.com> wrote:
>
> The DEPT patch series changed `wait_for_completion` into a macro.

Thanks!

In general, it is useful to provide a Link: to Lore to the right patch
(i.e. context is good), and please clarify in which tree you found the
issue if any -- I don't see it in linux-next, so I imagine it is not
applied, but "changed" sounds like it was? If it was actually applied,
please also provide a Fixes: tag.

Cheers,
Miguel

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

* Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
  2025-10-02 10:39   ` Miguel Ojeda
@ 2025-10-02 16:52     ` Guangbo Cui
  0 siblings, 0 replies; 8+ messages in thread
From: Guangbo Cui @ 2025-10-02 16:52 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: byungchul, Liam.Howlett, amir73il, andi.shyti, andrii, boqun.feng,
	bsegall, gregkh, linaro-mm-sig, link, linux-kernel, mark.rutland,
	masahiroy, mathieu.desnoyers, matthew.brost, max.byungchul.park,
	mcgrof, melissa.srw, mgorman, mhocko, minchan, oleg, paulmck,
	penberg, peterz, petr.pavlu, torvalds, vincent.guittot, will,
	yeoreum.yun, ysk, rust-for-linux, ojeda, gary, lossin, a.hindborg,
	aliceryhl, dakr, alex.gaynor, bjorn3_gh

On Thu, Oct 02, 2025 at 12:39:44PM +0200, Miguel Ojeda wrote:
> issue if any -- I don't see it in linux-next, so I imagine it is not
> applied, but "changed" sounds like it was? If it was actually applied,
> please also provide a Fixes: tag.

Yeah, it's not applied yet, this should be squashed into [1].

Sorry, I forgot to check the commit message.

Thanks,
Guangbo

[1] https://lore.kernel.org/all/20251002081247.51255-37-byungchul@sk.com/


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

* Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
  2025-10-02 10:06 ` [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function Guangbo Cui
  2025-10-02 10:27   ` Danilo Krummrich
  2025-10-02 10:39   ` Miguel Ojeda
@ 2025-10-02 17:27   ` Boqun Feng
  2025-11-13  1:20     ` Byungchul Park
  2 siblings, 1 reply; 8+ messages in thread
From: Boqun Feng @ 2025-10-02 17:27 UTC (permalink / raw)
  To: Guangbo Cui
  Cc: byungchul, Liam.Howlett, amir73il, andi.shyti, andrii, bsegall,
	gregkh, linaro-mm-sig, link, linux-kernel, mark.rutland,
	masahiroy, mathieu.desnoyers, matthew.brost, max.byungchul.park,
	mcgrof, melissa.srw, mgorman, mhocko, minchan, oleg, paulmck,
	penberg, peterz, petr.pavlu, torvalds, vincent.guittot, will,
	yeoreum.yun, ysk, rust-for-linux, ojeda, gary, lossin, a.hindborg,
	aliceryhl, dakr, alex.gaynor, bjorn3_gh

On Thu, Oct 02, 2025 at 10:06:17AM +0000, Guangbo Cui wrote:
> > -extern void wait_for_completion(struct completion *);
> > -extern void wait_for_completion_io(struct completion *);
> > -extern int wait_for_completion_interruptible(struct completion *x);
> > -extern int wait_for_completion_killable(struct completion *x);
> > -extern int wait_for_completion_state(struct completion *x, unsigned int state);
> > -extern unsigned long wait_for_completion_timeout(struct completion *x,
> > +extern void __wait_for_completion(struct completion *);
> > +extern void __wait_for_completion_io(struct completion *);
> > +extern int __wait_for_completion_interruptible(struct completion *x);
> > +extern int __wait_for_completion_killable(struct completion *x);
> > +extern int __wait_for_completion_state(struct completion *x, unsigned int state);
> > +extern unsigned long __wait_for_completion_timeout(struct completion *x,
> >  						   unsigned long timeout);
> > -extern unsigned long wait_for_completion_io_timeout(struct completion *x,
> > +extern unsigned long __wait_for_completion_io_timeout(struct completion *x,
> >  						    unsigned long timeout);
> > -extern long wait_for_completion_interruptible_timeout(
> > +extern long __wait_for_completion_interruptible_timeout(
> >  	struct completion *x, unsigned long timeout);
> > -extern long wait_for_completion_killable_timeout(
> > +extern long __wait_for_completion_killable_timeout(
> >  	struct completion *x, unsigned long timeout);
> >  extern bool try_wait_for_completion(struct completion *x);
> >  extern bool completion_done(struct completion *x);
> > @@ -139,4 +134,79 @@ extern void complete(struct completion *);
> >  extern void complete_on_current_cpu(struct completion *x);
> >  extern void complete_all(struct completion *);
> >  
> > +#define wait_for_completion(x)						\
> > +({									\
> > +	sdt_might_sleep_start_timeout(NULL, -1L);			\
> > +	__wait_for_completion(x);					\
> > +	sdt_might_sleep_end();						\
> > +})
> 
> The DEPT patch series changed `wait_for_completion` into a macro.
> Because bindgen cannot handle function-like macros, this caused
> Rust build errors. Add a helper function to fix it.
> 
> ```
> error[E0425]: cannot find function `wait_for_completion` in crate `bindings`
>      --> rust/kernel/sync/completion.rs:110:28
>       |
>   110 |         unsafe { bindings::wait_for_completion(self.as_raw()) };
>       |                            ^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `__wait_for_completion`
>       |
>      ::: /root/linux/rust/bindings/bindings_generated.rs:33440:5
>       |
> 33440 |     pub fn __wait_for_completion(arg1: *mut completion);
>       |     ---------------------------------------------------- similarly named function `__wait_for_completion` defined here
> 
> error: aborting due to 1 previous error
> 
> For more information about this error, try `rustc --explain E0425`.
> ```
> 

I think Danilo already made it clear, please fold this the existing
patch. Moreover, since this patchset doesn't adjust init_completion()
from the Rust side, the result is Rust code will also use the same dept
key for completion, which has to be fixed if dept wants to be in-tree.

Regards,
Boqun

> Signed-off-by: Guangbo Cui <2407018371@qq.com>
> ---
>  rust/helpers/completion.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/rust/helpers/completion.c b/rust/helpers/completion.c
> index b2443262a2ae..5bae5e749def 100644
> --- a/rust/helpers/completion.c
> +++ b/rust/helpers/completion.c
> @@ -6,3 +6,8 @@ void rust_helper_init_completion(struct completion *x)
>  {
>  	init_completion(x);
>  }
> +
> +void rust_helper_wait_for_completion(struct completion *x)
> +{
> +	wait_for_completion(x);
> +}
> -- 
> 2.43.0
> 

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

* Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
  2025-10-02 17:27   ` Boqun Feng
@ 2025-11-13  1:20     ` Byungchul Park
  2025-11-13  2:02       ` Byungchul Park
  0 siblings, 1 reply; 8+ messages in thread
From: Byungchul Park @ 2025-11-13  1:20 UTC (permalink / raw)
  To: Boqun Feng
  Cc: Guangbo Cui, Liam.Howlett, amir73il, andi.shyti, andrii, bsegall,
	gregkh, linaro-mm-sig, link, linux-kernel, mark.rutland,
	masahiroy, mathieu.desnoyers, matthew.brost, max.byungchul.park,
	mcgrof, melissa.srw, mgorman, mhocko, minchan, oleg, paulmck,
	penberg, peterz, petr.pavlu, torvalds, vincent.guittot, will,
	yeoreum.yun, ysk, rust-for-linux, ojeda, gary, lossin, a.hindborg,
	aliceryhl, dakr, alex.gaynor, bjorn3_gh, kernel_team

On Thu, Oct 02, 2025 at 10:27:51AM -0700, Boqun Feng wrote:
> On Thu, Oct 02, 2025 at 10:06:17AM +0000, Guangbo Cui wrote:
> > > -extern void wait_for_completion(struct completion *);
> > > -extern void wait_for_completion_io(struct completion *);
> > > -extern int wait_for_completion_interruptible(struct completion *x);
> > > -extern int wait_for_completion_killable(struct completion *x);
> > > -extern int wait_for_completion_state(struct completion *x, unsigned int state);
> > > -extern unsigned long wait_for_completion_timeout(struct completion *x,
> > > +extern void __wait_for_completion(struct completion *);
> > > +extern void __wait_for_completion_io(struct completion *);
> > > +extern int __wait_for_completion_interruptible(struct completion *x);
> > > +extern int __wait_for_completion_killable(struct completion *x);
> > > +extern int __wait_for_completion_state(struct completion *x, unsigned int state);
> > > +extern unsigned long __wait_for_completion_timeout(struct completion *x,
> > >                                                unsigned long timeout);
> > > -extern unsigned long wait_for_completion_io_timeout(struct completion *x,
> > > +extern unsigned long __wait_for_completion_io_timeout(struct completion *x,
> > >                                                 unsigned long timeout);
> > > -extern long wait_for_completion_interruptible_timeout(
> > > +extern long __wait_for_completion_interruptible_timeout(
> > >     struct completion *x, unsigned long timeout);
> > > -extern long wait_for_completion_killable_timeout(
> > > +extern long __wait_for_completion_killable_timeout(
> > >     struct completion *x, unsigned long timeout);
> > >  extern bool try_wait_for_completion(struct completion *x);
> > >  extern bool completion_done(struct completion *x);
> > > @@ -139,4 +134,79 @@ extern void complete(struct completion *);
> > >  extern void complete_on_current_cpu(struct completion *x);
> > >  extern void complete_all(struct completion *);
> > >
> > > +#define wait_for_completion(x)                                             \
> > > +({                                                                 \
> > > +   sdt_might_sleep_start_timeout(NULL, -1L);                       \
> > > +   __wait_for_completion(x);                                       \
> > > +   sdt_might_sleep_end();                                          \
> > > +})
> >
> > The DEPT patch series changed `wait_for_completion` into a macro.
> > Because bindgen cannot handle function-like macros, this caused
> > Rust build errors. Add a helper function to fix it.
> >
> > ```
> > error[E0425]: cannot find function `wait_for_completion` in crate `bindings`
> >      --> rust/kernel/sync/completion.rs:110:28
> >       |
> >   110 |         unsafe { bindings::wait_for_completion(self.as_raw()) };
> >       |                            ^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `__wait_for_completion`
> >       |
> >      ::: /root/linux/rust/bindings/bindings_generated.rs:33440:5
> >       |
> > 33440 |     pub fn __wait_for_completion(arg1: *mut completion);
> >       |     ---------------------------------------------------- similarly named function `__wait_for_completion` defined here
> >
> > error: aborting due to 1 previous error
> >
> > For more information about this error, try `rustc --explain E0425`.
> > ```
> >
> 
> I think Danilo already made it clear, please fold this the existing
> patch. Moreover, since this patchset doesn't adjust init_completion()
> from the Rust side, the result is Rust code will also use the same dept
> key for completion, which has to be fixed if dept wants to be in-tree.

Thank you for informing that.  I will take a look on it.

	Byungchul
> 
> Regards,
> Boqun
> 
> > Signed-off-by: Guangbo Cui <2407018371@qq.com>
> > ---
> >  rust/helpers/completion.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/rust/helpers/completion.c b/rust/helpers/completion.c
> > index b2443262a2ae..5bae5e749def 100644
> > --- a/rust/helpers/completion.c
> > +++ b/rust/helpers/completion.c
> > @@ -6,3 +6,8 @@ void rust_helper_init_completion(struct completion *x)
> >  {
> >       init_completion(x);
> >  }
> > +
> > +void rust_helper_wait_for_completion(struct completion *x)
> > +{
> > +     wait_for_completion(x);
> > +}
> > --
> > 2.43.0
> >

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

* Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
  2025-10-02 10:27   ` Danilo Krummrich
@ 2025-11-13  1:21     ` Byungchul Park
  0 siblings, 0 replies; 8+ messages in thread
From: Byungchul Park @ 2025-11-13  1:21 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: Guangbo Cui, Liam.Howlett, amir73il, andi.shyti, andrii,
	boqun.feng, bsegall, gregkh, linaro-mm-sig, link, linux-kernel,
	mark.rutland, masahiroy, mathieu.desnoyers, matthew.brost,
	max.byungchul.park, mcgrof, melissa.srw, mgorman, mhocko, minchan,
	oleg, paulmck, penberg, peterz, petr.pavlu, torvalds,
	vincent.guittot, will, yeoreum.yun, ysk, rust-for-linux, ojeda,
	gary, lossin, a.hindborg, aliceryhl, alex.gaynor, bjorn3_gh,
	kernel_team

On Thu, Oct 02, 2025 at 12:27:53PM +0200, Danilo Krummrich wrote:
> On Thu Oct 2, 2025 at 12:06 PM CEST, Guangbo Cui wrote:
> > The DEPT patch series changed `wait_for_completion` into a macro.
> > Because bindgen cannot handle function-like macros, this caused
> > Rust build errors. Add a helper function to fix it.
> 
> Good catch!
> 
> Given that the latest version of this series was just posted, please squash this
> fix into patch "dept: assign unique dept_key to each distinct
> wait_for_completion() caller" [1].

Thank you all.  I will squash this into the patch.  Thanks again!

	Byungchul
> 
> Thanks,
> Danilo
> 
> [1] https://lore.kernel.org/all/20251002081247.51255-37-byungchul@sk.com/

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

* Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function
  2025-11-13  1:20     ` Byungchul Park
@ 2025-11-13  2:02       ` Byungchul Park
  0 siblings, 0 replies; 8+ messages in thread
From: Byungchul Park @ 2025-11-13  2:02 UTC (permalink / raw)
  To: Boqun Feng
  Cc: Guangbo Cui, Liam.Howlett, amir73il, andi.shyti, andrii, bsegall,
	gregkh, linaro-mm-sig, link, linux-kernel, mark.rutland,
	masahiroy, mathieu.desnoyers, matthew.brost, max.byungchul.park,
	mcgrof, melissa.srw, mgorman, mhocko, minchan, oleg, paulmck,
	penberg, peterz, petr.pavlu, torvalds, vincent.guittot, will,
	yeoreum.yun, ysk, rust-for-linux, ojeda, gary, lossin, a.hindborg,
	aliceryhl, dakr, alex.gaynor, bjorn3_gh, kernel_team

On Thu, Nov 13, 2025 at 10:20:36AM +0900, Byungchul Park wrote:
> On Thu, Oct 02, 2025 at 10:27:51AM -0700, Boqun Feng wrote:
> > On Thu, Oct 02, 2025 at 10:06:17AM +0000, Guangbo Cui wrote:
> > > > -extern void wait_for_completion(struct completion *);
> > > > -extern void wait_for_completion_io(struct completion *);
> > > > -extern int wait_for_completion_interruptible(struct completion *x);
> > > > -extern int wait_for_completion_killable(struct completion *x);
> > > > -extern int wait_for_completion_state(struct completion *x, unsigned int state);
> > > > -extern unsigned long wait_for_completion_timeout(struct completion *x,
> > > > +extern void __wait_for_completion(struct completion *);
> > > > +extern void __wait_for_completion_io(struct completion *);
> > > > +extern int __wait_for_completion_interruptible(struct completion *x);
> > > > +extern int __wait_for_completion_killable(struct completion *x);
> > > > +extern int __wait_for_completion_state(struct completion *x, unsigned int state);
> > > > +extern unsigned long __wait_for_completion_timeout(struct completion *x,
> > > >                                                unsigned long timeout);
> > > > -extern unsigned long wait_for_completion_io_timeout(struct completion *x,
> > > > +extern unsigned long __wait_for_completion_io_timeout(struct completion *x,
> > > >                                                 unsigned long timeout);
> > > > -extern long wait_for_completion_interruptible_timeout(
> > > > +extern long __wait_for_completion_interruptible_timeout(
> > > >     struct completion *x, unsigned long timeout);
> > > > -extern long wait_for_completion_killable_timeout(
> > > > +extern long __wait_for_completion_killable_timeout(
> > > >     struct completion *x, unsigned long timeout);
> > > >  extern bool try_wait_for_completion(struct completion *x);
> > > >  extern bool completion_done(struct completion *x);
> > > > @@ -139,4 +134,79 @@ extern void complete(struct completion *);
> > > >  extern void complete_on_current_cpu(struct completion *x);
> > > >  extern void complete_all(struct completion *);
> > > >
> > > > +#define wait_for_completion(x)                                             \
> > > > +({                                                                 \
> > > > +   sdt_might_sleep_start_timeout(NULL, -1L);                       \
> > > > +   __wait_for_completion(x);                                       \
> > > > +   sdt_might_sleep_end();                                          \
> > > > +})
> > >
> > > The DEPT patch series changed `wait_for_completion` into a macro.
> > > Because bindgen cannot handle function-like macros, this caused
> > > Rust build errors. Add a helper function to fix it.
> > >
> > > ```
> > > error[E0425]: cannot find function `wait_for_completion` in crate `bindings`
> > >      --> rust/kernel/sync/completion.rs:110:28
> > >       |
> > >   110 |         unsafe { bindings::wait_for_completion(self.as_raw()) };
> > >       |                            ^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `__wait_for_completion`
> > >       |
> > >      ::: /root/linux/rust/bindings/bindings_generated.rs:33440:5
> > >       |
> > > 33440 |     pub fn __wait_for_completion(arg1: *mut completion);
> > >       |     ---------------------------------------------------- similarly named function `__wait_for_completion` defined here
> > >
> > > error: aborting due to 1 previous error
> > >
> > > For more information about this error, try `rustc --explain E0425`.
> > > ```
> > >
> > 
> > I think Danilo already made it clear, please fold this the existing
> > patch. Moreover, since this patchset doesn't adjust init_completion()
> > from the Rust side, the result is Rust code will also use the same dept
> > key for completion, which has to be fixed if dept wants to be in-tree.
> 
> Thank you for informing that.  I will take a look on it.

It looks not easy unless Rust side uses explicit maps for that purpose.
I think there are the same issues in 'lockdep + typical lock' too.  How
does lockdep deal with the issue?  Use explicit keys for that?

	Byungchul

> 
> 	Byungchul
> > 
> > Regards,
> > Boqun
> > 
> > > Signed-off-by: Guangbo Cui <2407018371@qq.com>
> > > ---
> > >  rust/helpers/completion.c | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > >
> > > diff --git a/rust/helpers/completion.c b/rust/helpers/completion.c
> > > index b2443262a2ae..5bae5e749def 100644
> > > --- a/rust/helpers/completion.c
> > > +++ b/rust/helpers/completion.c
> > > @@ -6,3 +6,8 @@ void rust_helper_init_completion(struct completion *x)
> > >  {
> > >       init_completion(x);
> > >  }
> > > +
> > > +void rust_helper_wait_for_completion(struct completion *x)
> > > +{
> > > +     wait_for_completion(x);
> > > +}
> > > --
> > > 2.43.0
> > >

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

end of thread, other threads:[~2025-11-13  2:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20251002081247.51255-37-byungchul@sk.com>
2025-10-02 10:06 ` [PATCH] rust: bindings: add `rust_helper_wait_for_completion` helper function Guangbo Cui
2025-10-02 10:27   ` Danilo Krummrich
2025-11-13  1:21     ` Byungchul Park
2025-10-02 10:39   ` Miguel Ojeda
2025-10-02 16:52     ` Guangbo Cui
2025-10-02 17:27   ` Boqun Feng
2025-11-13  1:20     ` Byungchul Park
2025-11-13  2:02       ` Byungchul Park

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).