Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2105758lqa; Tue, 30 Apr 2024 08:17:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4Qv7S1qnOdMyk7Dy6NLABn6COOOYh+8kq16HEsdxAsgMTPsb0POWDows7AgdB0akoqbkWyrQQcKyWWbvSJNZ3Do+JwiKfuV3tiC/akQ== X-Google-Smtp-Source: AGHT+IH0rjK421IVgkzV2Q2sUwdAPi9es7ShpHYavJ0fxTLRa3UBojAjymxsWs6OOr0X69fw7RFP X-Received: by 2002:a05:6a20:5b22:b0:1ad:746:3f6e with SMTP id kl34-20020a056a205b2200b001ad07463f6emr103903pzb.54.1714490257399; Tue, 30 Apr 2024 08:17:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714490257; cv=pass; d=google.com; s=arc-20160816; b=xGEOqwb4jMefg9ZPezw77msCgnvzhaLUYzFMd9C62Zu24QXayyXP5SukMQ2159Eei4 NL8eQ7CDo8CDpCj70XyhF9JZBbVCwlJOZmySfc29ChMksim3RbKIpp+rQR5GbLCOLLn+ gpDJIZv3SZeu0DMlDvCcohAfBEw+BQ6VPSfgVkLjooPexm5HZeAc5/3D0uldNQr9z51q j7d9ZpojiruqSLUbYDHFDyg1FKpqAjnw49nbBOcfPbWkMDNVwvD8acY/SzXYWEMh03dQ UZIzbpiUrthE2ON2WKovKjXTRflbaJ4a4jO0sxnxZ2YFlFqS6cEQOnZZ20rtZnaJMip2 CtUA== 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=idAHpuNGr09iY0JVj3Uq2+CukRYw2YB03EpKFunXlK4=; fh=6qNz05jhq7VT3ScirRCLWjaagH9l61S9f+Qoy6jfyWw=; b=cMVkJnAh5eu9mJfcSA5Nr4a453jhstjGjeu2OwN9RpZRZxVVQbi7P1HyL3rfabfV0u /mIk6RXte2raTTZO+B+mi46cc1q25/sgFD7nqbyVf6jYr9dXrG5O1VUPTK//Hvak3VtN YoKN1qxfG+R6gbV5R/uXx91OMy9MKC40XxYAvI/qi/WqSQSRC49a4Ao2wtkBQew/KrDo /PTpImjT0RUAh4/HZEi3qxcCkcAU090YLHF4tsD5lwBo2jqmYk4dg/+u/+QuqGL+Pzvj 1G6C3FFeIDZ/lbRTjvVnnSmTrDd1CnvQ21zZa7dg0cPJqbMy7rFYn7ruqbwrXd0s95UF 4rDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MaLh7vrw; 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-164241-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 134-20020a63028c000000b005d8bef48a86si21550226pgc.876.2024.04.30.08.17.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164241-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MaLh7vrw; 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-164241-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164241-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 01671281E8C for ; Tue, 30 Apr 2024 15:17:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AFB3143734; Tue, 30 Apr 2024 15:17:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MaLh7vrw" Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (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 C92CB152799; Tue, 30 Apr 2024 15:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714490247; cv=none; b=qLkYF2S/lnhsz50UCE7sQ7yxxbYaaL96nZ91WHQ3h8qB61hGwZx27K6bwQ1OA13kpQ/36cm11XnZe/rqck7SzL+cGaNwzosJJsgclFdQaX0rfRZYEvlmsj+deCPkNbHIB+gNp0yAA1YjgIxSHNyzoJMTg15HvV++Tg+XH05fVL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714490247; c=relaxed/simple; bh=kWp1Z0MGrG5ywNgdIVA70qKym3MH/fgTkmEAdT1eZ8c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GEFEvJgbTn2GKBLX2guXcMZnw8jAQu7bgCgpXkN5//dva5p+jPx8viLYuMh7nHwT9Ko+Mpb6XmeTmrCQZpvrHPk2yU5RCB4u12Z9dqhhF2itYiIUbbtkQeVHF4TUIeZASWhCC9Hq+SuuqjRBLSQaAE1+lVxLLB74fLM/16yrN20= 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=MaLh7vrw; arc=none smtp.client-ip=209.85.222.175 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-qk1-f175.google.com with SMTP id af79cd13be357-790fb9d1b55so161812885a.3; Tue, 30 Apr 2024 08:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714490244; x=1715095044; 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=idAHpuNGr09iY0JVj3Uq2+CukRYw2YB03EpKFunXlK4=; b=MaLh7vrwgJxNn+2mdQfqBdkwtfa/jHeIsnOBJsEZmyw8azW/jicBmoGnZDgSyhCgCo sR0Rx1ntNs0NdCm4RGs7QR2jwwhCZS06Da1sZCwPJzscIZ2ZqtJxm7eX+K++QjZpjsc2 ZDYHEJUPLtepX/OiCVEQdtjeV1rCcwIYgmIrnP7g4izrUX1WZVjJyd+3b98euj0HhQlg M9KDVzm/1ZotZjcqmJ5TorTpAY+b+BffKWULxAfCHbLio1DqIcfef17jOZMHDOcl9Msr xUIHRhxopbUpx+PDVpw+w3uyxEuKkNM1itVd0+3fPlRHUcJwYteCOVTZxHHSk14NEmPM pTqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714490244; x=1715095044; 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=idAHpuNGr09iY0JVj3Uq2+CukRYw2YB03EpKFunXlK4=; b=TGu6yaPoRLBBaLFI/O9/u0BmUztCd/6KZEqXbziMIo9K/lTKnaDLpXrnUe5HIITI7l MtqVVK0IKua/w3ab1NbSKqyOMPEKH0mm0y3KXJHMTuhgZnVVVniVtvvdlTzqayOJ9hHX gNeR0k0xSlQja2IQ2+z4y0+oPDBX1wI4royMaSHzc9jn4K6mvPX6P31Y1ZIl7V25nRAb DCHauY62sXW2uXD1BcVDybwbVMU6THqMEv9PUbeBQM4ZfjXg7Z2XncoZ72fVM8sCHPAX FAIFOKacIMkwwzQihGWogUXNY1EUdspY8yNESqPrKHgHEVlauHlZy0xo1MCX8OeGb+/J xtvA== X-Forwarded-Encrypted: i=1; AJvYcCUCF/CszOtq6aAJAD+xButGFBQq3PM/ULubj4dz0ssVWbXoc45r9Ax9K0eAP1e+VtVGcCWpgW0T4n2ml1a8K6C4PsslfXruaJKWDSIWjQ22YWs1DtjXXEPzUuFvSo+wrIXkh+4Ow0WEneSg9tU= X-Gm-Message-State: AOJu0Yx2nVD+zBWwi+ZpSDKScUGo8sU0CorJpzIbLK4hlbqJLHJBI0GR 7ipNwGymfXcCmQ0naMow/sKHphkpuzoRY/3bBevzgiCLFQeQP4Md X-Received: by 2002:a05:6214:2404:b0:6a0:cd1b:9f9f with SMTP id fv4-20020a056214240400b006a0cd1b9f9fmr3369680qvb.38.1714490244493; Tue, 30 Apr 2024 08:17:24 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id e13-20020a056214110d00b006a0cc5fc18bsm2159284qvs.14.2024.04.30.08.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:17:23 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfauth.nyi.internal (Postfix) with ESMTP id 240111200066; Tue, 30 Apr 2024 11:17:23 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 30 Apr 2024 11:17:23 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddufedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Apr 2024 11:17:22 -0400 (EDT) Date: Tue, 30 Apr 2024 08:17:21 -0700 From: Boqun Feng To: Andreas Hindborg Cc: Benno Lossin , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rust: hrtimer: introduce hrtimer support Message-ID: References: <20240425094634.262674-1-nmi@metaspace.dk> <87v844lbhm.fsf@metaspace.dk> <87plu7jahd.fsf@metaspace.dk> 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: <87plu7jahd.fsf@metaspace.dk> On Tue, Apr 30, 2024 at 02:33:50PM +0200, Andreas Hindborg wrote: [...] > > > > Could you see if you can replace this with a `SpinLock` + > > `CondVar`? We shouldn't use Rust atomic in kernel now. I know it's > > unfortunate that LKMM atomics are still work in process, but in real > > world, you won't do busy waiting for a timer to fire, so a > > `CondVar::wait` is better for example purpose. > > Since this is only using the atomic from Rust code, it should be fine > right? There is no mixing of memory models on this memory location. > It's better compared to mixing accesses on a same location, but it's still not allowed (for now, at least) to avoid mixing memory models on ordering guarantees, for example: (assume all memory location is initialized as 0) CPU 0 CPU 1 ----- ----- x.store(1, RELAXED); // Rust native atomic smp_store_release(&y, 1); // LKMM atomic let r0 = smp_load_acquire(&y); let r1 = x.load(RELAXED); The smp_store_release() and smp_load_acquire() pairs per LKMM, and provide certain rel-acq ordering. But to make it (r0 == 1 && r1 == 0), C11 memory model needs to understand this sort of orderings, but currently there is no such thing as an "external ordering" to C11 memory model. I admit this is much of a theorical concern for code reasoning, in real world, it must "just work", but "if you want to have fun, start with one" ;-) Regards, Boqun