Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp961546lqp; Fri, 22 Mar 2024 00:50:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUY/TUEH5HqlEXwFwSpkEQwD+EEkpuc3u2RUsV78udAE4dsfUVCAWP9YF2H6TE32pZYlFVBSt9qv1iFjtTzykEZGgq+xcxRSNcctwnJ4Q== X-Google-Smtp-Source: AGHT+IFtFpMxmUjhLEE9PFVv31FVGRLwdkz3vfSTuMhEI8WuPflPMF/a8QhDO+/AEyQA6u94SjIR X-Received: by 2002:a81:91ca:0:b0:610:e242:2f6e with SMTP id i193-20020a8191ca000000b00610e2422f6emr1620684ywg.20.1711093857150; Fri, 22 Mar 2024 00:50:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711093857; cv=pass; d=google.com; s=arc-20160816; b=oYWR4EcvBQmavsImPX8Bd0N4RKM8dZ33Ublu+Tmdzr9Pink7YTcI0HEXIoT5wIuLt7 etCt47Ss/XoeCPqpuyCXhdniPAsTO5wP8vgAC6Wt+mSc8N6WvedyIs0smXnVH8hUrMHr tFptrQuU3/Gb+GpQN3GzM1x7iZkdA+kPOuSD3de2voSr+fdYWRVxah8WpWmRhNFaADMr tPCX407xfhdUnM5xbc6E+jhdiZhVD5c4dWvvz9SSIFZpEXnsy/Dgcnobje3u2vtV5yto f863Vk6uQtaTRqs64zcP6WqAVzmWwLRjsv6RRagvgsqvqZ+54/4+bNmi1da/XQltl2Th DL2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=VnAe25wJMJ3hThrbeQJ8J1z3keZcPEDX52hAsKrK748=; fh=b1akxmgdWh7XR2L85USR4miQjuz/VQCIG7eeqcsjgT0=; b=xva6hIuFnxDiLubuLreoNKDUD5bVVeUfaEU9GcvODTu5Mk2XsBHs5EVMMZd/+uAACI 8EYKRoR0cF+ert9b83grqo3v8/C6oewFDGyJ5Sig64qfZ3u2Mr9QJnz1aXYW+bsaS3Eo lnajGgAsk9I18HHb/8SJbf5rQneMLgZXTp/YESEhRK/MPj+4AH2Z+sPmiGsqRBg7Wjrl qcqNLOlrpr47LTyU1fdP5LJtIMTupfKJ74DZu83BhzWn5zw8eo1nYssfB+StKtxuEz7J HW0f8kQ7NaoRchCxsoVSVB5rpSNzcbsuhQzKxvwZy0ogR4vja+02hkSksl80TFI5laCu 6sfg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZURDfk1w; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-111078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bb12-20020a05622a1b0c00b00430c4684d2fsi1455071qtb.284.2024.03.22.00.50.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 00:50:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZURDfk1w; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-111078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 711E81C23D38 for ; Fri, 22 Mar 2024 07:50:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80FD313FFB; Fri, 22 Mar 2024 07:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZURDfk1w" Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) (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 3A05216428 for ; Fri, 22 Mar 2024 07:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711093831; cv=none; b=TwZVdrvojtS0UmgX232HVnQFUxx/Rmg1nS7tWRjaGsYSj0ieDCXiil/sICE9Z6NBubfVZYWVwRZWmPQdL6yOKJheB+2Yoqs01IAa0eTXkv65gB4deVd4jw0kmMBtsHTsmjfRSgYzbqyfQDL/nw7ViaUF2keTNUJCbbaA/cZqX4k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711093831; c=relaxed/simple; bh=fhANto9ziKDqCV1d131XA6WLw6k2l/+/gNXzyf7gZhU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=dFfz7pMkHV8mV52riN2UU4pSiE+lhCgfSfOTKJBZ7aHKbmeDgJ5YkJf6ffbwEnLK5gTE8AZymRa054+PL7QI4XrfgTAGB+lPER7MyKzQLCSujql61wbb1h6GeAD9fzdYeBcM+rPO2gFYjajojp7DKf9a1QAqk5MhLxHKDNysxtY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZURDfk1w; arc=none smtp.client-ip=209.85.221.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-vk1-f178.google.com with SMTP id 71dfb90a1353d-4d436ab8a36so750736e0c.0 for ; Fri, 22 Mar 2024 00:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711093829; x=1711698629; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VnAe25wJMJ3hThrbeQJ8J1z3keZcPEDX52hAsKrK748=; b=ZURDfk1wYqYogkF+3Q2iYedPkvGQ+kNNxzFzEkMX4jOFRWE2Xy6islJrTyOsoXaGXj PUe5QCW0YiU131aaFqx7SBvJ4iGygUStqFW2Jzu67VGICAwbwRP4eHod20t066Zaqinc EgSwfmK8O+incoIJqzRU1y8q+04/gkn66EXOUmX265woCTD/q8hrWg3xw7YW8Jm0/C0j uUph+hzBvxty33kn7s9RbNCoSDiSUp5GMhpNFO9PQ9mSrCPfIqWg32oHcq94urTI2B0G 9djY0OcWX4HbLaPGOaknrcNUwTTwmJjTvQ1YOZBqp6lQkfI1iMBZpByFbLO936EJInp1 cTsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711093829; x=1711698629; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VnAe25wJMJ3hThrbeQJ8J1z3keZcPEDX52hAsKrK748=; b=EtmpU4Pt592JgrS9LEh27syHTadhX4LQOqWrSiaZ1lsz2Of4jOlwW+oHuiFJvaXhOg 5dRzDEhu2lQ482LFsDPTgnCvI2E68CLFkyT+jRE2ihrj8qAZu1Hl35BcjvZuVz9wnzr1 72EmRSWOHrmw0VubbLPc0nObwyCYG6JmgiS2mVIb8o0vYD4+yH0Yq+Aj7Nq3aKjq1N1W L4PVQJGVpN64YfSqTwnRRZgCeen0mnDxiQAwpOgfP0dARY41k3oeRy+HhYkeUeAuRdm6 Vjvaz3j9nNv+0oodk/A9myfVYpwcyFLQFjBaR3Oym9BooU+W1Ebm0PAqOulf7vdvAotz GRCw== X-Forwarded-Encrypted: i=1; AJvYcCXoiK4ZOBRlL9k06uLwzax79l2VDztmaXl5jduvCtL7XxsumBjeT7D03BqhQQGaOrxFTE+TNGaw1t6NAVeD9GtRr4SJqaTfDxBRWQCf X-Gm-Message-State: AOJu0YwSgpgwlbDL+BLw9aHaQaWJZyhpoUJW9iXwcZW4gzqqImh6vgGn GXurA6nDXJUIDsaOZS2oezUvmKrn77OHkvB2MUVGwpjjzZaPKFeyw1jmC4LgH8lguQ3ECor6uMP VXvpvv1Wyrf/Cm01Kq4xAer00upyKGvBCYeeF X-Received: by 2002:a1f:fe86:0:b0:4d4:15d2:8b3b with SMTP id l128-20020a1ffe86000000b004d415d28b3bmr1599387vki.9.1711093829049; Fri, 22 Mar 2024 00:50:29 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240320-rust-ktime_ms_delta-v1-1-ccb8672a0941@google.com> In-Reply-To: From: Alice Ryhl Date: Fri, 22 Mar 2024 08:50:18 +0100 Message-ID: Subject: Re: [PATCH] rust: time: add Ktime To: Boqun Feng Cc: Miguel Ojeda , John Stultz , Thomas Gleixner , Stephen Boyd , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 20, 2024 at 4:30=E2=80=AFPM Boqun Feng w= rote: > > Hi, > > On Wed, Mar 20, 2024 at 10:08:45AM +0000, Alice Ryhl wrote: > > Introduce a wrapper around `ktime_t` with a few different useful > > methods. > > > > Rust Binder will use these bindings 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]. > > > > I wonder whether Lina's previous patch also works for your case? > > https://lore.kernel.org/rust-for-linux/20230714-rust-time-v2-1-f5= aed84218c4@asahilina.net/ > > You don't need to implement all the `Clock`s since you only need > MONOTONIC time. But maybe `Duration::as_nanos` and `Duration::as_millis` > return `u128` is problematic? It would work for me too, but adds more than what I need. As for `u128`, I don't really know what the status on that is. I need to be able to print it as a base-10 integer. Adding an API with separate types that distinguish between Instant and Duration and different clock sources so that you don't mix them up is reasonable, but a bit overkill for my needs. I am spending enough API design cycles on my uaccess, file, and linked list patchsets. Someone else can submit patches to add a more well-typed time API in the future. Alice