lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251113020236.GA36724@system.software.com>
Date: Thu, 13 Nov 2025 11:02:36 +0900
From: Byungchul Park <byungchul@...com>
To: Boqun Feng <boqun.feng@...il.com>
Cc: Guangbo Cui <2407018371@...com>, Liam.Howlett@...cle.com,
	amir73il@...il.com, andi.shyti@...nel.org, andrii@...nel.org,
	bsegall@...gle.com, gregkh@...uxfoundation.org,
	linaro-mm-sig@...ts.linaro.org, link@...o.com,
	linux-kernel@...r.kernel.org, mark.rutland@....com,
	masahiroy@...nel.org, mathieu.desnoyers@...icios.com,
	matthew.brost@...el.com, max.byungchul.park@...il.com,
	mcgrof@...nel.org, melissa.srw@...il.com, mgorman@...e.de,
	mhocko@...nel.org, minchan@...nel.org, oleg@...hat.com,
	paulmck@...nel.org, penberg@...nel.org, peterz@...radead.org,
	petr.pavlu@...e.com, torvalds@...ux-foundation.org,
	vincent.guittot@...aro.org, will@...nel.org, yeoreum.yun@....com,
	ysk@...lloc.com, rust-for-linux@...r.kernel.org, ojeda@...nel.org,
	gary@...yguo.net, lossin@...nel.org, a.hindborg@...nel.org,
	aliceryhl@...gle.com, dakr@...nel.org, alex.gaynor@...il.com,
	bjorn3_gh@...tonmail.com, kernel_team@...ynix.com
Subject: Re: [PATCH] rust: bindings: add `rust_helper_wait_for_completion`
 helper function

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ