Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp715080lqs; Fri, 14 Jun 2024 03:44:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOv7KvJxhUMTe3d45LZ/8rmLrENaK0S2JWSgRhzKaWE8eTz59HWQEnMX1mJ1+yeoFq+NEK3+9YKvTZ3s6/Xfy2dL/fiO9V4J6GIhfypw== X-Google-Smtp-Source: AGHT+IHL18u8DGox7ieh1g3VOOAu8iSz8fb35sZHuuC5o8hRIBAuQAMDTffhZEX69PTopKVwYan7 X-Received: by 2002:a62:6503:0:b0:705:a18a:6870 with SMTP id d2e1a72fcca58-705d7122393mr2069417b3a.5.1718361859527; Fri, 14 Jun 2024 03:44:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718361859; cv=pass; d=google.com; s=arc-20160816; b=hZcFy4WXaVVEENtHNxrCzv3jHYQsMKwBL56OTVMFIf3TXL4pylYAd7x1RjXNMhczgX 3IT0xdFgwDlpztvSQi69wMKrOtT+QvO3zKBzwfDbKzKBfPfJZj+byAz1HbAOYtBAtF9V iedsWfuKqBe590/HMwj/V/rbXYSFZ/nVzfie3lGFOEc3D0J0tjMouvq/dO+f+MgCaZGQ C5ZU2W2P3l2AZpZ1hVpnVbFSJfE75yqcylC007mW5MFXAqBZobdiywNltC80xziY4gms QpmF0bY1JKECW8w+nc2io/JGAwHh1ce6etK/rLHBJmLG7DZPa8FLJS55W+luVocbHDUT AOLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=VZdOPT0IhzqnwElx9CAZHlmPaCQb8QSNaNtOuCpLMiw=; fh=ntTAZX4PTnAGrhGn4J7adVlQM4PL5Z4oztw7WpjKpYE=; b=h4U6IwVXSWG1S+trc9Hethtl1ku5+geCjPRIq84UAl9MtlSIgOvw+L5uj9TVHzeSrZ iRO3TivoYQsvyO/i0nSFZc97ez99cglmEY8G4Sc7liJoyy4fYaWXGu8QbAVsDN2r/yD2 yJlK1O6q4Wt7iRmBl8fG+BMdluYYHOumEu5zw5EJylbLVChnb3iPtKuo0u/30JBqfg4x pHqNvG/djz3NV7PcQ0lUcteInTJtsbzQjXIQYratv7ujRMykSR3nIIxFD12YFNHJcZFa EGp5jB3jdBW3Lvy538ObguZgr3ZIVcAEQ/7D846yYxjI29DRYTI1QbVzo6rJXp0bviIG YBdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-214790-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fede823787si3305762a12.223.2024.06.14.03.44.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 03:44:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214790-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-214790-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214790-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 877DF289BB0 for ; Fri, 14 Jun 2024 10:33:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BCB5195F22; Fri, 14 Jun 2024 10:31:49 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57C8E146582; Fri, 14 Jun 2024 10:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718361108; cv=none; b=NCvB/Gn9V6VW343+VHT3MyK+Lf6sD0/Ly6Mq9W1Bt7GC//PrMQs90Qf2edrohdX3Pome4cMPMuwUMJnRXRC8u5cuVMbClw9GosNBtA0aZuJJ4NxZTt3jL/8JQ94N5bHeQf8utKdkq8Ex1Llnpx0lz6tbQvrDkAaENXDy1ES9gJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718361108; c=relaxed/simple; bh=7/o+RQWCaaNGrfSufObH0pCcC/HZRaVC09CWwpJrhtU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=An6IhnO0THzhSap6GAwhXYmUDrCrdftdUJi0edSPhD5T0zeeChArTpCOIP2VLLnjJkZH2RqAFNB4f7LbkprjyFB5mVPOXMW87qpa2ga1apklo0X4hUQXf3fbL1XFSUzH1S0iwCO/3bm4X2lSmYp1O1QTvLtrysrKkaNJt4P7Lrc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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> 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: <20240612223025.1158537-2-boqun.feng@gmail.com> 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.