Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp177136rba; Tue, 26 Mar 2024 12:33:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8jvnoHQ20KybJs+AIku07hlqwA3b7RPObnfKZiclLI/ojnWLlmKKj6Stb3OaRi08LPEyo9YeM9GuOjd1ivD8zQxeC2PUshnKfBdr2Ng== X-Google-Smtp-Source: AGHT+IEgtIdhqmQQvePC6hNuZkLM02FWz97lis/zG3DD8XJhDOHgEmVYCS2qgk2kJO22F62YWyrZ X-Received: by 2002:a17:907:970a:b0:a4d:f77a:b8d6 with SMTP id jg10-20020a170907970a00b00a4df77ab8d6mr2017473ejc.22.1711481590154; Tue, 26 Mar 2024 12:33:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711481590; cv=pass; d=google.com; s=arc-20160816; b=pe95ehuJXnOVHL2DS86Moensgj9peW73OtBwyY4aGQo1qonblSl8JCq5/9mRnxj5Jh +KquC73mRuHyF+aXGsPiqlw2+BgJHm/Unrd2qixU/nBoQLRs1wsOOgY7CSZ+LtUW0bE2 aYU5T9GXN9aVXdgX3byfs3it93LdONwvv5lVCpHTRKPVfOVrxzFW5jXhDcIpappByIco 8HU9ofHvnsfBwjLT93+bH5hZP6E6quaOzFlGVoNNzdugx+/02lzmXk+Q5dMW0lJRlOno lRBE4tLsz1vncBIt//Iim00ucwwuxYx5BrLo0XQ9h5+bJIA0X+Jf9NEdQVum5y8ny7OG c2qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature; bh=WV7TbUWdy1KyRCYO59YjywGKYmLdtGd+fKg5ys9yxzU=; fh=MANdAP2heF3yOviG4eZwCbrjhn4AuhO5AtSHjxOPj3o=; b=c6warpM/9it+niYSs/C33H04i4CeqkDIM7rNVGZfL/O8DkO0tcWQO2JKpBXVkKk5n2 IsXLwKOP7lPCCE3d0ehWUUwRinpNZkDkE6RGha3V8/H2UkLoR3gtE6MHXGuhR/GvVfHz vVcNruGE7Wsp72Z+bX1rza3uenDLnoEcbNdA31eamaaFHVSCOnUWhCFCdY7P8xsEWAxk YJqr8/mOBBckUPv/29dS1he3SuUMQXH/y43ev9mYNBUnK8gsagW9XegQNrQ9IVPo023p ZObB8GpS9ssNIImJvnc6k2g8Muq9ZnN8F9JCKI3nuVdJ2Qw4J3skB7R3jheuRWXXDMGN KMxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZtZiGz1r; 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-119797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119797-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id jr4-20020a170906a98400b00a4c76b7d6c5si1593197ejb.272.2024.03.26.12.33.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 12:33:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZtZiGz1r; 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-119797-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119797-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 64E871F86CC4 for ; Tue, 26 Mar 2024 19:23:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55FB313D258; Tue, 26 Mar 2024 19:22:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZtZiGz1r" Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 B19333A8D0; Tue, 26 Mar 2024 19:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711480932; cv=none; b=M0GdFKScaiZu3BENFS+2o/eHJckpwYh7wx/f2Sjea1AUpcSSyHpC8TWxyca+CbBo6tIr/roaESGAqhS72CeYC64XQW+jI9ECS01Ac8Y8y+vy3yqy1PLW3XTPe+0r3Zwr+OBJiqIzRMeg+fj8ddWp6/ciqLlZ3A4fHvbdo87ulvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711480932; c=relaxed/simple; bh=9A69lqNVbjewNLP/BP8WnbYpmKhO8CPeO89Rbk7DpmQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I6DqsQKxWlxWI1gmYbUgjojLiU8SbHZ9BTLolDm6+zEnvcWywtsNkZZn83aUigXaLdi/RwMPiMKdTwHB+TnZuLEMgs5upNT5D/v9neB8VrHnFJNBQ19PgyPcYokrCoVf7H1BWSTYLb4pl+QMZVQbIF/IxXWgA+hauw6TV9zykLg= 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=ZtZiGz1r; arc=none smtp.client-ip=209.85.167.172 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-oi1-f172.google.com with SMTP id 5614622812f47-3c3bc867eaaso2529542b6e.1; Tue, 26 Mar 2024 12:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711480929; x=1712085729; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=WV7TbUWdy1KyRCYO59YjywGKYmLdtGd+fKg5ys9yxzU=; b=ZtZiGz1rZB6o/UIFXVJy+0HVVtgkB4oMKjZoQbR7+St+0jEv04Z+YcQ/4VuMMmeOH9 MhZ/Q6iqumLq/tW/lY/pIRY3rMpUHcKx+n8uokUM2OxEoO9Zb50wsimPvD8kAR0WtjSz Jok721igWGPz+ba7S5wVbK/GB+yHUMaJxviYtnN8ndRzB1M6uuRCG1QI6zEaaGy2gFHS SwbqPMOfg77KhaTu4/giydoIN1VwBxapTPH9+hscuw5bufpubuG0D0A/4olnm25eef9r i/PEkKOBSCyybzp2eZukL3k0Mur8oTIAIYsoW8qXtU7ldIzbJk48bYEVl2iaW9BmwXj8 dg/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711480929; x=1712085729; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WV7TbUWdy1KyRCYO59YjywGKYmLdtGd+fKg5ys9yxzU=; b=gr3gALnooUacB3no8sfA3ZRC0K0zMOzYbe7iPdn+m3cSLppfY4kr0IfJ3yaxUxR+rX aVRQDz/deoqKdDHdTkg44oUHFHGVqnv2Ow/DV+XZfDRUAxl9HNhNLE7BV0MjEda1iXKu ew/0MqxD+PmZpUO/Yj42xFkFr9Fv4ekZeYDQ7KbHvVpdrVMAeYIYNd4wfyqZUJlsZT3m aEO17CRcaC8gMd048AKiWKL7cl9//vNeKJysyLwphw4cGOOWI6DttPzYz9+TSQvMWVc0 23RhwnwBSY+OKBj9PYgxjWzFVy/RgysxfZCQPKGHX6XXIrvM6FikkXX/CA8x5O6M7IBu 5oMQ== X-Forwarded-Encrypted: i=1; AJvYcCU6VrRgwO3249dZDg3KE8Cn1bYfnFCCRGDnrLF62tu/36kMQTzz95obd1/MuXFbUwnQ0jFF3tB4mzJ0Xxw9W7Vuynfuftt6kgfGQKFE X-Gm-Message-State: AOJu0Yx6ia6uXkE+KLbrhWU9Kjqt3fvcLI5tM/ee97O2FKE872h+LWUt FS1lHg50u4swqS8xyY+eD+foFCCUIqZkY5mMdUx2OflpDHn2ZHdY X-Received: by 2002:a05:6808:90a:b0:3c3:af17:fa34 with SMTP id w10-20020a056808090a00b003c3af17fa34mr1890703oih.16.1711480929338; Tue, 26 Mar 2024 12:22:09 -0700 (PDT) Received: from fauth2-smtp.messagingengine.com (fauth2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id jm14-20020ad45ece000000b0068fb6fb217csm5513558qvb.122.2024.03.26.12.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 12:22:08 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfauth.nyi.internal (Postfix) with ESMTP id 730FA1200066; Tue, 26 Mar 2024 15:22:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 26 Mar 2024 15:22:08 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddufedguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhepfffhkeeuvdejtddukefgteffieffledujeeuudeffedtvdejfeekvdev heeugedvnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghdprghnughrohhiugdrtghomh dprhhushhtqdhfohhrqdhlihhnuhigrdgtohhmnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgvrh hsohhnrghlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfhgv nhhgpeepghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Mar 2024 15:22:07 -0400 (EDT) Date: Tue, 26 Mar 2024 12:21:34 -0700 From: Boqun Feng To: Benno Lossin Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Alice Ryhl , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Andreas Hindborg , John Stultz , Stephen Boyd , Valentin Obst , Heghedus Razvan , Asahi Lina Subject: Re: [PATCH 4/5] rust: time: Support reading CLOCK_MONOTONIC Message-ID: References: <20240324223339.971934-1-boqun.feng@gmail.com> <20240324223339.971934-5-boqun.feng@gmail.com> <4wFCQqSgpLIPmdFau6MTL1XLLB73d9Tuv5y-VFnXTDc1DFuTnmNV-GLtF582V5yz8s9ogWP_4U0NK3ei6sZlD1oLl929f8ADoT5K9bO6uKs=@proton.me> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4wFCQqSgpLIPmdFau6MTL1XLLB73d9Tuv5y-VFnXTDc1DFuTnmNV-GLtF582V5yz8s9ogWP_4U0NK3ei6sZlD1oLl929f8ADoT5K9bO6uKs=@proton.me> On Tue, Mar 26, 2024 at 05:03:41PM +0000, Benno Lossin wrote: > On 24.03.24 23:33, Boqun Feng wrote: > > Rust Binder will need to read CLOCK_MONOTONIC to compute how many > > milliseconds a transaction has been active for when dumping the current > > state of the Binder driver. This replicates the logic in C Binder [1]. > > > > For a usage example in Rust Binder, see [2]. > > > > Hence add the support for CLOCK_MONOTONIC read. > > > > The `ktime_get` method cannot be safely called in NMI context. This > > requirement is not checked by these abstractions, but it is intended > > that klint [3] or a similar tool will be used to check it in the future. > > > > Link: https://lore.kernel.org/lkml/5ac8c0d09392290be789423f0dd78a520b830fab.1682333709.git.zhangchuang3@xiaomi.com/ [1] > > Link: https://r.android.com/3004103 [2] > > Link: https://rust-for-linux.com/klint [3] > > Co-developed-by: Heghedus Razvan > > Signed-off-by: Heghedus Razvan > > Co-developed-by: Asahi Lina > > Signed-off-by: Asahi Lina > > Co-developed-by: Alice Ryhl > > Signed-off-by: Alice Ryhl > > Signed-off-by: Boqun Feng > > With the nit fixed: > > Reviewed-by: Benno Lossin > Thanks! > > --- > > @Alice, I still put the link to the usage of Android binder here, if you > > want to remove that, please let me know. > > > > rust/kernel/time.rs | 19 +++++++++++++++++++ > > 1 file changed, 19 insertions(+) > > > > diff --git a/rust/kernel/time.rs b/rust/kernel/time.rs > > index 0f9f5605ed48..5cd669cbea01 100644 > > --- a/rust/kernel/time.rs > > +++ b/rust/kernel/time.rs > > @@ -113,3 +113,22 @@ fn sub(self, other: Self) -> Self::Output { > > Duration::new(self.inner.wrapping_sub(other.inner)) > > } > > } > > + > > +/// Contains the various clock source types available to the kernel. > > +pub mod clock { > > + use super::*; > > + > > + /// A clock representing the default kernel time source (`CLOCK_MONOTONIC`). > > + pub struct KernelTime; > > + > > + /// `CLOCK_MONOTONIC` is monotonic. > > + impl Monotonic for KernelTime {} > > + > > + impl Clock for KernelTime { > > + #[inline] > > + fn now() -> Instant { > > + // SAFETY: It is always safe to call `ktime_get` outside of NMI context. > > + Instant::::new(unsafe { bindings::ktime_get() }) > > I don't think the turbofish syntax (the `::` part) is needed here. > Fixed locally. Regards, Boqun > -- > Cheers, > Benno > > > + } > > + } > > +} > > -- > > 2.44.0 > >