From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 C766B40FD81 for ; Wed, 21 Jan 2026 15:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769010870; cv=none; b=k89MSNLBbsFC6x17XsXstGkZ7PjSM6kZdoWi7pWXt0oqmEBJcREox0nHH7e3pYV2jUXnEIzSy8gnKdga3LdU5RN+1ntxlsiOrKFhIDnMs1n/VJUb/resyiJbcT9uNHDzhYmklcN9u7YtxOluCpowSfR7z0EvANy7bf5FkDtD2Js= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769010870; c=relaxed/simple; bh=YHIVmzsUwXYFRNT8PxJqLUDcsjT4fcomkaFdrmmVUOc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j2Hoh/A58ejPM0Dus4BNdCG+yIXWMBaTsTFFUahOl3lvBGozgB3sobKvvzU6+7s1HZ0gieIe8i3mllfENd1rkeyrCcOBx5F2tUOr9Atyl9HoHy1bfckVrFzRhgNR7+Pmcn17vF1bVer6tqgEKI9lZ8XzG9E+afDB+DWhlo8MfeE= 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=bWurDZB9; arc=none smtp.client-ip=209.85.210.46 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="bWurDZB9" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-7cfd53a8c31so571371a34.1 for ; Wed, 21 Jan 2026 07:54:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769010867; x=1769615667; 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=vBuHUIxWMnLe6s7TwsvCGhfWapOm3oLq0HDTyptAlGo=; b=bWurDZB9eJj3Dn0GiEllBslYD+9FVE9Mmby58n+k8MH7tnJ4IK3QYXDmCPKXptjLet p0GWE0PxdmKNQukPtkhtnJBVqiGTKm1ec9/yXXK/RNSIgW1OjjKpmjmfQMhfmtkM/fqW Eg5KVCsEITLACMPwDPBuLsN3Wg/fgjxWWJfUW+Y6KLCRLRpsiEaUyjmUz01SpHQabNLJ 6Nr7zGDbRa5YAUd1eJS7t6Cp4PQo8wlPE3Hs2luBvyZClMXNSmHHhmlPBAZOFD4QR4gL 0fAPRenR9MlGIeYLCIn1/K15hSRpamxQttV2HyzkZmAO491S8J1l25GH30hpGSnVwlyf lE3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769010867; x=1769615667; 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=vBuHUIxWMnLe6s7TwsvCGhfWapOm3oLq0HDTyptAlGo=; b=NjsTWN+KavkrA3RfvhABQjkJOX2o9NglJbiSXA4/MPptcYoVxmFIQmyEwUhPYs0Vnl BKZcbL7u9BMZOf/e7BQLYwdSSj137xcljc173ge2wOfMfooIiRibLV6DhJoMUiEYTcgF ykL3oYSv9fmB5eCdvDLR1PVJZvvX+8qI/+ren9n3s8zV02ycK7MGgdqBDxKjI2Uz8SK1 5JrS8pnkjezC4pto5O/MF0cYnQ+BATKZPy8jA7CUAuOcMwBBZjVohrdmQHRf1nreHOyW 9fxk86hPx8FZJbxgLhnfBH4HKy4W+brnHP1QQgYU5EuV5e/QbTo+IQUKZQQxy/+9yZQL OCVg== X-Forwarded-Encrypted: i=1; AJvYcCVwgyhn2gP28Qy5ZvRg2p0xPLPY7kRlo4y+w+f4u4fLHAJ45KlMWmVaA3tw6Yp/7MHekimNS0jXev1RNQE=@vger.kernel.org X-Gm-Message-State: AOJu0YwQh55bfBSkLYQS7UmAQTlB6fGvE6/Y2wZXA+5CKcK2SVWG5yEj TMrs2h1AHbaYgE3V8WBP1tcNxL4aCxhkykBW4psjJe3ryRDpIjK1D29ckxCyb2SC X-Gm-Gg: AZuq6aJiTJCBEdOK28gZveOEkZTA/3lSy/APv4PNKtgJnOS2RmjrByNfVfqIXAQvf+k wsu+5OMtr4Kuodf3VBDdPtQwB0n+A6L5Ib6j8VG67++w5jqciVusbi0CIS8Cw1ae5HLFa+UE8ZV Dwlpxn/4UlnW/mXP4dVur89np7/8LWP17xIHAx6qwWwbE7HlAOpWmOvKAhrHyms3K/SQ5X86JzY dL///4/jrCIQpP73XjCjHZgYMr4OpLX0XGgqFE/uz+qg8vLfBadIuyZ3s96df20LxxEEjYu9sdX Gly0YxBiwFfAXIImtu1FGys0OgAmxe/ZVT0o/gu2+iAC6EWphrpKM8Wa5BYQEqRdPglXFljvGfH VZgdWcYjn1UvyJE/xKlxTWz23vGa7/nmmpNmi5yUoe81BTneyJnEvgRj3dc6Td0XUncPwuFotSn m4HupZmUaT/+8nijRTTkcYkWSge500OIJQE+Ly0KbQkCjswH1mqEkP425w/jh6bdCRtvjeS7tH4 cSEo0F8uNhzmIo= X-Received: by 2002:a05:6214:21ef:b0:87c:19af:4b76 with SMTP id 6a1803df08f44-89398144853mr314752936d6.17.1769004274227; Wed, 21 Jan 2026 06:04:34 -0800 (PST) Received: from fauth-a1-smtp.messagingengine.com (fauth-a1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8942e6d8a94sm124931226d6.56.2026.01.21.06.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jan 2026 06:04:33 -0800 (PST) Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfauth.phl.internal (Postfix) with ESMTP id 82E98F4006D; Wed, 21 Jan 2026 09:04:31 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Wed, 21 Jan 2026 09:04:31 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugeefgeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpefhtedvgfdtueekvdekieetieetjeeihedvteehuddujedvkedtkeefgedvvdeh tdenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgv rhhsohhnrghlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfh gvnhhgpeepghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvpdhnsggprhgtphhtthho pedvtddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprghlihgtvghrhihhlhesgh hoohhglhgvrdgtohhmpdhrtghpthhtohepvghlvhgvrhesghhoohhglhgvrdgtohhmpdhr tghpthhtohepghgrrhihsehgrghrhihguhhordhnvghtpdhrtghpthhtoheplhhinhhugi dqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhushht qdhfohhrqdhlihhnuhigsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplh hinhhugidqfhhsuggvvhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthho pehkrghsrghnqdguvghvsehgohhoghhlvghgrhhouhhpshdrtghomhdprhgtphhtthhope ifihhllheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgvthgvrhiisehinhhfrhgr uggvrggurdhorhhg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Jan 2026 09:04:30 -0500 (EST) Date: Wed, 21 Jan 2026 22:04:28 +0800 From: Boqun Feng To: Alice Ryhl Cc: Marco Elver , Gary Guo , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org, kasan-dev@googlegroups.com, Will Deacon , Peter Zijlstra , Mark Rutland , Miguel Ojeda , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Elle Rhumsaa , "Paul E. McKenney" , FUJITA Tomonori Subject: Re: [PATCH 2/2] rust: sync: atomic: Add atomic operation helpers over raw pointers Message-ID: References: <20260120115207.55318-1-boqun.feng@gmail.com> <20260120115207.55318-3-boqun.feng@gmail.com> 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: On Wed, Jan 21, 2026 at 01:07:34PM +0000, Alice Ryhl wrote: > On Wed, Jan 21, 2026 at 08:51:48PM +0800, Boqun Feng wrote: > > On Wed, Jan 21, 2026 at 01:36:04PM +0100, Marco Elver wrote: > > [..] [...] > > > > Note that it also applies to atomic_read() and atomic_set() as well. > > Just to be completely clear ... am I to understand this that READ_ONCE() > and the LKMM's atomic_load() *are* the exact same thing? Because if so, > then this was really confusing: > > > my argument was not about naming, it's > > about READ_ONCE() being more powerful than atomic load (no, not because > > of address dependency, they are the same on that, it's because of the > > behaviors of them regarding a current access on the same memory > > location) > > https://lore.kernel.org/all/aWuV858wU3MeYeaX@tardis-2.local/ > > Are they the *exact* same thing or not? Do you mean that they are the > same under LKMM, but different under some other context? Right, they are the same thing under LKMM when used for inter-thread synchronization when they are atomic. But when READ_ONCE() (and __READ_ONCE()) used on types that are larger than machine word size, they are not guaranteed to be atomic, hence semantics-wise READ_ONCE() firstly guarantees "once" (volatile and no data race with WRITE_ONCE()) and then on certain types, it's atomic as well. * In the case that we need atomicity, we should just use atomic_load(). * In the case that we don't need atomicity and no data race, we can just use read_volatile(). * In the case that there is a non-atomic concurrent write, that suggests we have a bug in C code or we simply should have some other synchronization. Or if we believe the conncurrent write has at last per-byte atomicity, then we can have `READ_ONCE()`-like function that returns a `MaybeUninit` to bear the possible tearing. Regards, Boqun > > Alice