From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (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 EF78E2853F1 for ; Tue, 29 Jul 2025 12:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753791340; cv=none; b=AFpsgu4zV22Tsoh4q5hwZGMuR7FLO7myEpL9lwjUcFkKDQZYCEtku1hfU5vXRCRu5knkayhPfI84PK9TxYZhQc6LyEXGLqDVRWjw0hkY9OhuOchVZRMVnpd9XfxRChQoJsTTe6W8DXZtfOORHOWWGf/67MynbZExWGTRF6jMDak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753791340; c=relaxed/simple; bh=pRKWkEQ859AqbMty/6nEBTeAZEv6HUIc36eyCZvgTD4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Une0YDBIh0zm8hCMCkY+1KJjeFmRBT6mGLMvk2aRQDHvApuCchF9Ac3uy9vLGClP3hA7OLzokQnRRq7zOujZ3Hku8BPKq9r+DOrFlNPLU2+wAaj1MvpKKs50PtkrQmxQo5WYGBxT0dqa0sWX9lSr9YJ/tb79hgAPoEZJHdpE+4M= 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=SeSZZN/C; arc=none smtp.client-ip=209.85.218.73 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="SeSZZN/C" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-ae3c8477f1fso581602666b.3 for ; Tue, 29 Jul 2025 05:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1753791337; x=1754396137; 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=lYzZqhjw8TBD0wreOo10dc1gdI2xJtGND/ZcoPMk/NA=; b=SeSZZN/CRYZPX1j9NTP17/DvMhV7whVJV5trQjGoCaOAKFPFESAo4yuTLnjLL3p+yz 3PGyoDqMjItRTROJo1uqoDaK9WngSzzu6NN1ls6OSugjaPkwkifzGnsjdw8TW4FunO8Z gajH03n/l9aeKTMFIxsGWnQ7UT20TJcBPro1hAbOlEe3ZJsEvHQEV+KZyZHZfiAz0saP Yrex1jqonuLQzKZFVAwgGxa+N8gKz877EOCuycBiMfsVdi2jIzhb/koSy9uUFdENPEJf xc5r/rB26wSDsICT9eQhZeod3KYr9x7RZ9mrlEgEQtepSYJ5CSWwWz4WgZ4qXk+pQbIl YX7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753791337; x=1754396137; 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=lYzZqhjw8TBD0wreOo10dc1gdI2xJtGND/ZcoPMk/NA=; b=wVHoQ1FWn7cTxjIPGu411rr70Vr6rpVpxPqTlimaeyzUzR82I32e18KKY4rjXhVmDb cMb+mTwksRUVBGJBDNEedq/FCjg5lTlrb9sYjRbK5z/nTtGB2qw/+Dvay0CxqIVvsghu wTLYHyuOznPzGnl/m4FkCctpcUNhPNK0nuJfLzY+YgJ9+x894Bi909NIa2PGSNeXduko GB0wrIbwHqfnazZbd4em7PmCWEp/aU0OzyBB3iredC+PE2tYq6l9lFKK2PN339/l8Bqt MJoXvVTVcWYngc4Hi6/PiyNRNoZQJj01VJgvv3pjnpTarREyP05rOTbm/+0HckyK0ZqM DBfQ== X-Gm-Message-State: AOJu0YwisShtm/a8Ly4f025N6t6QXschx1WU6q/iW9gRvQTNq6GuO+e/ S030UkITRUyLmZXnTs0fqD38U8HKAD+1BaYzMAkIAqm6cR1Xvr8zWlHFoCMHCGtqQHs8sr+wdtZ G9FhWrfq4WsBIq2QE7A== X-Google-Smtp-Source: AGHT+IGSHNfo7Zrf2KfxC7hlR2bqTHQpTRrlnzGDMx0KhUGV2by0O6HJ7+TOJf/JhZjV+hwsM1vj07vYYew4aMM= X-Received: from ejbgx7.prod.google.com ([2002:a17:906:f1c7:b0:af8:f1eb:c67]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:9287:b0:ae9:bf58:4190 with SMTP id a640c23a62f3a-af616efc1ddmr1835841566b.4.1753791337106; Tue, 29 Jul 2025 05:15:37 -0700 (PDT) Date: Tue, 29 Jul 2025 12:15:35 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250724185700.557505-1-lyude@redhat.com> <20250724185700.557505-3-lyude@redhat.com> Message-ID: Subject: Re: [PATCH 2/2] rust: time: Implement basic arithmetic operations for Delta From: Alice Ryhl To: Lyude Paul Cc: rust-for-linux@vger.kernel.org, Thomas Gleixner , Boqun Feng , linux-kernel@vger.kernel.org, Andreas Hindborg , FUJITA Tomonori , Frederic Weisbecker , Anna-Maria Behnsen , John Stultz , Stephen Boyd , Miguel Ojeda , Alex Gaynor , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Trevor Gross , Danilo Krummrich Content-Type: text/plain; charset="utf-8" On Mon, Jul 28, 2025 at 02:36:50PM -0400, Lyude Paul wrote: > On Sun, 2025-07-27 at 07:31 +0000, Alice Ryhl wrote: > > The CONFIG_64BIT restriction seems annoying. Could we not support 32-bit > > from the get-go? Where is this going to be used? > > > > After all, we have stuff like this: > > https://lore.kernel.org/r/20250724165441.2105632-1-ojeda@kernel.org > > I'm not really sure how the example is relevant here since we're dealing with > a different problem. The issue is that division and remainders for u64s are > not implemented natively on many 32 bit architectures. Also for where it's > going to be used: currently I'm using it in rvkms for calculating the time of > the next vblank when we enable/disable our vblank event timer. We basically > use the duration of a single frame and divide the time elapsed since our > emulated display was turned on, then use the remainder to figure out how many > nanoseconds have passed since the beginning of the current scanout frame - > which we then can just use to figure out the time of the next vblank event. The reason I bring up the example is that once you add code using these impls, you're going to get kernel build bot errors from your code not compiling on 32-bit. And as seen in the linked one, code may be compiled for 32-bit when setting CONFIG_COMPILE_TEST even if you don't support it for real. > This being said, the kernel does have a math library that we can call into > that emulates operations like this on 32 bit - which I'd be willing to convert > these implementations over to using. I just put the CONFIG_64BIT there because > if we do use the kernel math library, I just want to make sure I don't end up > being the oen who has to figure out how to hook up the kernel math library for > 64 bit division outside of simple time value manipulation. I've got enough > dependencies on my plate to get upstream as it is :P If you just want to call the relevant bindings:: method directly without any further logic that seems fine to me. Alice