Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1111354rdb; Wed, 6 Dec 2023 08:53:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIJm3CD9lLmqr8PRqjEhfZnY2GZDfxHtoWEofQIGKKK2ZhCEcKy8VXkO018iH3W1+3/GHT X-Received: by 2002:a05:6a20:a39c:b0:18a:e39b:c52f with SMTP id w28-20020a056a20a39c00b0018ae39bc52fmr910960pzk.38.1701881622916; Wed, 06 Dec 2023 08:53:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701881622; cv=none; d=google.com; s=arc-20160816; b=vwFXsnhwF0ypc6aVGs9UuikPU7eEvhLsn8tudNhF6D3fjUPR5meckMddR4/F6JxNg0 F13izapHJdj2u2UFSEZDVQDK0qaxccKorrWeSFrX8Q6fkgHlvCrlOy8ICQ6I9qzSSD0H PA1CDct9ic008dnfn2dQYoqVgPZfr8FmEVTwQlXgknX09hhCIsBzJduL8xAZNtIJsjkw ZuaSrrcrzPZLxSqRzXKSR2gZc9VIUa2mh/nc8eg0Dmbo/4ZedPTGm33ZpRdxKiP5Wa/S 9mzzojiH56skaqmprzbPexnvDuw7ZxjvxGD+T3yk69I4th9RedMrwh/iX0uQpWSGRPAE XL5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GDb7VcIuAlj7p6a+uRK8czAqVjt+vCV92iGoS2eIJsE=; fh=35+wLVm4ijktRP//uBduMTQ3rrjjG0FW3EYPEpdSzzQ=; b=tIt+PiIBlUMvw6iYFinpH6O0oFuodUKCg+ZZ8MsZPeVPchWj944GqY4qOh1auwg+9R CKwyuGLnuZQIu6GZDfxsj0BdWH/hwOwQ9h8QJGS3d4Mw3FaB7Jf06vrCs0S97N8o8w7Y lNo995edvUEG4VQ99BoPGrtyzMTJo88a2BmRx04KwkHm5yW9CsTE/Qt8MxFxP4+pSg0b igaLAK9uOfCTBzHdZ3gE3e14pESh09W+GSd1bQc5VBxTrRMzjImpj9tPHEbNt3rFZzV5 VCeboA3IHU1XzZGu5CcJZyFeN5usoql6aYQ1wgBfdOfIDstdJJRnQ8Z5A+QSq4cnmD+x GPug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vWdnhMnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id t9-20020a656089000000b005c659bf1c70si169109pgu.206.2023.12.06.08.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 08:53:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vWdnhMnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 11CCF81C46D4; Wed, 6 Dec 2023 08:53:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442602AbjLFQxZ (ORCPT + 99 others); Wed, 6 Dec 2023 11:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379355AbjLFQxY (ORCPT ); Wed, 6 Dec 2023 11:53:24 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63002D3; Wed, 6 Dec 2023 08:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=GDb7VcIuAlj7p6a+uRK8czAqVjt+vCV92iGoS2eIJsE=; b=vWdnhMnKagysIvOHbp7KeWA46B pzZhVeoYXslp+ZfacdNXyKWWFf5IG2XagfhGB15eZTWexsOZBVImNvJAY2dv/3eEknOL1WQqtolnF WvU1fwFzV7F2Dk0ZsL5aYCzYtPNt3CF9Vm0lomRIW5ZTNSQE1xWSrjNq6Zr/r8NrVylXKUEtb0usK bMD4HCpqmseWudNQrZDjiPV8oIjxHCwFIJA4aY/4MK2HhQrH/3ukIpk+0/QCU1FAiOHusVh8fmrQ1 /v4oW2vUKrnyyLFIJOZ76Kd6oa55a0BAHry2nPN9B9IBZm5LBZ1MWlp9HvIbmMAXqhaF4R6ePaTf1 5DMT/yOQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1rAv98-00358V-Li; Wed, 06 Dec 2023 16:53:14 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 4F93E300451; Wed, 6 Dec 2023 17:53:14 +0100 (CET) Date: Wed, 6 Dec 2023 17:53:14 +0100 From: Peter Zijlstra To: Alice Ryhl Cc: Boqun Feng , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Ingo Molnar , Will Deacon , Waiman Long , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH 2/2] rust: sync: add `CondVar::wait_timeout` Message-ID: <20231206165314.GD36423@noisy.programming.kicks-ass.net> References: <20231206-rb-new-condvar-methods-v1-0-33a4cab7fdaa@google.com> <20231206-rb-new-condvar-methods-v1-2-33a4cab7fdaa@google.com> <20231206163945.GC36423@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 08:53:40 -0800 (PST) On Wed, Dec 06, 2023 at 05:42:29PM +0100, Alice Ryhl wrote: > On Wed, Dec 6, 2023 at 5:39 PM Peter Zijlstra wrote: > > > > On Wed, Dec 06, 2023 at 08:30:06AM -0800, Boqun Feng wrote: > > > On Wed, Dec 06, 2023 at 10:09:24AM +0000, Alice Ryhl wrote: > > > [...] > > > > + > > > > +/// The return type of `wait_timeout`. > > > > +pub enum CondVarTimeoutResult { > > > > + /// The timeout was reached. > > > > + Timeout, > > > > + /// Somebody woke us up. > > > > + Woken { > > > > + /// Remaining sleep duration. > > > > + jiffies: u64, > > > > > > I have a Jiffies definition in the my upcoming timer patchset: > > > > > > /// The time unit of Linux kernel. One jiffy equals (1/HZ) second. > > > pub type Jiffies = core::ffi::c_ulong; > > > > > > Maybe you can add that (in a separate patch) in kernel::time? > > > > Urgh, why are we using jiffies in 2023? > > I assumed that the correct thing here would be to accept the same unit > as what schedule_timeout takes. Should I be doing something else? Bah, so we have schedule_hrtimeout() that takes ktime/u64 nsec. But the 'problem' is that hrtimers are written with the expectation to fire, while the old timers are written with the expectation to not fire. Timeouts are typically best done with the latter, so in that regard using schedule_timeout() is right. But it is sad to inflict the brain-damage that is jiffies onto new code. Perhaps add schedule_timeout_*msec() wrappers around schedule_timeout*() and use a consistent sane time unit? Thomas?