Re: [PATCH v9] rust: sync: condvar: use Delta<Jiffy> for timeout and result
From: Alice Ryhl
Date: Wed Nov 04 2026 - 08:17:43 EST
On Mon, Nov 02, 2026 at 07:51:29AM -0800, Boqun Feng wrote:
> On Mon, Nov 02, 2026 at 12:59:34PM +0900, FUJITA Tomonori wrote:
> > Update the only user, binder. It now converts the freeze timeout with
> > Delta::to_jiffies_timeout() instead of msecs_to_jiffies(). Both round
> > up, so a short timeout does not become zero. They differ only for a
> > very long timeout. msecs_to_jiffies() returns MAX_JIFFY_OFFSET for
> > 2^31 ms (about 24.9 days) or more, which means an infinite
> > timeout. to_jiffies_timeout() has no such special case. It converts
> > such a value to the matching number of jiffies, so the wait is long
> > but finite.
> >
> > Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> > Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
>
> Thanks. Alice, any concern regarding the change in binder?
>
> I have some naming suggestion, please see below:
>
> > ---
> > drivers/android/binder/process.rs | 7 ++++---
> > rust/kernel/sync/condvar.rs | 31 ++++++++++++++++++++++---------
> > 2 files changed, 26 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
> > index 1f4cb43f1de6..edde0ea35687 100644
> > --- a/drivers/android/binder/process.rs
> > +++ b/drivers/android/binder/process.rs
> > @@ -1552,8 +1553,8 @@ pub(crate) fn ioctl_freeze(&self, info: &BinderFreezeInfo) -> Result {
> > inner.is_frozen = IsFrozen::InProgress;
> >
> > if info.timeout_ms > 0 {
> > - let mut jiffies = kernel::time::msecs_to_jiffies(info.timeout_ms);
> > - while jiffies > 0 {
> > + let mut jiffies = Delta::from_millis(info.timeout_ms.into()).to_jiffies_timeout();
>
> I would rename this variable to `timeout`, i.e.
>
> let timeout = Delta::from_millis(info.timeout_ms.into()).to_jiffies_timeout();
>
> Thoughts?
No concerns from me; the binder change and your naming suggestions look
good to me.
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Alice