From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from flow-a7-smtp.messagingengine.com (flow-a7-smtp.messagingengine.com [103.168.172.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 338A03596F8 for ; Thu, 6 Aug 2026 07:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.142 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786001622; cv=none; b=KtY7gq/MxaG0SxkjuUN8+a7TpJ3pw3mXdRgj7e2860xKeBKRJ7wz45+pGOb63XEdhygqIDGHp4DRgO+y40nB0Tpo3z44MTm0KE+DOVXMl55ocw7kXi3QDGhj5YhVPMwUZ2AUZfGCxE0blFTh27+wAhrLrQoL/kFj/7R7+Iv28Eg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786001622; c=relaxed/simple; bh=S5P5DtcVF6BPqwlPAhTNZgNH9vVWAP9U/pnsPq45Lf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pqiwriq9srVGgYYNMT9DVf2igMR6/8YX1gdAvgTl4rIpNGV8/ZbSXVjpFSb92/2Ma4kfq8fxOjBDpf3adDydeZQhbSI8ywQWmregLmYdGs5de+XwxsrZFQNrCB+Xu6y+5eYkltd1inHVHXUgzKeqAx+K6wuzPLVp/QNP1nh/UtE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org; spf=pass smtp.mailfrom=flapping.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b=aovBKyRf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VgipK+0o; arc=none smtp.client-ip=103.168.172.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flapping.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b="aovBKyRf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VgipK+0o" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.phl.internal (Postfix) with ESMTP id 4BEEB1380231; Thu, 6 Aug 2026 03:33:40 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Thu, 06 Aug 2026 03:33:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flapping.org; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1786001620; x= 1786005220; bh=SbOIwbW2S4CYQpzxjpl6OhfC5zaWzNlzY0GTgOxVWwY=; b=a ovBKyRfKbKTUcmOStJnou1CkiATQExLaZj41/doSa25hjskX5BirRZ2cW7cvp2yf 6pWfSVAsf0sy8vXmNMYPzXNg9tbFzzWUCt9L2uoSlNwv01HT7zHH1p3TuoqT/zJ6 U6HvYoHqaPXxa9bt6YYOg7suVB+YnqDNCTDOkGy/A3QGfZeAzzakPqzveAcJDYty GPMvi8tCBlyCByDM4LEc8AWwP02tUYq80DMeY/TMH1VDNZALesL24n56WJzVD5TR oucwIHduITXEZLItJSV4vJ+cjOHDsK0ohGNEAuv3WymmuaSMnf2Jn2H4ptoHKsoq ccK7dWwTif4qLDrW6bRag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1786001620; x=1786005220; bh=S bOIwbW2S4CYQpzxjpl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cZ18PAZAxJZrB7oiyM6s4IZrcJIaw X-ME-Proxy: Feedback-ID: i51fe4b43:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Aug 2026 03:33:34 -0400 (EDT) From: FUJITA Tomonori To: a.hindborg@kernel.org, aliceryhl@google.com, arve@android.com, boqun@kernel.org, brauner@kernel.org, cmllamas@google.com, gary@garyguo.net, gregkh@linuxfoundation.org, ojeda@kernel.org, tkjos@android.com Cc: acourbot@nvidia.com, anna-maria@linutronix.de, bjorn3_gh@protonmail.com, dakr@kernel.org, daniel.almeida@collabora.com, frederic@kernel.org, jstultz@google.com, lossin@kernel.org, lyude@redhat.com, sboyd@kernel.org, tamird@kernel.org, tglx@kernel.org, tmgross@umich.edu, work@onurozkan.dev, rust-for-linux@vger.kernel.org, FUJITA Tomonori Subject: [PATCH v5 6/7] rust: sync: condvar: use Delta for timeout and result Date: Thu, 6 Aug 2026 16:32:40 +0900 Message-ID: <20260806073241.1024319-7-tomo@flapping.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260806073241.1024319-1-tomo@flapping.org> References: <20260806073241.1024319-1-tomo@flapping.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: FUJITA Tomonori 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. So a delay is expressed in the same time vocabulary as the rest of the kernel crate. Reviewed-by: Gary Guo Signed-off-by: FUJITA Tomonori --- drivers/android/binder/process.rs | 7 ++++--- rust/kernel/sync/condvar.rs | 29 ++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs index cdd1a9079726..aacce7d07499 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -33,6 +33,7 @@ Arc, ArcBorrow, CondVar, CondVarTimeoutResult, Mutex, SpinLock, UniqueArc, }, task::Task, + time::Delta, uaccess::{UserSlice, UserSliceReader}, uapi, workqueue::{self, Work}, @@ -1482,8 +1483,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(); + while jiffies.as_jiffies() > 0 { if inner.outstanding_txns == 0 { break; } @@ -1500,7 +1501,7 @@ pub(crate) fn ioctl_freeze(&self, info: &BinderFreezeInfo) -> Result { jiffies = remaining; } CondVarTimeoutResult::Timeout => { - jiffies = 0; + jiffies = Delta::from_jiffies(0); } } } diff --git a/rust/kernel/sync/condvar.rs b/rust/kernel/sync/condvar.rs index 69d58dfbad7b..73e123aac860 100644 --- a/rust/kernel/sync/condvar.rs +++ b/rust/kernel/sync/condvar.rs @@ -12,7 +12,10 @@ task::{ MAX_SCHEDULE_TIMEOUT, TASK_FREEZABLE, TASK_INTERRUPTIBLE, TASK_NORMAL, TASK_UNINTERRUPTIBLE, }, - time::Jiffies, + time::{ + Delta, + Jiffy, // + }, types::Opaque, }; use core::{marker::PhantomPinned, pin::Pin, ptr}; @@ -186,15 +189,23 @@ pub fn wait_interruptible_freezable( pub fn wait_interruptible_timeout( &self, guard: &mut Guard<'_, T, B>, - jiffies: Jiffies, + delta: Delta, ) -> CondVarTimeoutResult { - let jiffies = jiffies.try_into().unwrap_or(MAX_SCHEDULE_TIMEOUT); - let res = self.wait_internal(TASK_INTERRUPTIBLE, guard, jiffies); + let jiffies = delta.as_jiffies(); + let res = self.wait_internal( + TASK_INTERRUPTIBLE, + guard, + jiffies.clamp(0, MAX_SCHEDULE_TIMEOUT), + ); - match (res as Jiffies, crate::current!().signal_pending()) { - (jiffies, true) => CondVarTimeoutResult::Signal { jiffies }, + match (res, crate::current!().signal_pending()) { + (jiffies, true) => CondVarTimeoutResult::Signal { + jiffies: Delta::from_jiffies(jiffies), + }, (0, false) => CondVarTimeoutResult::Timeout, - (jiffies, false) => CondVarTimeoutResult::Woken { jiffies }, + (jiffies, false) => CondVarTimeoutResult::Woken { + jiffies: Delta::from_jiffies(jiffies), + }, } } @@ -248,11 +259,11 @@ pub enum CondVarTimeoutResult { /// Somebody woke us up. Woken { /// Remaining sleep duration. - jiffies: Jiffies, + jiffies: Delta, }, /// A signal occurred. Signal { /// Remaining sleep duration. - jiffies: Jiffies, + jiffies: Delta, }, } -- 2.43.0