Re: [PATCH v4 6/7] rust: sync: condvar: use Delta<Jiffy> for timeout and result
"Gary Guo" <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
On Wed Jul 22, 2026 at 10:49 PM BST, FUJITA Tomonori wrote: > From: FUJITA Tomonori <[email protected]> > > wait_interruptible_timeout() takes the timeout as a raw Jiffies and > reports the remaining time as raw Jiffies in CondVarTimeoutResult. That > is the C representation rather than a kernel time type, so it neither > carries the unit in its type nor composes with the Delta spans used > elsewhere, and it pushes the unsigned-to-signed conversion onto callers. > > Switch the parameter and the result fields to Delta<Jiffy>. So a delay > is expressed in the same time vocabulary as the rest of the kernel > crate. > > Signed-off-by: FUJITA Tomonori <[email protected]> > --- > drivers/android/binder/process.rs | 6 +++--- > rust/kernel/sync/condvar.rs | 29 ++++++++++++++++++++--------- > 2 files changed, 23 insertions(+), 12 deletions(-) > > diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs > index cdd1a9079726..314962b5361d 100644 > --- a/drivers/android/binder/process.rs > +++ b/drivers/android/binder/process.rs > @@ -1482,8 +1482,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 = kernel::time::Delta::from_millis(info.timeout_ms.into()).to_jiffies(); Given that `Delta` is used twice this can probably be an import. Best, Gary > + while jiffies.as_jiffies() > 0 { > if inner.outstanding_txns == 0 { > break; > } > @@ -1500,7 +1500,7 @@ pub(crate) fn ioctl_freeze(&self, info: &BinderFreezeInfo) -> Result { > jiffies = remaining; > } > CondVarTimeoutResult::Timeout => { > - jiffies = 0; > + jiffies = kernel::time::Delta::from_jiffies(0); > } > } > }