From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CBE7245005; Thu, 10 Jul 2025 11:08:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752145706; cv=none; b=UkCqhItp32YIOzg9FyU/UFM2SM9OcMdU5ja+VsueZGEozmC9C7Z8sM4eBWbUsOvW6LRECZ0OBFvnOrCraGzU7rzyJskqJ0wZEROhw8V8PiANTFBQFGYlF1P3g/kqmF0VnuPN4Glqz/v+iRZD5lR4eXHZNjF0w9vypEHfDQ46T0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752145706; c=relaxed/simple; bh=06vmJVYbLt+NdxRw+Ts2u7M9TMq+jFYPoVoc4jfx5DE=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=C6tToaH9RnaG6hGP5O4dh+QA7arGBiRaWBZVDeUEa1scwSFwfTkJHNuabxD4i9jcynCSkDn2V3RzMGBTxrqlgt2y7JurjOzXOJwBPr7vOeo7MPk/d7rpixeGI5hf8BmX0z3DZefwk44gQsh9WtPlyuXpwTzWrGGyXgijg2sSlVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=THu2ivw0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="THu2ivw0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B0C9C4CEF5; Thu, 10 Jul 2025 11:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752145705; bh=06vmJVYbLt+NdxRw+Ts2u7M9TMq+jFYPoVoc4jfx5DE=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=THu2ivw0Azp6h1Coq9LNqnWIQJt2eeAuvAMfMDk/1Pl949Jy6p4pagXuo50tkjfcb MUxi3hvEJL+yzuyk5grkP1oOktMR/nXgOqEBvHCLDFdKoeEVra7ujiSmyYiUvrNrKI c5lPmrB/dYkfX9Ghbvzn+4/JDX6i5bUyhefwKKw+GkSWJ3biK/MpFBBebKaPZliXyH r8ZIiSl0c8ElnFWmxhGNCynTnWB3w7WyJ3c4Amkhp3FYoO6ZTYug0k4XA2r2OULrOQ JVAVxWs1pz0isQ6AYUImqPWmQp6N/OD7XgxNTaFlj2BbEG0wfXfnkgkLkZjm3/z7n+ tqmrhcmMDsXDQ== Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 10 Jul 2025 13:08:19 +0200 Message-Id: Cc: "Miguel Ojeda" , "Alex Gaynor" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Danilo Krummrich" , "Will Deacon" , "Peter Zijlstra" , "Mark Rutland" , "Wedson Almeida Filho" , "Viresh Kumar" , "Lyude Paul" , "Ingo Molnar" , "Mitchell Levy" , "Paul E. McKenney" , "Greg Kroah-Hartman" , "Linus Torvalds" , "Thomas Gleixner" , "Alan Stern" Subject: Re: [PATCH v6 3/9] rust: sync: atomic: Add ordering annotation types From: "Benno Lossin" To: "Boqun Feng" , , , , X-Mailer: aerc 0.20.1 References: <20250710060052.11955-1-boqun.feng@gmail.com> <20250710060052.11955-4-boqun.feng@gmail.com> In-Reply-To: <20250710060052.11955-4-boqun.feng@gmail.com> On Thu Jul 10, 2025 at 8:00 AM CEST, Boqun Feng wrote: > Preparation for atomic primitives. Instead of a suffix like _acquire, a > method parameter along with the corresponding generic parameter will be > used to specify the ordering of an atomic operations. For example, > atomic load() can be defined as: > > impl Atomic { > pub fn load(&self, _o: O) -> T { ... } > } > > and acquire users would do: > > let r =3D x.load(Acquire); > > relaxed users: > > let r =3D x.load(Relaxed); > > doing the following: > > let r =3D x.load(Release); > > will cause a compiler error. > > Compared to suffixes, it's easier to tell what ordering variants an > operation has, and it also make it easier to unify the implementation of > all ordering variants in one method via generic. The `TYPE` associate > const is for generic function to pick up the particular implementation > specified by an ordering annotation. > > Reviewed-by: Alice Ryhl > Signed-off-by: Boqun Feng One naming comment below, with that fixed: Reviewed-by: Benno Lossin > --- > rust/kernel/sync/atomic.rs | 3 + > rust/kernel/sync/atomic/ordering.rs | 97 +++++++++++++++++++++++++++++ > 2 files changed, 100 insertions(+) > create mode 100644 rust/kernel/sync/atomic/ordering.rs > +/// The trait bound for annotating operations that support any ordering. > +pub trait Any: internal::Sealed { I don't like the name `Any`, how about `AnyOrdering`? Otherwise we should require people to write `ordering::Any` because otherwise it's pretty confusing. --- Cheers, Benno > + /// Describes the exact memory ordering. > + const TYPE: OrderingType; > +}