Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2358606lqp; Sun, 24 Mar 2024 15:34:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrGFLbgNgUOu04eQ9peOlzODrEqg703GCTlqN/LstNtSGye1uwZhp5YltZOPKsCzIfD3NMJIhylfmrVUAXPOp5F8Fcyt4OKh2WPIoeTw== X-Google-Smtp-Source: AGHT+IFsZAq7EoFNldbnVHeOCjQ7d2hheXr1utLDg/FOnVQRLeReBksv11+B6gtTU9yyld5fKNl+ X-Received: by 2002:a17:903:22cb:b0:1dd:7e2:b9c2 with SMTP id y11-20020a17090322cb00b001dd07e2b9c2mr7809962plg.10.1711319675086; Sun, 24 Mar 2024 15:34:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711319675; cv=pass; d=google.com; s=arc-20160816; b=CWfa9vfmc0r9fdOC1ss3QCPsU1wzCN/TFra3zSFVsNseHQzQxROe0FjxqsgKxuRks7 prv/XGpYNvYktV0/4BOpAppo8+4DLBDD2GQn4CsfOc53L4XiD424smH3XEvHyj9dIpgd SfO6cCMRLxd7bLkcheH/PP91/3FhBVpqW9ZyHk+uqlux60QKd/VIUvnzGJsGpa+WB8Vd j1+sZiOKd6vW1WMb0sE5jG8X+acxittMuZFJsPW73pn7pSPHUk23pV8P0C/pli701XUy V0Hd9/D5BGEQu5dwQt8qrsTe1XDdFqnLmYXmQERKom/YW6I4LuC5a24l97btZFoUmneg 6yuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:feedback-id:dkim-signature; bh=TsjmfCDFGITGTAqlv2AZ5kLiFTR8eAn1Iun3m/vv7Ug=; fh=rL9y7rGHVV1NJdf9zrUtxyFuvwpM1gEqeZYc7dj1P9U=; b=GnPSifcUJ1rqR39BpCUKs0Z85yR1vr2TwkmiUUbusRY7TAgQ1wwcia2xgqMKWvfxWB 3ZwkIVu/i8Jya2o1kRMgUv0c44t6mV+r1iYviiqs9/Jie1Tocu0l94O31XTOVT5D1MUj qXHGJtzKvaAEpN2RTLB1XeJ2LVqpqKOnS/gCGeVkaeO0DCorjZlItWieGXLVPKv6VA9T Ixf6qk+PTwyVfUGyir7RQqyGCLi3hxgTbFeGMYRzrxnt+BIEC7mofZ3ODE/kn9CJJXY5 DmagCebJer+CokeH7IFVv6l8I0JmJtMWBlN89Qscq9NCxRHpzwHO4BJYK0tHLzy99VRx QxNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A/3Gnc2W"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112881-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o16-20020a170902d4d000b001dd63e18e5bsi4185150plg.136.2024.03.24.15.34.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:34:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A/3Gnc2W"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-112881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112881-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A3536B2116F for ; Sun, 24 Mar 2024 22:34:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1F461F922; Sun, 24 Mar 2024 22:34:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A/3Gnc2W" Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8D0933EE; Sun, 24 Mar 2024 22:34:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319659; cv=none; b=jsCgTwxvHlS8Sa9rBNWz9uUQkN8w+diqO5v7aRtb9/Xd7MRsAD24N/SBPpvehyn8bDbVm6SPvpvK1qtVRcBqptmm1DeIttifdXdt6Fz677KIxEANVvkv8Ivh8HHlIEct8R+F6flJq1pae5bRFV8ZXj3BEi/mwMmACRPrtcRQd8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319659; c=relaxed/simple; bh=AqFkJFWBvaMw+zfMIgl3xomLAFFq9YqqVutllV/J8kg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Kvx+ouh8V0KNQoRdZ9QH+a45UJ1TpzsfIe4NXfSYh6H83paBpWYx3K6yqqE/r5Fm2cfg2qCKB8MiQ5/4oDkHzrj+JZDj8mfS2DcdS/VdcMmtuv+odTdfnoLSdB3YQG8dfKtQkH/tbr3jYdqsruiFz+YZuFdfMMGnuJ0cjMZk2hc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A/3Gnc2W; arc=none smtp.client-ip=209.85.160.177 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 Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-430c45ab240so23744001cf.0; Sun, 24 Mar 2024 15:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711319656; x=1711924456; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:feedback-id:from:to:cc:subject:date:message-id:reply-to; bh=TsjmfCDFGITGTAqlv2AZ5kLiFTR8eAn1Iun3m/vv7Ug=; b=A/3Gnc2Wt7+jsAIf3IeVRMzSBblaEg+T1XhgFXkbOvwIYNEFuLYW4loJgFYrhAP38d GkEqLIy7GbCBhrwylznEPRkZwcC3fJsrjVHE4qZDiZas11hZVlRP3BUwqNhFRiMtI6xA ZP55spNdydB9eOFYy5esegnMfUic5MZU5mR8lcDArSE7NtOXdN1q+dLQ0Gzuz2/aQhPG 0/BFsDxYBalRU2Zrdv+WNYmw/koBX1qg6m9bOGapCSqASS+ObQIp+dz/68qFlb0R9/g7 A9U1NcBe2pxhbp/6SJmNsE3vvvbAjfP+UAN5aoUFa88CRv2HbgvKdR1eyRx89SYNGZ6f sW1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711319656; x=1711924456; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:feedback-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TsjmfCDFGITGTAqlv2AZ5kLiFTR8eAn1Iun3m/vv7Ug=; b=TuqQwbIsyqOpAFP9df9xXY9Vht6D7PqEPx9+uMI03aW/cjtfWlZ99BJJcda2d6HfGV AwPLrEOZ+Hkn6zZJXVTqXtUgMnZe/BUfHDJwiAqMaXzObiMbwHJC6FQwvfEZE5KZQSDl B7xYWXzGj86jm68hcpwjCkk7IS49Y3y9dzbQ9U6N+s35o6UXiXPyasq1GshmwZ1pFXyT EobO2thPUoNAtEyZj/Ax/mRojyCX1fLb06Hg7uiDykLh+5Ijh1VUGJr7+Do/xnHvdOL/ B5E8C78OVvEsgJnRA9zOQ3n8yqIYpKu2lhWYgxj+/B+lmpaO2LUIFGMKMy05siguvLCW 8/mA== X-Forwarded-Encrypted: i=1; AJvYcCXLa9l5XAJWybbLa5jG2celyo6K6EE3i3yCKWfHlkAquMrUVFqGecSdBEXUGhpQF4M4uZ4N2zAs+oQIWTvcAYsId5H7CpeG5vjZQlTy X-Gm-Message-State: AOJu0Yy0SRdWduETvKEFlGtrmRbOlvo5/IU1JJ4RVQ0PWRC/dTtslQgH sPZbjXMPWjUHoYHBL6ook9xHOGKMwaOVKKbHvjhYhV1+pan8yRqg X-Received: by 2002:a05:622a:1883:b0:431:2051:4798 with SMTP id v3-20020a05622a188300b0043120514798mr7069993qtc.14.1711319656564; Sun, 24 Mar 2024 15:34:16 -0700 (PDT) Received: from fauth2-smtp.messagingengine.com (fauth2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id f9-20020a05622a114900b0043140cd9996sm1755194qty.38.2024.03.24.15.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:34:16 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfauth.nyi.internal (Postfix) with ESMTP id 71CE81200032; Sun, 24 Mar 2024 18:34:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 24 Mar 2024 18:34:15 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtkecutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhnucfhvghn ghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrthhtvghrnh epgeegueekgefhvedukedtveejhefhkeffveeufeduiedvleetledtkeehjefgieevnecu ffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshho nhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnrdhfvghngh eppehgmhgrihhlrdgtohhmsehfihigmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 24 Mar 2024 18:34:14 -0400 (EDT) From: Boqun Feng To: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner Cc: Alice Ryhl , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , benno.lossin@proton.me, Andreas Hindborg , John Stultz , Stephen Boyd , Valentin Obst Subject: [PATCH 0/5] rust: time: Add clock read support Date: Sun, 24 Mar 2024 15:33:34 -0700 Message-ID: <20240324223339.971934-1-boqun.feng@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Thomas, This is an updated version of: https://lore.kernel.org/rust-for-linux/Zf2kio8NYG5DEgyY@tardis/ where I'm trying to provide the same functionality of Alice's patch: https://lore.kernel.org/rust-for-linux/20240322-rust-ktime_ms_delta-v2-1-d98de1f7c282@google.com/ along with the lesson we learned from the previous discussion: https://lore.kernel.org/rust-for-linux/20230221-gpu-up-time-v1-1-bf8fe74b7f55@asahilina.net/ https://lore.kernel.org/rust-for-linux/20230714-rust-time-v2-1-f5aed84218c4@asahilina.net/ There are three important types or traits (the design was mostly brought from previous patches): * Instant type: it's a generic type for timestamps, whose backend is just ktime_t, but it has a generic type to differentiate clocks. * Clock trait: to read a clock, one must implement the `now` function, in this series, only CLOCK_MONOTONIC support is added. * Duration type: it's a signed 64 bit value which represents the timedelta, I've considered making it unsigned, but I want the following code: d = ts2 - ts1; ts = ts3 + d; to work even when ts2 < ts1, but I'm also OK to define it as an unsigned. Let me know how you think about this. Regards, Boqun Alice Ryhl (1): rust: time: Introduce Duration type Boqun Feng (4): rust: time: doc: Add missing C header link to jiffies rust: time: Introduce clock reading framework rust: time: Support reading CLOCK_MONOTONIC rust: time: Add Instant::elapsed() for monotonic clocks rust/kernel/time.rs | 139 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) -- 2.44.0