From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 4381E25C704 for ; Thu, 1 Jan 2026 01:13:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767230024; cv=none; b=I2H+yrU1qk47EaSKUP6C692NuJx3VrYhTQcBU4OjXh2/ahYiepIOCWOBWA2z8uRz9boxJb/KMkEPbixg+lYNVWKGVoR9ulA0B178vKzDmRajqoG7xL87Ffiz2wtE20slVLO8fkdl+JYI9T+WycdASvMhr1wK0cjenUuHFRh0nfM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767230024; c=relaxed/simple; bh=WW9T6v83YpHrdRU6GxDyOasG1bC9q4PJavZbqVhfXcs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qjBnzgoIFutHz1lU6ZMQjTKjPtkk0mLzd9VpE/dYn7AGRTrJnLjvWLi/y+fGGLvQEQnBngiS1P1YOrYykibzC1PVdcx+gco/lK7wTZew9+wqVxaFCejcA9WveB5pQI4WU9UVUMPjtlPgN0As7tSLYk5OVOEHH+Zziv8U1g7I+LY= 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=d9cdXSKs; arc=none smtp.client-ip=209.85.160.179 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d9cdXSKs" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-4ed9c19248bso95796131cf.1 for ; Wed, 31 Dec 2025 17:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767230022; x=1767834822; 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=IrjRP9q8c0tglfIoe+XxWLIY8X9nzFBO0FXW5gpQW5g=; b=d9cdXSKsyXys4TH9A/im43O8vTr1JMNwjD3BQoEyqz0w27o2T4KBXY40DPOYIwCnr7 xt8hspRhtt7vmhioknSbw8uZhGM5L7P5LC0kj7YoqATfjDG2v8px/0tD8atxQoZvoEaX pF5HlLcoT+bUd9pUruVUtubGGVwtRpKpLHZcD4IoTFcus2WelSOepVom2i8BIG4aELOj uduQAe0tIdPGfaLkGEOkS4JUki2cf98vtAKOT6EB37/I+B5EliUgAxTm8BSX5W17rnBK 6aFm0go7pC4qbaYo4ph9GV1luuAfZJzdh4t0MapZSHNB2ncn+NEDh+Am3B5+mAlr08Lu TlGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767230022; x=1767834822; 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=IrjRP9q8c0tglfIoe+XxWLIY8X9nzFBO0FXW5gpQW5g=; b=RYQfIt0n8SsGqklxg+yNJtByyj3JIbzpDSQjBXTR3IBAFld1aqDJrjUUvb2ZkMSO8F ls0MsNYBN9mIuqBVc/AYhHrq6xJs9UnI0EBkJxDY8YBkudNKq8Cn/dJBOFT0jJ6sVjRA ojQghV7MajQlQw5Yijh++CNVlpM/ERCeO/rWgY1w3/16ARlVRf0bSQ5EA3fS5z2Zv96i eVLG1ovTvWE9l8rTbbnKHw9IfQ1A+cqaBp+51FJz5TlnjP8Zxe0tkb8r3MveMEnKxBDI WnKitPdULFnt7Wef87Vj90RHjStE/+JSjjwyJ2fFYNxKjYZRvwtwH4vn071AV+BDkSPy dDAA== X-Forwarded-Encrypted: i=1; AJvYcCWEYDQfCDEpZdQzxDHYNF1exPeM87kPLskmj443EH067/PgQ3xSFlymatUlH6AlSnv2805EbF/I8znLvFTXbQ==@vger.kernel.org X-Gm-Message-State: AOJu0Yypn5FvqCn01DR5okvOtfaUX1vAmtXJWzUsDa07COjHPyBGgOVI 0hGE1YQw367RNX6VFUm2yO0xo1RnwieDQUvz2ILsXON6BUtmDx0NBppU X-Gm-Gg: AY/fxX7kULBd5z0oZP0C2OVjZJuCMRWGUO519J883Mojv6UwFWpdiS3BNchiiCa4LKS MVLIRMH6liBb1sUipeMs4yrr0esQQdoa9QL1d3v8q4J6p6IqLyhhG3lgUSAp4Hxpsui3v5w/YYT +UbCZk/9kbLFrOCN/0sT180Lhvmy4844RbfAWa9fv0PIW1H1OHzA/MG6tdw6jXkN8nNs6rpszMM KVxjLhWwK5+FGhB+I3NocjUwknIPsztlTlYqMSAv2nH+P2bKN6oVbxoPqNWXFb7CoTl7+YVzz1h +EPBEgkCePpY8/RaY9UWlfSoyVqP4yssPgEH4rDXFbUDbd2Jt1z7Uwd+XvdpsYV7xNNNWDLsOpZ oi11Sk99c4mQ6CTLPBxYUvO0CX5xZoLTgwofJ0P+y+JtRj4o1u5DuGHg2SGsErtrhwpcSmXYTyq s/eqPyPLJkBEj3RsVZ++8drRgD8knr3S9+u7Jh7PK3C2qFjHDOxscbp5mjR8XAkxF+snMBeF75Y qXgsylGIsBmshU= X-Google-Smtp-Source: AGHT+IGqbWQCQzh9nbyhwAaF7d7/2+0PkqXfRpFE3/XyT4YpnYVUp5bmjdZmquhjJvald9WQ52Pa+Q== X-Received: by 2002:a05:622a:4295:b0:4ee:bff:7fbf with SMTP id d75a77b69052e-4f4abcf6ad2mr546707501cf.4.1767230022154; Wed, 31 Dec 2025 17:13: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 d75a77b69052e-4f4ac65344bsm270256121cf.28.2025.12.31.17.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Dec 2025 17:13:41 -0800 (PST) Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id E4468F40068; Wed, 31 Dec 2025 20:13:40 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Wed, 31 Dec 2025 20:13:40 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdekgeegfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhquhhnucfh vghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrthhtvg hrnhephedugfduffffteeutddvheeuveelvdfhleelieevtdeguefhgeeuveeiudffiedv necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsghoqh hunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieegqddu jeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigihmvg drnhgrmhgvpdhnsggprhgtphhtthhopeefvddpmhhouggvpehsmhhtphhouhhtpdhrtghp thhtoheprghlihgtvghrhihhlhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepghgrrh ihsehgrghrhihguhhordhnvghtpdhrtghpthhtohepfihilhhlsehkvghrnhgvlhdrohhr ghdprhgtphhtthhopehpvghtvghriiesihhnfhhrrgguvggrugdrohhrghdprhgtphhtth hopehprghulhhmtghksehkvghrnhgvlhdrohhrghdprhgtphhtthhopehrihgthhgrrhgu rdhhvghnuggvrhhsohhnsehlihhnrghrohdrohhrghdprhgtphhtthhopehmrghtthhsth ekkeesghhmrghilhdrtghomhdprhgtphhtthhopehlihhnmhgrghejsehgmhgrihhlrdgt ohhmpdhrtghpthhtoheptggrthgrlhhinhdrmhgrrhhinhgrshesrghrmhdrtghomh X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 31 Dec 2025 20:13:39 -0500 (EST) Date: Thu, 1 Jan 2026 09:13:35 +0800 From: Boqun Feng To: Alice Ryhl Cc: 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 , Andreas Hindborg , 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> Precedence: bulk X-Mailing-List: rust-for-linux@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: On Thu, Jan 01, 2026 at 12:53:39AM +0000, Alice Ryhl wrote: > On Wed, Dec 31, 2025 at 03:12:16PM +0000, Gary Guo wrote: > > On Wed, 31 Dec 2025 12:22:24 +0000 > > Alice Ryhl wrote: > > > > > There are currently a few places in the kernel where we use volatile > > > reads when we really should be using `READ_ONCE`. To make it possible to > > > replace these with proper `READ_ONCE` calls, introduce a Rust version of > > > `READ_ONCE`. > > > > > > A new config option CONFIG_ARCH_USE_CUSTOM_READ_ONCE is introduced so > > > that Rust is able to use conditional compilation to implement READ_ONCE > > > in terms of either a volatile read, or by calling into a C helper > > > function, depending on the architecture. > > > > > > This series is intended to be merged through ATOMIC INFRASTRUCTURE. > > > > Hi Alice, > > > > 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. Regards, Boqun > Alice