From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796289685; b=CIZcSAann7JTcsrxWV+DRJwT96kT1a3jhsuGuQAQb8ddoXxud2ryNh8RUME0FBOiFnVi v4QaIwWKHF9UxuaF3PZysAEIs5sX1LU/TDDdpX2LNLYD44AV9gO+dh5avddM3QxFSx5ub 9b4JYFiK6fIKuClK6qLi0GbUQZaE32OBLrP5g+2NNS99cDgxx0iLRmiCQPT9NuLfVJ4N5 LsQfl5qry89ILZBHHFNFaxBThaY7R14V5ZvMWvnG1an56BQMrwN6jzta2dCyoVRMp1a8h V9oEKCwuyi8l4mAvKUplDiBzm5NPOXEYN2xLkcyr6WvOAIhEeUZGlGKjujMFN+853Ew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289685; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=1DTXJlUjhinBM8Z777+QYr3YfL6UXXD3ssanbsPJyQE=; b=Lu27vDdzr+ZrkdBeXETai4VCM0LSTzRNNo5Tu9n+vfqoCr0zDHcTGF60OdLH63nmk6PF rDvQROIQkYtKS9xW9JfsU6N+WunArWAfQG1X0De6y5+ToTn2txURc7zhjdU6PiGJvdSqL TsXsoHwPseExEfGl6ASfZqjIrma1F5E9DlROn2jE42RzeNrWG/3lv0we7CDbQ7KRlj4Iy JeO0idXBettAWCcgiqpZe1Pax8X4PvlHZIGx7Ir3qODoTwOZ36edprUsUovy6FYc//mV/ B6P2OwB+3oUPf0M3PDMHMH23+F4sCGTcmKmNvBi+gPXJJMaBSGyBfwyhjGKfQVZk8oA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="ozWkZ4y/"; arc=none smtp.remote-ip=209.85.210.173 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ACED606A332 for ; Thu, 3 Dec 2026 09:21:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9ACED606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ozWkZ4y/ Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-8a06cc097c7so8365959b3a.0 for ; Thu, 03 Dec 2026 01:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796289684; x=1796894484; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1DTXJlUjhinBM8Z777+QYr3YfL6UXXD3ssanbsPJyQE=; b=ozWkZ4y/Q8K7YKYKm+DsvM/L4K5Wmzt96zDFfovDErzv/S3JnFZNnVoIs3peBfIyit DxdYOk5AKa0pNsRqfdxB8bCgmNhtcLxjIsi8jF9Ei5VyrIV8yL1xXbW3wZluljeO/fOS rIn4F7xBw9ItfRxQxiDO1Wz0eVn1SsX2lLyxQLtT0JfNyYghQ12cvG7dQ9THVXgXk0DE RYunvdBshhzc/49PLFj5OjaSwJX6XZTQtn9uUZ9MCh4H6oadp9EcEIQhZRX3JaMMiL8q wJGPk7DG0yAyixw/56nGs7fPcI1wz09/xuLkVP/Yf6sSkOhhBUj8Q+HTj63vlhty4esE YPAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796289684; x=1796894484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1DTXJlUjhinBM8Z777+QYr3YfL6UXXD3ssanbsPJyQE=; b=G77c8oUEqa6RPTF93dWuomDYPDyGpeHlHucK50cejirzvyRiktlMUYVePJ6cYdcOxu GLhngEcHsw1nv12M2l93/EKWl0nSrpsTv8g74JtY9OU95RrdCA8G/NZiA/uX5JtG/+21 6UML5ADjIY73gmG/g5vLrOy3XU9CNDtlOAxf0KzY+Pc7pS5btF5VOou/0DcqxdR6uFS0 VO9putRYHqTR0tvP6kccBqKdzvJQRbsayaKKXIZZq3IjKJKDA6VMup4DUivEkb117tYB amUITb9t/Uvyfb7GLe8hXqUNbvkvwV7ssEM0j+0n0GTPMUU4DrHlILKDMXJpM3Y3wL6X yMCw== X-Forwarded-Encrypted: i=1; AL+hErH7CckM/MxZSvh/gy7rt2x43JO4aYORPvJcNfU04FF6D4mUHceeBRsGAJ0Y8M72wezj2WFle7M=@vger.kernel.org X-Gm-Message-State: APuU4Z/60Q0h9i4jNjfIFUvef5mf0yXGPeTNriqmoHU2OU6PBQotFNOx GlkvjCl3k8e/JtKAlbTNPxRAWLHUSKSmaKD7d30ZCg1b4mP8VeuMEF4g X-Gm-Gg: AZFdTZdKlLAz2JcQJWdCQo3QHJrBOp3g7E8XhdRAyh0xaifT45cOOVJVH6MaSbp9OQU T8EM/esrU8UrOeTj79IFRU5snI+PFb3eEGnC4sLslz+SXut1I6c5KukD9mp+b3xPSafxLaRJOFe sCVZqUc0PohQcFecKcrB/sApNMwimpgBaka8/B6dJElBU/b513abYvuuIva+0aCjbrpPbxEsUJu pFWsRZH1sqBTr193WDqpv1Zpw1s40+/fTdhfMYPTZ71+174/cT1brM3R7/8SEVNfLoQZMKaTyC3 ynVPOtXPrNFTHXwO9Ho+AwRmVHLkL1cEGxw09VQIQ5AwmmOk6XqfTrfu/uZubf0rvi5gecknkTx DajmNLVx0r6Vx5E6j6PxY8DTPn3wFn0yif7xIqSiwMgoroN11lZGls6P/RqNGgF7iVTqQbPs+2+ AhTt+bqswENuOkojTt6xfFil+XrBw8A7q8EohWwdvsvhrvi7l8WyGh+LdbM//Zf+W7c02QeqW1W B1dnMFt9QPp78XbtQ9xy/NVkNGCllLNTGudhmbgu1Z+78L9+o5YfefKod2yxtpxZ/AKYhadAoT+ wUwswSSuAmcXu0LoY9VGRgxSJPK2EYdeDQ== X-Received: by 2002:a05:6a21:3a41:b0:3fa:fbcc:edf8 with SMTP id adf61e73a8af0-401493a634dmr50657046637.2.1796289683588; Thu, 03 Dec 2026 01:21:23 -0800 (PST) Received: from ysq-QiTianM428-A376 ([111.201.209.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8d329855224sm11606321b3a.38.2026.12.03.01.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 01:21:23 -0800 (PST) From: Franklin-Qi To: Andreas Hindborg , Lyude Paul , Miguel Ojeda , Alice Ryhl Cc: FUJITA Tomonori , FUJITA Tomonori , Boqun Feng , Danilo Krummrich , rust-for-linux@vger.kernel.org, Thomas Gleixner , John Stultz , Stephen Boyd , Frederic Weisbecker , Anna-Maria Behnsen , Georgios Androutsopoulos , stable@vger.kernel.org, Franklin-Qi Subject: [PATCH v3 0/2] rust: time: keep Instant invariant when adding/subtracting Delta Date: Thu, 3 Dec 2026 17:20:59 +0800 Message-ID: <20261203092101.63850-1-yusq77@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261202080227.898512-1-yusq77@gmail.com> References: <20261202080227.898512-1-yusq77@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Instant documents that its inner value stays in 0..=KTIME_MAX, but Add/Sub only enforced the lower bound under CONFIG_RUST_OVERFLOW_CHECKS. With checks disabled the result could leave that range, which later Instant-Instant subtraction assumes still holds. This series keeps the existing panic behaviour with overflow checks enabled, and otherwise saturates/clamps into range with a one-shot warning. A follow-up patch adds KUnit coverage for the clamping paths. Changes in v3: - Rebased onto timekeeping-next (Instant is now Instant). - Without overflow checks, also warn once when saturating to KTIME_MAX, not only when clamping a negative result (Tomonori). - Add a second patch with KUnit tests for Instant +/- Delta clamping (Andreas, Miguel). v2: https://lore.kernel.org/rust-for-linux/20261202080227.898512-1-yusq77@gmail.com/ Franklin-Qi (2): rust: time: keep Instant invariant when adding/subtracting Delta rust: time: add KUnit tests for Instant Delta clamping rust/kernel/time.rs | 153 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 133 insertions(+), 20 deletions(-) base-commit: 8ecc26b396a2b587088e8ffd4d4b77d878f1eb33 -- 2.55.0