Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1801656rwl; Thu, 6 Apr 2023 01:06:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1GL0FirxLm24RXsQ7rBi0aUaLfL+yTmdYF2c1O2sfCwxYPhDGK3H+KGvMxAQ2LYudvEum X-Received: by 2002:a05:6402:1ace:b0:4fe:ddf:8d8c with SMTP id ba14-20020a0564021ace00b004fe0ddf8d8cmr3945918edb.13.1680768396663; Thu, 06 Apr 2023 01:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680768396; cv=none; d=google.com; s=arc-20160816; b=daNcKuUVZtEXJ3OiR7ulmVlxKel5Hx396XJtSU2yyKTX56/dannq7UnbSBGxWB1Dmj yrJeMuW/USBSC7EY2HR5NASC6RMGGzxEUYhKcebfFZ/qtRVE0+qX5uH09WttOH7c/dCg FYCRHyGts7x5XZgmYSjNLWUyoWnheISB4tsCRnwMYpWm1jqoCT7LAwW4/FD5TTnhiy+5 AOzPhiYGOvUOCr1bOpxRX0rXX30WHA/kq3/7+yRdDIhfKF7pe16wIMy0Kuz4BvghzE1q 7tmX0gyf2O4woGl4VTli6hMIf5IBaR7CB3Ih8bP+H7sa+GXZ/b0mY+dISGEeIcKbIg4w yDGA== 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=kBR23GZ8+/B49HpGt9RtYBgTJWOQz/g1P9XKqxTbjRU=; b=AaG2lotoIUWkMcAAUAiagC+zHnezJ8wSSsjcl7qNw2Ws/nKsh458ePd1DE47T7cETZ oA2LKYir16TZJc58Y4k3KuiKMTSE7JIcLig1+ZkrbzRHq8V3VVkhNXss8RiMB16kWUF3 cgg83l1FT6z/kMDA/ezkBSPI8wEwY+msk0LKn5uZ8pjFy3giXBy7m3/6uf1zhGPNDnju JoX2JJXj0QSCuBeUYm94+U2zKAotoH6ypYtcz6tNPJ8DiFGehkLGXf6/BcTFYTEMCyoS 8wqDiSeNEuLjrmaQxitjuWYTzxeRoyyncTEVErYa5hhRR7qYeKPVthYatQ9CKnkz04rI GJkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y1J37HTV; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq2-20020a056402214200b0048e82d753a3si645674edb.227.2023.04.06.01.06.11; Thu, 06 Apr 2023 01:06:36 -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=@redhat.com header.s=mimecast20190719 header.b=Y1J37HTV; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234663AbjDFIFg (ORCPT + 99 others); Thu, 6 Apr 2023 04:05:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234102AbjDFIFe (ORCPT ); Thu, 6 Apr 2023 04:05:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBBBA7AAD for ; Thu, 6 Apr 2023 01:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680768256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kBR23GZ8+/B49HpGt9RtYBgTJWOQz/g1P9XKqxTbjRU=; b=Y1J37HTVBwGF4DrWoE8G/7rFElnNYpJZKbxxT0q7ThoZuvrtk0Ut7PYhNVOdnPbW+DtJR/ v1bCRvgQQqZkV+oGo8ZrM0PomzWECbkSjHIRlvPbGtpRqfX+VhKa1/2dvVO7tNWBQP0DnN f0tX8VlU2Jjk55MJzJexS0Fl6+SxGG0= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-VjybiymmODicHCMMiq5_EQ-1; Thu, 06 Apr 2023 04:04:14 -0400 X-MC-Unique: VjybiymmODicHCMMiq5_EQ-1 Received: by mail-qk1-f199.google.com with SMTP id b142-20020ae9eb94000000b007486a8b9ae9so14735014qkg.11 for ; Thu, 06 Apr 2023 01:04:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680768254; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kBR23GZ8+/B49HpGt9RtYBgTJWOQz/g1P9XKqxTbjRU=; b=rSiNvwCCUcYXPI81+tTQw6bzN2DyavNGgzE6tV1YHoUzk9wzV+MwjO9MUDtcSuLjQY SpCTkOI9kFb8c9r3NOGDIIGw4ZnX2KwFPwXusC8DMjzX1P/FFChwFZi5cRsgl9YI5OgC 59MFGnrie6XTtOrdh2xn916VEBcwS3EseSyBBs7iFarebT+4p9vKk2cC2BRl26TrEsZ5 Bx0f/QPoI+lp7fkokKY/14rZunTw3bX8vGj6Qgne/LDdovhFWf+7jft6TlBGg2HbGFq4 dQQfbYIenbOcj+EdJcEChbln9jtMxWmZiZtinS4UGNp+wCufT87b3zLT81vTU+zYJrpj MZ1w== X-Gm-Message-State: AAQBX9eOyYAH4df4GQDAn4P9WQImC0XbTJg1un5QTikTGJ7BYTJ4ZGRs GKaEOVENnaBbLxvSSk2guMnobsTVaZAuTmfpX0RFVAkxianE7sl7o7RGbKUYgS8tSFiw8DfR57M YaQAnzc1YfVlmKFlI1+xxBwlPEovH8908E30gWzft X-Received: by 2002:a05:620a:1a87:b0:74a:580:c44f with SMTP id bl7-20020a05620a1a8700b0074a0580c44fmr1997127qkb.15.1680768254369; Thu, 06 Apr 2023 01:04:14 -0700 (PDT) X-Received: by 2002:a05:620a:1a87:b0:74a:580:c44f with SMTP id bl7-20020a05620a1a8700b0074a0580c44fmr1997118qkb.15.1680768254137; Thu, 06 Apr 2023 01:04:14 -0700 (PDT) MIME-Version: 1.0 References: <20230404163741.2762165-1-leobras@redhat.com> In-Reply-To: From: Leonardo Bras Soares Passos Date: Thu, 6 Apr 2023 05:04:03 -0300 Message-ID: Subject: Re: [RFC PATCH v3 0/6] Deduplicating RISCV cmpxchg.h macros To: Guo Ren 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=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On Wed, Apr 5, 2023 at 11:40=E2=80=AFPM Guo Ren wrote: > > Thx Leonardo, > > It's a good point for cleaning up. Hello Guo, Thanks for the feedback! > > 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 exa= ctly > > 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.) Sure, as mentioned below, I have no issue squashing the patches, so 2 should work fine. I was previously worried about the changes, so I split them in 3 so it's easier to understand my thought process. I will resend it in a couple minutes. > > > total of 6 patches. I did this so it becomes easier to review and remov= e > > 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 nam= e > > - 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 err= or > > > > > > 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 > > > > > -- > Best Regards > Guo Ren > Best regards, Leo