From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F92FC27C6E for ; Fri, 14 Jun 2024 10:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VZdOPT0IhzqnwElx9CAZHlmPaCQb8QSNaNtOuCpLMiw=; b=kU4wyH04bo+t8n5JVepg/n1dxw dWoQfWLWq8Na9cjl1/yEtYj4a49L44fFGFKUuwFOS4QGSPxNrva4VHi9Y3f+52RSuxxs6PXajh3aQ oURH5pm5maKu7cThFxLAz3ISRyNPALhcpknCu2lPRbeT3OW7hATwVvTT14qRBHBxj/Q3NLBGRpqFl jltC5uu9+SqjBsFISn2/3R/x7fsF4I8YI1KW/G+YgXrdxBbEzBHmKWlhnzNAJ9ICgX5Gz0aV848iB 2M1DDJ5KbdZnTNqTBhxm1RYGxc2QbXPP/59yzNh+GAp50Da8rNBGtEMPoo/v7uJqGb2V6aVAfegB1 C2WL7bVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI4Dq-00000002RpO-1ZRf; Fri, 14 Jun 2024 10:31:54 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sI4Dk-00000002Rkl-1etE for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2024 10:31:53 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 19E4BDA7; Fri, 14 Jun 2024 03:32:09 -0700 (PDT) Received: from J2N7QTR9R3.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BA53B3F5A1; Fri, 14 Jun 2024 03:31:38 -0700 (PDT) Date: Fri, 14 Jun 2024 11:31:33 +0100 From: Mark Rutland To: Boqun Feng Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, llvm@lists.linux.dev, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?utf-8?B?QmrDtnJu?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Nathan Chancellor , Nick Desaulniers , kent.overstreet@gmail.com, Greg Kroah-Hartman , elver@google.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Catalin Marinas , torvalds@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, Trevor Gross , dakr@redhat.com Subject: Re: [RFC 1/2] rust: Introduce atomic API helpers Message-ID: References: <20240612223025.1158537-1-boqun.feng@gmail.com> <20240612223025.1158537-2-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240612223025.1158537-2-boqun.feng@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240614_033149_177930_66ADA0F8 X-CRM114-Status: GOOD ( 17.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 12, 2024 at 03:30:24PM -0700, Boqun Feng wrote: > In order to support LKMM atomics in Rust, add rust_helper_* for atomic > APIs. These helpers ensure the implementation of LKMM atomics in Rust is > the same as in C. This could save the maintenance burden of having two > similar atomic implementations in asm. > > Originally-by: Mark Rutland > Signed-off-by: Boqun Feng FWIW, I'm happy with the concept; I have a couple of minor comments below. > --- > rust/atomic_helpers.h | 1035 +++++++++++++++++++++ > rust/helpers.c | 2 + > scripts/atomic/gen-atomics.sh | 1 + > scripts/atomic/gen-rust-atomic-helpers.sh | 64 ++ > 4 files changed, 1102 insertions(+) > create mode 100644 rust/atomic_helpers.h > create mode 100755 scripts/atomic/gen-rust-atomic-helpers.sh [...] > +#gen_proto_order_variant(meta, pfx, name, sfx, order, atomic, int, raw, arg...) > +gen_proto_order_variant() > +{ > + local meta="$1"; shift > + local pfx="$1"; shift > + local name="$1"; shift > + local sfx="$1"; shift > + local order="$1"; shift > + local atomic="$1"; shift > + local int="$1"; shift > + local raw="$1"; shift > + local attrs="${raw:+noinstr }" You removed the 'raw_' atomic generation below, so you can drop the 'raw' parameter and the 'attrs' variable (both here and in the template)... > + local atomicname="${raw}${atomic}_${pfx}${name}${sfx}${order}" > + > + local ret="$(gen_ret_type "${meta}" "${int}")" > + local params="$(gen_params "${int}" "${atomic}" "$@")" > + local args="$(gen_args "$@")" > + local retstmt="$(gen_ret_stmt "${meta}")" > + > +cat < +__rust_helper ${attrs}${ret} ... e.g. you can remove '${attrs}' here. [...] > +grep '^[a-z]' "$1" | while read name meta args; do > + gen_proto "${meta}" "${name}" "atomic" "int" "" ${args} > +done > + > +grep '^[a-z]' "$1" | while read name meta args; do > + gen_proto "${meta}" "${name}" "atomic64" "s64" "" ${args} > +done With the 'raw' parameter removed above, the '""' argument can be dropped. Any reason to not have the atomic_long_*() API? It seems like an odd ommision. Mark.