From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 EBBDF40FDB4 for ; Tue, 20 Jan 2026 13:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768916789; cv=none; b=eu8ngwCVkexZbQsLDSBxCYoReSsCUCdHjf401ibyioPlIYKKkCpD8DtoQ9zhy/Tkth2/FJQ2TbjZKbKMhOukbfssdkMTte7xUi4p2qn2pSgepcLa9QCq3VLjC1BVPJ9+HZgr7MLLQQcfjWId1adcpDyWPgi+s3SWuG1bp50BGUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768916789; c=relaxed/simple; bh=y2corVxRFZhp6KNK2+4uobUAAg4FYICr7oMYMY/v8wg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nnlBId69yoypsUXMmFm2EudESVt7rWk98AzrPGHcQHdzJvq9bQzPpjVK1uJOwks8rDi3zw4z2ZaRjZSDKYbCuP0AONJc44DxeW7ZpRbMMyZwk+p81lrD+XV13PXo/iNcln+d9Uu1kGOban8+d7esTv9I1uTx+4Qul6RL1gYsh7U= 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=GYdJ0W+2; arc=none smtp.client-ip=209.85.219.47 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="GYdJ0W+2" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-888310b91c5so54898206d6.1 for ; Tue, 20 Jan 2026 05:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768916786; x=1769521586; 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=spiJEUz7YrJ9p2nUXIqRGXS2HMPY7smmsApThddibpI=; b=GYdJ0W+2b9lqFggO/Ra6CK7l6PlYf4iygEKex7UtkTgF0K7hk0pjJ26YphAL6VSn1j xjQh9fg+YQIklbsnWtPbZKUD69LZu4NUO31lsTp2O3tUOui277R9BCzAfY+mWuIHsYbb 1UlwFXc/0ZcSzbW/iTM7JJPrsmClLHusIWwuHgn9lDpIRIbQvp1Z8n5E2jHQ3GFuG+rD ilwItLXDZX+qs6u/69chQvk9Z8gCpNH03s4IYLPhouHC7seXnyp93f/6HSIMAjmjL8+J vReLLO/2/NIzPEcCpE9R7YpYMFDUhnXV8Is0UOejZnvacnGwr0iZUj7JN0NBijZu8sL9 +0TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768916786; x=1769521586; 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=spiJEUz7YrJ9p2nUXIqRGXS2HMPY7smmsApThddibpI=; b=Pe8zlYgV4+kd/BnUY09MgScTZut50vWfDCn1SL1i/lCYxFtRmnnZ1Ps5zjgdRx3LnN 3//6JdjGgA6KUzGzAkgd3TmQp+4q++e1Y8QK/i1E+1VgR8TYprM1XEktDr5zFEA050f4 rlWSee2QQG6TxpBRorTVvQJdJ8hPobAt3qVcSzi0v4Br+j1Lb3fmsoWMoDYDbUUXPYWR q0b7RNrZZOksJyjb0x2cDPW1x244n4gqUr21u8FP7G6IASkYeiE2wCWpjiJz/8n676dM +jk40kCiXwx62QjOW6PvygTyxHlaXoMPX51jQF+xmC2FO9mtLvcLZyRsmimlte+c4GsI E69g== X-Gm-Message-State: AOJu0YyoDdfdF3d0+JnV/SzV/cYdFv6Dc5gf/Lj+2/URB9CaZA/MkQb8 QFknZci0HYjyTh2IZLRZQqFT7fniesGJS0PvcpEq7gszIB8K0mq88CiJ X-Gm-Gg: AZuq6aKj4XXndri7ohlcZAGH7MD0R6pis6p4ft9ygGImOokhRF7E6CuDI7fV8Watu3G U29yuu48ulScY73WGixA7is8G1TPM9XJODl24QUI6xbvzfHPOtlt9nk/kXGVip2gl3zO331v2jQ SHCVwgE2fvp1Uh9xIYZeXpCFcsHEMWp2K+XYdSny+aIjN8YMMAuRv6dYKt64bulKlj50OLT++2g SIgvu0QLl98natfenmJpSHpGHP0Ho2PT5w/USaxyxMHQSQ03VWo25Mcbx2/wdQWxqL+53eV3Zvd Y6z+s8CXGx1xXqqQdLrlsME2/LBm8/k6MeKc+neAzIOdNCdlIJVlZvKMRtPFnhv8UAwyUqFJ1zL j5FCskhcxMlgADP4x7Bu8qwp1q8MWFiy9dUK7oYyoRO60Tqbwp6brBEUyx89zF6ZWVbALgvlGgN 2EEJ4VDeC7miDxc8VkjBeCVfqsTmCXTpPx2EC3umGwsqytJ0THllbzPIjpLsE4G87uSNK8D+L1p pKaM3cmaiPkxHo= X-Received: by 2002:a05:6214:212b:b0:888:6fde:7b72 with SMTP id 6a1803df08f44-8942d7e0460mr207178096d6.32.1768916785693; Tue, 20 Jan 2026 05:46:25 -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 d75a77b69052e-502a1dc88afsm92873801cf.15.2026.01.20.05.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 05:46:25 -0800 (PST) Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfauth.phl.internal (Postfix) with ESMTP id 21AB8F40068; Tue, 20 Jan 2026 08:46:24 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Tue, 20 Jan 2026 08:46:24 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugedtheejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueevieduffei vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvgdpnhgspghrtghpthhtohepvddtpdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehgrghrhiesghgrrhihghhuohdrnhgvthdprhgtphhtthhopehlihhnuhigqd hkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehruhhsthdq fhhorhdqlhhinhhugiesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlih hnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep khgrshgrnhdquggvvhesghhoohhglhgvghhrohhuphhsrdgtohhmpdhrtghpthhtohepfi hilhhlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehpvghtvghriiesihhnfhhrrggu vggrugdrohhrghdprhgtphhtthhopehmrghrkhdrrhhuthhlrghnugesrghrmhdrtghomh dprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 20 Jan 2026 08:46:23 -0500 (EST) Date: Tue, 20 Jan 2026 21:46:21 +0800 From: Boqun Feng To: Gary Guo Cc: 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 , Alice Ryhl , Trevor Gross , Danilo Krummrich , Elle Rhumsaa , "Paul E. McKenney" , Marco Elver , 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 Tue, Jan 20, 2026 at 01:25:58PM +0000, Gary Guo wrote: > On Tue Jan 20, 2026 at 11:52 AM GMT, Boqun Feng wrote: > > In order to synchronize with C or external, atomic operations over raw > > The sentence feels incomplete. Maybe "external memory"? Also "atomic operations > over raw pointers" isn't a full setence. > Ah, my bad, should be "atomic operations over raw pointers are needed", > > pointers, althought previously there is always an `Atomic::from_ptr()` > > You mean "already an"? > To me, it's kinda similar, but let's use "already" > > to provide a `&Atomic`. However it's more convenient to have helpers > > that directly perform atomic operations on raw pointers. Hence a few are > > added, which are basically a `Atomic::from_ptr().op()` wrapper. > > > > Note: for naming, since `atomic_xchg()` and `atomic_cmpxchg()` has a > > conflict naming to 32bit C atomic xchg/cmpxchg, hence they are just > > named as `xchg()` and `cmpxchg()`. For `atomic_load()` and > > `atomic_store()`, their 32bit C counterparts are `atomic_read()` and > > `atomic_set()`, so keep the `atomic_` prefix. > > I still have reservation on if this is actually needed. Directly reading from C > should be rare enough that `Atomic::from_ptr().op()` isn't a big issue. To me, > `Atomic::from_ptr` has the meaning of "we know this is a field that needs atomic > access, but bindgen can't directly generate a `Atomic`", and it will > encourage one to check if this is actually true, while `atomic_op` doesn't feel > the same. > These are valid points, but personally I feel it's hard to prevent people to add these themselves ;) > That said, if it's decided that this is indeed needed, then > > Reviewed-by: Gary Guo > Thank you. > with the grammar in the commit message fixed. > The new commit log now: In order to synchronize with C or external memory, atomic operations over raw pointers are need. Although there is already an `Atomic::from_ptr()` to provide a `&Atomic`, it's more convenient to have helpers that directly perform atomic operations on raw pointers. Hence a few are added, which are basically an `Atomic::from_ptr().op()` wrapper. Note: for naming, since `atomic_xchg()` and `atomic_cmpxchg()` have a conflict naming to 32bit C atomic xchg/cmpxchg, hence the helpers are just named as `xchg()` and `cmpxchg()`. For `atomic_load()` and `atomic_store()`, their 32bit C counterparts are `atomic_read()` and `atomic_set()`, so keep the `atomic_` prefix. Regards, Boqun