Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2396645ioo; Sat, 28 May 2022 12:19:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycLrQmV61uZD7HwXYZvTLaF7zf3NqqubQIdWh+miHMo679dnp9M3g8+i9Tsl9f+mB2n6il X-Received: by 2002:a17:90a:77c5:b0:1df:dc04:526e with SMTP id e5-20020a17090a77c500b001dfdc04526emr14702984pjs.225.1653765544678; Sat, 28 May 2022 12:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653765544; cv=none; d=google.com; s=arc-20160816; b=lJeV3xDVtFhtegI8+KiSJcBcO2aCgHb+R/74vmJRlV/Qki52eLyj7CNGF/fc4TiMCF MDXOo2/jpXLpwrqv0dlaWFURwJHsUTPjkFwsO2zLWaVsAvKLSBWw2VYXvrKja2KlxSbE a4t0qWQicWZGjjwauttfVba7ZGj711RMuXaNV07D2ltFdwukWY9mXz0cOd2Mu3iHQU7c jbC4ZfdAqlSHJp3YEptR5xdL+LO2sJh8ykbA19e3k6EKkpEUT85OEvQuHAvPvKmFClzI TCSsTwEY63k+ntu/S0SziJ61/1OGIQOYsLRepbZKKhlGE6+u82Kv1pyfY3vWLiQK9QzE 4KBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=kKBSF1sgnRVEClN2XE41ZIsDOAx1LhnZDnusGmVvA+M=; b=SCSR5KCvlTJ6ReLdoG+uhPliLc40Rv89QnzWOyY7EBknh5BueuPV69LGgB0SoA6PSf rU7XnCjz/VAynMYK1cc/OxFGVCHl9bUhkTJy85iabyFyGXbBVpqy+CdvrNFd1qUCCCNc 3ECg4mkTQxjo63xkrJF/UEDvSAzRbN4caJvW9nbK+TscRFQngSgcGBEyVpbvXaMfJqyq K63e7HiVTIrFTMGGdaRLh1c72IJYr8rbk+oamAdqKBPkw8AY+biLYzjywY+o5adObtrP BAzAVRqvjlTy83vZxBWkxCYGRuetMemzVW9AfjDa0KpRp6gf44xjhYaiDKuI4fJwp0ZH z2Lg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c3-20020a17090a8d0300b001ded60fddb1si6587078pjo.12.2022.05.28.12.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:19:04 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61B9B10578; Sat, 28 May 2022 11:51:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233908AbiEZMmx (ORCPT + 99 others); Thu, 26 May 2022 08:42:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232589AbiEZMmu (ORCPT ); Thu, 26 May 2022 08:42:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0B5566D954 for ; Thu, 26 May 2022 05:42:44 -0700 (PDT) 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 8242A1688; Thu, 26 May 2022 05:42:44 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.27.164]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D8193F70D; Thu, 26 May 2022 05:42:41 -0700 (PDT) Date: Thu, 26 May 2022 13:42:35 +0100 From: Mark Rutland To: Michael Ellerman , Linus Torvalds Cc: Uros Bizjak , Catalin Marinas , Will Deacon , Russell King , Thomas Bogendoerfer , Heiko Carstens , the arch/x86 maintainers , Linux Kernel Mailing List , Peter Zijlstra , Thomas Gleixner , Waiman.Long@hp.com, Paul McKenney , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 1/2] locking/lockref: Use try_cmpxchg64 in CMPXCHG_LOOP macro Message-ID: References: <871qwgmqws.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <871qwgmqws.fsf@mpe.ellerman.id.au> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, May 26, 2022 at 10:14:59PM +1000, Michael Ellerman wrote: > Linus Torvalds writes: > > On Wed, May 25, 2022 at 7:40 AM Uros Bizjak wrote: > >> > >> Use try_cmpxchg64 instead of cmpxchg64 in CMPXCHG_LOOP macro. > >> x86 CMPXCHG instruction returns success in ZF flag, so this > >> change saves a compare after cmpxchg (and related move instruction > >> in front of cmpxchg). The main loop of lockref_get improves from: > > > > Ack on this one regardless of the 32-bit x86 question. > > > > HOWEVER. > > > > I'd like other architectures to pipe up too, because I think right now > > x86 is the only one that implements that "arch_try_cmpxchg()" family > > of operations natively, and I think the generic fallback for when it > > is missing might be kind of nasty. > > > > Maybe it ends up generating ok code, but it's also possible that it > > just didn't matter when it was only used in one place in the > > scheduler. > > This patch seems to generate slightly *better* code on powerpc. > > I see one register-to-register move that gets shifted slightly later, so > that it's skipped on the path that returns directly via the SUCCESS > case. FWIW, I see the same on arm64; a register-to-register move gets moved out of the success path. That changes the register allocation, and resulting in one fewer move, but otherwise the code generation is the same. Thanks, Mark.