From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 94F1E225AF for ; Fri, 22 Mar 2024 10:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711102687; cv=none; b=DPPMRVmeEc8SUQlFzmI/ASlF0rS22ESKQZ1/YpKesMp1tIWM+aSfK9dd+nDRnZC4EGfcyiOttS1NAAkIT5LJk0h0X+874DkXZI7mTUoVvj0bej1rMFJ2Igg5cNoz+6TQp3Dlab/w6BBaL/AOsaneM5AA2VmoVoGCwSplVidzcRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711102687; c=relaxed/simple; bh=Pvx75pjUmfAFix8YdtVQOmsT9EGDVWYx2bvbS3+FwfA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=i+9jerEE2Eq5PHvY/J24BY97nx1uxJuUx93+VerTITSUJRyrN51IzBA78Y4srxfbqIkQb0+5EFOH4aQEc/D6eJnPZuR9rktEvnMBcjLYroDCQobN/ocPM6WDZw40rvU7O9zHMgSZbg/dyurmmY96iqTTXrRmvysJsBisPeeYEiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3GbQ6/4N; arc=none smtp.client-ip=209.85.219.201 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=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3GbQ6/4N" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbf216080f5so3174126276.1 for ; Fri, 22 Mar 2024 03:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711102685; x=1711707485; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ACnQs7aBrEZBi3RLGYrxwrSPV2Zrt2coy5sWl3wY0QA=; b=3GbQ6/4Nq2m7q1fQ0gCoFAI0DNi3i+lJLYXtQoG9ik7oPnl8UtnD6PovuQLITi6JfM hOMdwyh2BdUbczT10C4LaE8S7Iv82eOW+dDHSFru6ZtUHcSIMdjJZCCeQI2lTpRpRZ+A 0rHltXTFW1DAoJ5yjaMuej6n8KvzgThx2arFJV2ACvFanaG8/tJwbW0JqIwyOuKzJ7Yq lB6+133f1JzaANO2+PUKBkQM4LEjbBCgONYzqM+bi8EarADottlKAhOWjOHrb+UUjpim J+TgG/N+51FkcpFg6QTcHxzRBBOdxt+/2E6Z8uwLk4Vt85PFXvXAGXP1NOIzQo+phZ/C a5VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711102685; x=1711707485; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ACnQs7aBrEZBi3RLGYrxwrSPV2Zrt2coy5sWl3wY0QA=; b=XsZx9YFWIK1K3F1X75SsfPZ69GK24x3OEw9xs6e+TSoikeFQKUFvDI1UBryIq8Q/jV NZmfuwZPAk4OnzZefZl65egh9+kU5MM1q0uqV8QY+28OEqskAC3YJR0Y/7XZjN8F+jYH ZEPKwt3ty1+2AD6an5ykNlvoKAjZvX8c/lVy1kPIuPkf+veiTR+Hc6ycrLY56458pCRY Hi6+PGpEMSnIEWmAzKhEGCstjQWC5gwn5hGDQvFd5jweOvOiGOzQDqFSpzXECloLcWXQ /qH5/G1bOckDbR39SaOCbFyPcyqWwBdyo3itdAddpG56QZGKdoU45NntMkK+MYj67KaQ ChRw== X-Forwarded-Encrypted: i=1; AJvYcCU9wZ77J9f8bFKxSGqFvyzsAqrHEV4aQkazBRv/VbVmWpBOYlnT5kqx4LGzMARqyUd7VFLLcRhaYQVSeoZI5iqMOAIYWAO3dr4Cup6iEJk= X-Gm-Message-State: AOJu0YzN92CWD6FRzk0i9xsPRQ8TSXesqsiHu3i9qSg3jRcxKh5XAoby 2EFY+Z18DTgMTUxasxq38ibWU161B0FLSiRLBOWe08HChCSIxiNmh5/rKYStU26ghUetfT6flL7 GefYd/6XoF9oJ2A== X-Google-Smtp-Source: AGHT+IFFpd2y4r17dMtANQ7EJXXpErok7tREHxgAjPnoff6hqLaJf+G18lXV1ORhcR/6TZaKCbZ+5IgRff5HgU4= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a05:6902:1009:b0:dd9:20d9:d010 with SMTP id w9-20020a056902100900b00dd920d9d010mr595720ybt.3.1711102685532; Fri, 22 Mar 2024 03:18:05 -0700 (PDT) Date: Fri, 22 Mar 2024 10:18:02 +0000 In-Reply-To: <2ecf6529-5408-4621-becc-2f30e1039079@proton.me> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <2ecf6529-5408-4621-becc-2f30e1039079@proton.me> X-Mailer: git-send-email 2.44.0.396.g6e790dbe36-goog Message-ID: <20240322101803.400735-1-aliceryhl@google.com> Subject: Re: [PATCH v2] rust: time: add Ktime From: Alice Ryhl To: benno.lossin@proton.me Cc: a.hindborg@samsung.com, alex.gaynor@gmail.com, aliceryhl@google.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, gary@garyguo.net, jstultz@google.com, linux-kernel@vger.kernel.org, ojeda@kernel.org, rust-for-linux@vger.kernel.org, sboyd@kernel.org, tglx@linutronix.de, wedsonaf@gmail.com Content-Type: text/plain; charset="utf-8" Benno Lossin wrote: > On 3/22/24 09:59, Alice Ryhl wrote: >> +/// Returns the number of milliseconds between two ktimes. >> +#[inline] >> +pub fn ktime_ms_delta(later: Ktime, earlier: Ktime) -> i64 { >> + (later - earlier).to_ms() >> +} > > Is there a reason for this function being standalone? I think for a Rust time API, we should make one of two choices: * Match the C ktime_t API as closely as possible. * Match the Rust standard library std::time API as closely as possible. This patchset has made the former choice, and that is why I went with this design. In the future it could make sense to add a more "Rusty" API, but even then I think it could make sense to have both and implement the latter in terms of the former. That way, only the API that closely matches the C ktime_t API needs to concern itself with unsafely calling into C. Alice