Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1534012rwl; Wed, 5 Apr 2023 19:40:28 -0700 (PDT) X-Google-Smtp-Source: AKy350bMzoTeXYdHzLIaprE4rO0dmLUXYh3givHGJbX6EZcF2rq+/DMYoEueJYL3Hk8zovshD7Pn X-Received: by 2002:a05:6a20:19a:b0:d6:f3dd:5a88 with SMTP id 26-20020a056a20019a00b000d6f3dd5a88mr1470963pzy.5.1680748828646; Wed, 05 Apr 2023 19:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680748828; cv=none; d=google.com; s=arc-20160816; b=jJL7YN86HOjB5RlqnciQVk7uI6O/nvZxbkdos1SzDXrdyaStrkBnYAq79qJybSuIb+ TEnaQ8ul77O9XiiC226zDVGcFxNIiBgHy/0fIxQoe7bSO/tmIckoitZibGHNEaHyTMdr +ID+isqKChKAToy9k/hZXCWPfbnTjeLWnuKcY0BqIxpue8ZKwp++tgfI1299z4iM4YWS mx7s+KzxvIKbgy577SVDfN82XBqnk3PUKfyeI+R2rz5n3rw/v2udWqGM0D7NoNeoY50f TgRU8rkyqB1MCKqPdsf4mT2wuLo/vJyZBsZuDZ9gGhOaQ+iy82tgZccSLa/47exDrdes v4Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9Mf8Zj9l99NRXWwVRZPOJWvufbRrMXXXtecx7GSQsow=; b=mzDrw8KMW8+2DAprLHaMJd5fj8+p48Wwlh35YlEy3Vp9oF7DGlAHYpNi02Czpp25Zs /7/PXq7f7pGP6zIjp2kczrDvEobcTCUedv6NqagWA5cce5/I5fBtE2r+fgRn1xNDdi82 EI4Pjb6k3cF9fuYkV/k0UNYu8lQlImTonFRfbLAQQBWCulYTJ1WFFxgvMV3UZS+dCuDs NfSplxQpQXa8/Wre9D+LgVkc9fwVs9Rrb7Ph+LWmwhNiSsZDess33brmNEF0hPxrOmws LIZlArXHFG+HJb89GQbeGMfEQLK1SMr1ba++IeJvYM1UhRjeN5dMVskx8FxRDskMOcyN Xltg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MTM6vfcX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v188-20020a632fc5000000b005098f98e16csi132052pgv.321.2023.04.05.19.40.16; Wed, 05 Apr 2023 19:40:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MTM6vfcX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234712AbjDFCkP (ORCPT + 99 others); Wed, 5 Apr 2023 22:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjDFCkO (ORCPT ); Wed, 5 Apr 2023 22:40:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70CF7121 for ; Wed, 5 Apr 2023 19:40:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0CE116421F for ; Thu, 6 Apr 2023 02:40:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74350C433A7 for ; Thu, 6 Apr 2023 02:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680748811; bh=LkwP71SP/70ZN7M7Tv0EhvcohUjcinoOGkY82vHCOIo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MTM6vfcXqjdgV9GdqsYJUtrE4BqMldYTjp7lpRIMw4s00ZdAmL8ieghHZMw5ZsteZ axdWzcrxpeaSAPJ01Y9RjHvUWfdGDMlRKP8DrYisI9ce8HIBE+rf9iFO5f7HSViFDO FitcbcvmEzDIdhBok/zX/6gaUJExy+GMQDidhcABEW9nFWXZbIXC/RAX6ouigQUN/J EBApsb0loXxcBYx9es0E9qmjMHPzxgY1cPO06J3b3gZ35UveohjY5tfTR+F5Ht+g0j a7gpjiYFnsBfQibKonJbnTgPU3C3Aa689O9QEVkI5dQJVtdiTlUlxIHdU1D5Ub5OLv UvAsZAhEEVPbQ== Received: by mail-ed1-f51.google.com with SMTP id t10so145729444edd.12 for ; Wed, 05 Apr 2023 19:40:11 -0700 (PDT) X-Gm-Message-State: AAQBX9fE1AG8O8ywgIMH7+3Asq/mrqjJ22KWbGMCU9DELi2ERP4lgNEv 9ZzTxcenAxs8o7f3DtwRPj3vy/IWZENgyeJUxdg= X-Received: by 2002:a17:906:2b49:b0:939:e928:5323 with SMTP id b9-20020a1709062b4900b00939e9285323mr4893999ejg.54.1680748809602; Wed, 05 Apr 2023 19:40:09 -0700 (PDT) MIME-Version: 1.0 References: <20230404163741.2762165-1-leobras@redhat.com> In-Reply-To: <20230404163741.2762165-1-leobras@redhat.com> From: Guo Ren Date: Thu, 6 Apr 2023 10:39:58 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v3 0/6] Deduplicating RISCV cmpxchg.h macros To: Leonardo Bras Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrea Parri , Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thx Leonardo, It's a good point for cleaning up. On Wed, Apr 5, 2023 at 12:37=E2=80=AFAM Leonardo Bras = wrote: > > While studying riscv's cmpxchg.h file, I got really interested in > understanding how RISCV asm implemented the different versions of > {cmp,}xchg. > > When I understood the pattern, it made sense for me to remove the > duplications and create macros to make it easier to understand what exact= ly > changes between the versions: Instruction sufixes & barriers. > > I split those changes in 3 levels for each cmpxchg and xchg, resulting a But how about merging 3 levels into one? (I mean one for cmpxchg and one for xchg, resulting in 2 patches.) > total of 6 patches. I did this so it becomes easier to review and remove > the last levels if desired, but I have no issue squashing them if it's > better. > > Please provide comments. > > Thanks! > Leo > > Changes since v2: > - Fixed macros that depend on having a local variable with a magic name > - Previous cast to (long) is now only applied on 4-bytes cmpxchg > > Changes since v1: > - Fixed patch 4/6 suffix from 'w.aqrl' to '.w.aqrl', to avoid build error > > > Leonardo Bras (6): > riscv/cmpxchg: Deduplicate cmpxchg() asm functions > riscv/cmpxchg: Deduplicate cmpxchg() macros > riscv/cmpxchg: Deduplicate arch_cmpxchg() macros > riscv/cmpxchg: Deduplicate xchg() asm functions > riscv/cmpxchg: Deduplicate xchg() macros > riscv/cmpxchg: Deduplicate arch_xchg() macros > > arch/riscv/include/asm/cmpxchg.h | 319 +++++++------------------------ > 1 file changed, 67 insertions(+), 252 deletions(-) > > -- > 2.40.0 > --=20 Best Regards Guo Ren