From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C7A5CDC19B for ; Tue, 6 Jan 2026 13:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JpzahlfiGpAFEOQGjh5jjjaXUgZ9jhcXoloaQUEBJwU=; b=eNSFD+J4uPnHQ0RCVuFrv2xwLX Yp5VYXoJKLy/8zm+lfXHwq3D4GhLOangZg9AYHdQhF80VhaMHDv8F4rPrvfKYQOWbxWnprdr92/d6 1N7lTxln93hir1c5/ZFJ+l2/rS2jSTPz5872xST2TEW0yUyL5CHF2uyCMrKQ11TyKBOVFlWne81Iy frjoA+vKvAz4vWCVe0dvMyOCXPmlXC48SOpc3+rukFsJfbj6ENH7zYLeYUxrgFVteKcKIdRpa5r7J S1ey/CC27YNLArw+P3nB7zVCAlNetrEwm4WMARg5JdxmSn3OVKY3O1Kl1FAgzaBLY9/A8SsDzBqsj oEwo2WDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vd6ol-0000000D3nE-1LUl; Tue, 06 Jan 2026 13:09:47 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vd6oi-0000000D3lZ-1xam for linux-arm-kernel@lists.infradead.org; Tue, 06 Jan 2026 13:09:46 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-8bb6a27d3edso79323585a.3 for ; Tue, 06 Jan 2026 05:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767704983; x=1768309783; darn=lists.infradead.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=JpzahlfiGpAFEOQGjh5jjjaXUgZ9jhcXoloaQUEBJwU=; b=NQyiMI+V9jGCEMuGeykDAFFrpcHv1XvaKyUfupVncHAxWwwt/t+GpUIXHDg19V5Xm/ f2qomtc5a3Nhyfl7HWqFX2tei2uHvT2zDI5RS3xhOAl90PxV3Dl4WzIu9V95lnWKdJ/G AMhi9oPLoDmgZMQf5jdj2aj6azWLAz0YvkH0Hil2s+pU56TJ//FqT04bKthlirdXhsLW vW5TJ5vfowGVHOTt7ZIVCu1bsgU1NZrdUiQY0Z9VlGoxYnnkSSEQXmPxJgKizTWNzvOJ /tY0LanyXHcOcH+Kft+32uzQ+l/aQFls+5K6RCf0ZVNGgJmHWgQ6LnonPuBKXYUyf+ao cTaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767704983; x=1768309783; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JpzahlfiGpAFEOQGjh5jjjaXUgZ9jhcXoloaQUEBJwU=; b=EAO87hQfFS6JKiH5y93MAdB7/ZwADVUx4ek7y+KSRvsdsxyZtTJtlupJekB3zFcPGS eklFzqU1Q6KdAJky7sQ7hff31c+VRwiB3ggiENNvRSHdWNMsxx2DrRVomZqmp+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w+Esh+/t/URn4jtbR4Hhg== X-Received: by 2002:a05:620a:708b:b0:8c2:2b5c:6bb3 with SMTP id af79cd13be357-8c37ec03772mr311728985a.85.1767704982941; Tue, 06 Jan 2026 05:09:42 -0800 (PST) Received: from fauth-a2-smtp.messagingengine.com (fauth-a2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-890770ce659sm13118086d6.10.2026.01.06.05.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 05:09:42 -0800 (PST) Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfauth.phl.internal (Postfix) with ESMTP id C2639F4006A; Tue, 6 Jan 2026 08:09:41 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Tue, 06 Jan 2026 08:09:41 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddutddtvdekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueevieduffei vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvgdpnhgspghrtghpthhtohepfedvpdhmohguvgepshhmthhpohhuthdprhgt phhtthhopegrrdhhihhnuggsohhrgheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprg hlihgtvghrhihhlhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepghgrrhihsehgrghr hihguhhordhnvghtpdhrtghpthhtohepfihilhhlsehkvghrnhgvlhdrohhrghdprhgtph htthhopehpvghtvghriiesihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopehprghu lhhmtghksehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrihgthhgrrhgurdhhvghnug gvrhhsohhnsehlihhnrghrohdrohhrghdprhgtphhtthhopehmrghtthhsthekkeesghhm rghilhdrtghomhdprhgtphhtthhopehlihhnmhgrghejsehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 6 Jan 2026 08:09:40 -0500 (EST) Date: Tue, 6 Jan 2026 21:09:37 +0800 From: Boqun Feng To: Andreas Hindborg Cc: Alice Ryhl , Gary Guo , Will Deacon , Peter Zijlstra , "Paul E. McKenney" , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Miguel Ojeda , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Trevor Gross , Danilo Krummrich , Mark Rutland , FUJITA Tomonori , Frederic Weisbecker , Lyude Paul , Thomas Gleixner , Anna-Maria Behnsen , John Stultz , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 0/5] Add READ_ONCE and WRITE_ONCE to Rust Message-ID: References: <20251231-rwonce-v1-0-702a10b85278@google.com> <20251231151216.23446b64.gary@garyguo.net> <87fr8ij4le.fsf@t14s.mail-host-address-is-not-set> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fr8ij4le.fsf@t14s.mail-host-address-is-not-set> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260106_050944_520924_4880DED3 X-CRM114-Status: GOOD ( 29.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jan 06, 2026 at 01:41:33PM +0100, Andreas Hindborg wrote: > "Boqun Feng" writes: > [...] > >> > I would prefer not to expose the READ_ONCE/WRITE_ONCE functions, at > >> > least not with their atomic semantics. > >> > > >> > Both callsites that you have converted should be using > >> > > >> > Atomic::from_ptr().load(Relaxed) > >> > > >> > Please refer to the documentation of `Atomic` about this. Fujita has a > >> > series that expand the type to u8/u16 if you need narrower accesses. > >> > >> Why? If we say that we're using the LKMM, then it seems confusing to not > >> have a READ_ONCE() for cases where we interact with C code, and that C > >> code documents that READ_ONCE() should be used. > >> > > > > The problem of READ_ONCE() and WRITE_ONCE() is that the semantics is > > complicated. Sometimes they are used for atomicity, sometimes they are > > used for preventing data race. So yes, we are using LKMM in Rust as > > well, but whenever possible, we need to clarify the intentation of the > > API, using Atomic::from_ptr().load(Relaxed) helps on that front. > > > > IMO, READ_ONCE()/WRITE_ONCE() is like a "band aid" solution to a few > > problems, having it would prevent us from developing a more clear view > > for concurrent programming. > > What is the semantics of a non-atomic write in C code under lock racing > with a READ_ONCE/atomic relaxed read in Rust? That is the hrtimer case. > Some C code believes a plain write to a properly aligned location is atomic (see KCSAN_ASSUME_PLAIN_WRITES_ATOMIC, and no, this doesn't mean it's recommended to assume such), and I guess that's the case for hrtimer, if it's not much a trouble you can replace the plain write with WRITE_ONCE() on C side ;-) Regards, Boqun > > Best regards, > Andreas Hindborg > > >