From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 95197242D70 for ; Wed, 21 Jan 2026 02:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768962925; cv=none; b=fRTUnxQHQNr25EkwuoyVtaKldCYwZeaxQVHi4zJAFYe4YNhBDsD4+Ooa0QS/NEpd0oF61u41A0u7Ji7gLIH4bmx6H0ZQxjMB2sGEFELUN6I/mRfK8JcZaxsTU9/+3snnhoRRhGnkt4DRUOSId//on0pkojDWTYEBxu38ug7YTro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768962925; c=relaxed/simple; bh=YycTiJrPuZ50XWbU+aKf4d35PZCgfYUN6bofn1fuMIY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uHlWJknWfWGo85g+qgKlKg1YiqEwsn6TdMhCGz0ICBAlJ339boGskhk1vJc88DZ7lMVOaA/MzJ1EaffsLptONZzg7Vfvj1Dly7cStT3D5fe6X6jBamJ33JR9mRPEbB2MeQYnWMCLOn1/mqC6NzbYQ35YctrLoLBd7/gY2mAOXRk= 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=dtV/tJov; arc=none smtp.client-ip=209.85.160.170 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="dtV/tJov" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-5013c912f9fso69573711cf.2 for ; Tue, 20 Jan 2026 18:35:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768962922; x=1769567722; 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=/SYWzQFciEmh1FoU8deqlPVu+NRiIm4WLmRuTDTk8Qc=; b=dtV/tJovqzzyACr5s1G+/qmbQ4HHdR5Q4w8KN2zr73rZScisHI6J+9avAKYtKDZHBn m/v8wSq5iv7dvhnJiDY1BdX7NqXZtPG+QTKIbCKJvq+YjSOOj8CPrWmorlt3E4cn1t5s S9yfwMzZVZ1Jf3j4Lev0sPCKWZMHVP0VykYu0pNjZlJSQmEGwiFO5BpPxLBCelrUFdYL WoQAfQr6OyKo+FtvoEjIb0w0FSxFvhMtfWbpGttxhxT15dZQmk4LW0taXsztFyjp7Ysh 4z/2diXWLlC3m3Da0ST+cZsBn5bzJttibon/WIx4sWMrO4/EMkcPIE9mhXxSFHMSEeVO UXJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768962922; x=1769567722; 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=/SYWzQFciEmh1FoU8deqlPVu+NRiIm4WLmRuTDTk8Qc=; b=Th2aJYt0ARklkjTChMIfTGt0n+S5WqK+TCizMifkxOH1wVEj8u6NDFRupqpUqzOTfL nfePouJWmdidUdXfji/32OnptRJB6dWozsPJLSp5AjBp5MZ/YQqE7jTBhE8c49Mo+hJy /HgSNekIoRyHGxDOJYKmt7bfajJJfhc5bOXtjBKqAToAkjoaFNmmuiiut2QpWWzWr9rz BKmDcfRrt/4qmCy2Hw6pCc1BSRjBZmefjZ9g6ZfDas/PjgraXVCZ643U6kkd/QQ456kU YSsVQULJtcjcNJe+fC7NbiGUI+ssmZnb0vAH58noSj1uX7412BjuaIEA0wOrRrHGHkmH fUpA== X-Forwarded-Encrypted: i=1; AJvYcCVGB+ksoF+UdxmV8vWTgxkAnwuo7Tnvh54Df0x6zPGMZ5K5Pq6uuAf6IhyZMObDcK7+FgLiAkiSVnnlK+Er@vger.kernel.org X-Gm-Message-State: AOJu0Yzka7ikjFy/214eaPh9zlUVYnnixto0N2in7u5gzAFy7VyDPg6o M/l2NtQK8JWfXTMc6Y4W1PhR/O7wtfGNin3vvSqfQCQIVx9nOd4FcuB/ X-Gm-Gg: AZuq6aLdAOQynvQ+mLW1YYJaVtZgWa5evfDVWoBGl7ko4bcicsZowLZ9fwDYLsn3m+R tRRYOYKktck6pmifVBHup6dvUWd1XwmoTfqrDvPqlZqiR/x6BkVSOlb//fChloeJi+iHNvWZBma dHM18AFOmpdmvB+b0/A+FX4aOnPp2Glhy/S+9PWSo8NAX92WcBogrpediC60/F4pgezjCEyGyL+ wuvffhMPk1bodVRqr2WsL7NOYkC9ASAbUIWCH/Q7th6w6x5rpzkQwPuUi/spn/LiPzJ5igQgAFi H8C/iLpp5McrUx3Rtb01qcHGp+yGkH8kITq2yrv0WHqnO0EpNic2Ch0ETCaYWnuwRplOEZAYlip k8h2UzhZ06hHe8OYoROBLIzGXz4I95RD1haLI7G2CidLjTLdZW0UZozgNDAqyv1c0G0RBLt55WO 9NMY/+TXjirAmMBiVpm1zGw/O6YMWXUJCA9K8dfamLp0ko8SU2GmRxfJVssLhFR9Ngyf5bG0vI+ dtERlRLLyvs0EM= X-Received: by 2002:ac8:5e11:0:b0:4f4:d298:b47c with SMTP id d75a77b69052e-502a1e07becmr238961631cf.28.1768956457813; Tue, 20 Jan 2026 16:47:37 -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 af79cd13be357-8c6a7269277sm1143950785a.43.2026.01.20.16.47.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 16:47:37 -0800 (PST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfauth.phl.internal (Postfix) with ESMTP id 9A38FF40070; Tue, 20 Jan 2026 19:47:35 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 20 Jan 2026 19:47:35 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugedukeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueevieduffei vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvgdpnhgspghrtghpthhtohepfedupdhmohguvgepshhmthhpohhuthdprhgt phhtthhopegrlhhitggvrhihhhhlsehgohhoghhlvgdrtghomhdprhgtphhtthhopeifih hllheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgvthgvrhiisehinhhfrhgruggv rggurdhorhhgpdhrtghpthhtoheprhhitghhrghrugdrhhgvnhguvghrshhonheslhhinh grrhhordhorhhgpdhrtghpthhtohepmhgrthhtshhtkeeksehgmhgrihhlrdgtohhmpdhr tghpthhtoheplhhinhhmrghgjeesghhmrghilhdrtghomhdprhgtphhtthhopegtrghtrg hlihhnrdhmrghrihhnrghssegrrhhmrdgtohhmpdhrtghpthhtohepohhjvggurgeskhgv rhhnvghlrdhorhhgpdhrtghpthhtohepghgrrhihsehgrghrhihguhhordhnvght X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Jan 2026 19:47:34 -0500 (EST) Date: Wed, 21 Jan 2026 08:47:32 +0800 From: Boqun Feng To: Alice Ryhl Cc: Will Deacon , Peter Zijlstra , Richard Henderson , Matt Turner , Magnus Lindholm , Catalin Marinas , Miguel Ojeda , Gary Guo , =?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 5/5] rust: fs: use READ_ONCE instead of read_volatile Message-ID: References: <20251231-rwonce-v1-0-702a10b85278@google.com> <20251231-rwonce-v1-5-702a10b85278@google.com> Precedence: bulk X-Mailing-List: linux-fsdevel@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: <20251231-rwonce-v1-5-702a10b85278@google.com> On Wed, Dec 31, 2025 at 12:22:29PM +0000, Alice Ryhl wrote: > Using `READ_ONCE` is the correct way to read the `f_flags` field. > > Signed-off-by: Alice Ryhl > --- > rust/kernel/fs/file.rs | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/rust/kernel/fs/file.rs b/rust/kernel/fs/file.rs > index 23ee689bd2400565223181645157d832a836589f..6b07f08e7012f512e53743266096ce0076d29e1c 100644 > --- a/rust/kernel/fs/file.rs > +++ b/rust/kernel/fs/file.rs > @@ -335,12 +335,8 @@ pub fn cred(&self) -> &Credential { > /// The flags are a combination of the constants in [`flags`]. > #[inline] > pub fn flags(&self) -> u32 { > - // This `read_volatile` is intended to correspond to a READ_ONCE call. > - // > - // SAFETY: The file is valid because the shared reference guarantees a nonzero refcount. > - // > - // FIXME(read_once): Replace with `read_once` when available on the Rust side. > - unsafe { core::ptr::addr_of!((*self.as_ptr()).f_flags).read_volatile() } > + // SAFETY: The `f_flags` field of `struct file` is readable with `READ_ONCE`. > + unsafe { kernel::sync::READ_ONCE(&raw const (*self.as_ptr()).f_flags) } Not a question directly to this patch, but for FS folks: I see we read and write `f_flags` normally (i.e. without *_ONCE() or any atomic), and I don't see any synchronization between these read and write (maybe I'm missing something?), if read and write can happen at the same time, it's data race. So I assume we must have some assumption on the atomicity of these accesses to `f_flags`, could you may share or confirm this? Thanks Regards, Boqun > } > } > > > -- > 2.52.0.351.gbe84eed79e-goog >