From mboxrd@z Thu Jan 1 00:00:00 1970 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 21D0C32E6AC for ; Tue, 6 Jan 2026 13:09:43 +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=1767704985; cv=none; b=gJ9GoWc6qwpWhsZVR3rutBZqLzfKA1z2GjwcFIrHeX9zxmG2R2w/T98fjGFAJeHr0JOzxER0DRCtV4uXh3rneQkHPdp7ezC+EL7waIcyeon3isRK+xvJiHFYTTE9WT/av0nSHVCuU5UGfNjr9ZIti7qBbPB8XSU990OKJ0TEquo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767704985; c=relaxed/simple; bh=7vNqbhncbz2ImZAWXhLrEG8jeofeaKSGrO+Rt1M8f0I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YSA5ykqqn+pkGu6fk/55EzMp4KOob4dNmI8nfdDM129IlazStx5B7AARXEf3kZMxrf/j8p0XimrBTem8BPutmq6w9wnsNkRgBYXq4xBmwMcBxSYo1gZKNhZ4AdzbTAU0ZTWSxZIhc7lLxTSi4vSrJIpLyeEjaC03iqeBWkX+D+c= 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=RVe5xUIT; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RVe5xUIT" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-8ba0d6c68a8so90453185a.1 for ; Tue, 06 Jan 2026 05:09:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767704983; x=1768309783; 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=JpzahlfiGpAFEOQGjh5jjjaXUgZ9jhcXoloaQUEBJwU=; b=RVe5xUITdR78PuScG3gXhIryZDhqamHfCSere5daOlkm3u7xWsadhsSeh4KGP9RP86 3HRsAdemsSYGZdq15BM+8S+AhguN/z8ioIY/Ca5DKx2lYn2okFiD6PvQQqSNj3ul3byE 1o32TVcYRePiMSNKlmJA2/OFKhZW1ocSO1K6nAaURXbdDpbfPiybkQVPdSvfNS8vw7IN VCivcw5qYqfadvl0h7qZC/7jRiJw2awIa6Pzfigpx2zAkUTkqQvi3ljqncEnm+BZnmCC hL1pNbiICJ1zQT86xDAv2kyfmdPOumuTE1BVCjbQBZTu/rBvZ36l9ymf0SFNqIG6Jc9E +7jQ== 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=vNT6Fkxh0wEND+JM9WJHHVkqbNv7s1p3IYii7Y5S+e/WJy1lh88Q8s5TDEQLhJFQIJ UxY8uwEn324HrS5I4T9zaFR+X7THdvBWtwt0WAWDVkPo6zDjJ/oVYPxNfvt5Yzmz5Bi4 wkHhjZ7nnc8PXQFv1PAcUkpjUFds0STkAlzlEWTSWAzGHQStsrAzCV06rhqwKe44PuvE MQrO12b+HUH+tm2cUZQrRa9zjteopB1vk0sz77TY9SQ+Cpfl74N592JojjN5905s67Mh J+9v7jUa177XayHLXr+lrsAvgS5bPyDlCWRuCK6rVgbfJhBV7bga1X7nijgMBq16O2eQ D5Pg== X-Forwarded-Encrypted: i=1; AJvYcCX7TaLhWtC35JTR06/16iCc8MBcjJcVPMuc2gvzMUTf6c1mWX3iiEAnptD8ceDPNpoGtAneZxFiPl3L3o8wdQ==@vger.kernel.org X-Gm-Message-State: AOJu0Yxw88F7axP1xf4+Fuz3IBhk7gYNvw00pg/jVdxCs37JgMHsOQSr Y+//a1SyhxAuPsPTVLefXExQVRNSFchV11GCtdptcNDWbVluiMKSMPjZ X-Gm-Gg: AY/fxX7QpKyQ8V8P+ZzbOe2s5UAu9S/vGtpec9uyHsjWVqcaUgyKRz73121ZKh17W9Z fbzfXIP/8K2FIAZu6MgpF7kz3t3S4SETM0wJPJD2g6m+VmENzWXZpshrwFyR1oofPY3XGWm+FXU 5VNmFU1M5ZUiqCNF9c9280QC2crs6ZHGC0jyl70/2Ls4u21W2zCrsA8mbYryKA0NGz2cOSzIlzp O2fIgKy4hiKYCNfyUaQw+OwWSNAiSOAYZNZQKmBdiAIcupNmUzivOFKjbLTPTnbdTVSWHAjIey9 sp/cyCUAVMZXra+KbDvJZJmyjtknTEnnSBLeV7EVk+3tX5o0cUbEf8SprUkcJeBXFUw4OQ7ECF+ mKgmZUyqBzNW2obNqr4uHQQSUIB7yKPFZh0L3azIRttjNHgjTnBSdRMplFo3dqrvibmAZFTYlVo FL87W/y32oyssDsLOQaEFOM7NEtrX/ODtAnv2LDIoS3VxHB8enhIwd4AFo1aCd+ACxQw5S2NoEC NyHjO+Mxa6Wr5w= X-Google-Smtp-Source: AGHT+IE/G8uVi22ATP3WXoVJPNVxriboWDTjcasbHlPDtJRw+IZ7O9Erdw+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> 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: <87fr8ij4le.fsf@t14s.mail-host-address-is-not-set> 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 > > >