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 4EFDF1EA73; Thu, 10 Jul 2025 12:01:08 +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=1752148868; cv=none; b=QPG5v3ytJ9NipvDZTl8gdXOfgUlKPHkhIR33spNGVG697elbjzT6dO4GqJVXqluy4B+ioh4DnIgsOVeG6sjmpwEzw2STUr/tKB9xdGuPAHmdGYCxobdfdi3u0Bik1q6tG2oXgbFjXKbkVtFwMD4tQXfrLYcBrn/U1UUs4tcfMsw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752148868; c=relaxed/simple; bh=xlOKUHxAG5+wDJb2IC+FgPeerBVxfJ6Ohz+JMX7/gpI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=o0uka/Oac72rZ+w8isqfg8Ske7cTdS5g4L2C2fqNhfKWawq1aCZea8NK8Lv4G3ZbZq6NXLA9lGmK2TbqYRYxYq0m9qHD0dGrzujrmTwtntgdQg8B2/mZ0H5VHlojaB32BsdWbwbrlSADVAiOdZPj4pKk5efFqBnYFGTLsuBtnUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W6nv30q1; 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="W6nv30q1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E000C4CEE3; Thu, 10 Jul 2025 12:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752148867; bh=xlOKUHxAG5+wDJb2IC+FgPeerBVxfJ6Ohz+JMX7/gpI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=W6nv30q18H8QhIFXyBVNo5oXW0gI/m+DesNOelLmRsQkbSUQMuruGa9bvwZn1hblG olZk7orPdkztCj9aZy46xyY9ZOYIqwpHjrCpm7xGNnfqfYp+yFNuyFr5DOcENbVxSj AZJJ9tq0uh3A2taBqFaJWTC3cmTQxKa1XWm8525tRxQbSrX7LENZeF18+wTwywg49r pGMhGk9Siao5Pw4JOivaoF6B7rHRm4vmo0IhZ/1DUUSlaRlXpm77kQzuWnFmjpUYkv Z+IJ3Tu94t+POIiPdkl6CJXLtH2ibipoWm0zC/EyyeDxO46i99Hd4CGoVx2BG0dmsk smk2Tb9A6tQNw== From: Andreas Hindborg To: "Benno Lossin" Cc: "Boqun Feng" , , , , , "Miguel Ojeda" , "Alex Gaynor" , "Gary Guo" , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , "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 In-Reply-To: (Benno Lossin's message of "Thu, 10 Jul 2025 13:08:19 +0200") References: <20250710060052.11955-1-boqun.feng@gmail.com> <20250710060052.11955-4-boqun.feng@gmail.com> <4Ql5DIvfmXBHoUA428q2PelaaLNBI5Mi0jE3y3YPObJLRgY73zNZzQ8Pdl2qq25VWsMQFKUpYRHHQ1e7wFaGUw==@protonmail.internalid> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Thu, 10 Jul 2025 14:00:59 +0200 Message-ID: <87v7o0i7b8.fsf@kernel.org> Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Benno Lossin" writes: > 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 = x.load(Acquire); >> >> relaxed users: >> >> let r = x.load(Relaxed); >> >> doing the following: >> >> let r = 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. I agree with this observation. Best regards, Andreas Hindborg