Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6449166rwb; Tue, 9 Aug 2022 15:54:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR6V2LCAQ9SC7ZjlBbwjrXfDdTMIpjiESM4WLJQAZZIWRHuQtg7zaERk1FBM4gHldJRVqVHA X-Received: by 2002:a17:903:283:b0:16e:f604:1408 with SMTP id j3-20020a170903028300b0016ef6041408mr25507287plr.119.1660085647303; Tue, 09 Aug 2022 15:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660085647; cv=none; d=google.com; s=arc-20160816; b=vEhpSZcYZw03VJgGNmGL692CmPlrN6DkaNQdSyS8Iys11FR3nqewwc1Yw6H7T3X59L fGuBW0JAiJKC9AoeifUFO7+vzAHkwuc4RtxV1SN12PowHFcNtN4QEaZmKHvaYAbg1F3o 12Fe5erTDcKGLTqSmrUefw/2vrSVzpmrHPMqoDyzEXcE8IQvc5iRpuUHgr9EPpy7+HFe UWfAtkh7QNtl4JMNcMzady4hXEV/MjH2SSFAiwW3O3zKC9xHEOOm0c2si+PzNYlD+KWe zO151SWSX8IvTQhXA1pfKxEY2hnnGXyIdJ4+FOwzsg2WaIAMHmqi0R9see/G++R/AYJX NLfg== 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=ksA6ANmxP2mSP65t0aelT4H/KyIBL5x9xkz0Sm+7ROk=; b=SEQXbzrqBuLh194Sr3Dqleak3C/QmC1PMd1qLG+FmSYOJxlvKT9jXjydqS1e9D7Gnj t96PMH0EWWnxs4TmTgAHYomDQauasDG/0HwjZjgpuzoxR0y1MN6S54/E47FZFefvCPy9 p4eQUhowlSqGaa3EKRdbHplxqD917qpGopMYsfYucoTh7p8xxop5DkUbnQKebyVDYmLD vOaGE+L+M/PoNGQXzDTlFg8IQMSOeB1L605t95qD8nY6LFQvvTRI3FtN8d0r53Q7ERV7 2zfC3Ig9T45hM1Rqt3jMGGJIAx+4pZ51DXddByLJfIlwM2xFni8QzliSusYSOgZq3RRu 9gAQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y25-20020aa78f39000000b0052aeaff99efsi835279pfr.39.2022.08.09.15.53.47; Tue, 09 Aug 2022 15:54:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230081AbiHIWGs (ORCPT + 99 others); Tue, 9 Aug 2022 18:06:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbiHIWFT (ORCPT ); Tue, 9 Aug 2022 18:05:19 -0400 Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5ABB8A8; Tue, 9 Aug 2022 15:05:18 -0700 (PDT) Received: from dread.disaster.area (pa49-181-193-158.pa.nsw.optusnet.com.au [49.181.193.158]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 2C7A110E85DA; Wed, 10 Aug 2022 08:05:13 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1oLXLb-00BCHm-Hu; Wed, 10 Aug 2022 08:05:11 +1000 Date: Wed, 10 Aug 2022 08:05:11 +1000 From: Dave Chinner To: Uros Bizjak Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, "Darrick J. Wong" Subject: Re: [PATCH] fs/xfs: Use atomic64_try_cmpxchg in xlog_grant_{add,sub}_space Message-ID: <20220809220511.GI3600936@dread.disaster.area> References: <20220809165615.9694-1-ubizjak@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220809165615.9694-1-ubizjak@gmail.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=VuxAv86n c=1 sm=1 tr=0 ts=62f2da19 a=SeswVvpAPK2RnNNwqI8AaA==:117 a=SeswVvpAPK2RnNNwqI8AaA==:17 a=kj9zAlcOel0A:10 a=biHskzXt2R4A:10 a=7-415B0cAAAA:8 a=qgxBokI5hthhnRxBgHsA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, Aug 09, 2022 at 06:56:15PM +0200, Uros Bizjak wrote: > Use `!atomic64_try_cmpxchg(ptr, &old, new)` instead of > `atomic64_cmpxchg(ptr, old, new) != old` in xlog_grant_{add,sub}_space. > This has two benefits: > > - The x86 cmpxchg instruction returns success in the ZF flag, so this > change saves a compare after cmpxchg, as well as a related move > instruction in the front of cmpxchg. > > - atomic64_try_cmpxchg implicitly assigns the *ptr value to &old when > cmpxchg fails, enabling further code simplifications. Do the two cmpxchg operations have the same memory ordering semantics on failure? > This patch has no functional change. The patch looks ok, but .... ... I'm about 2 hours away from posting a patchset that completely removes the cmpxchg and the new grant head accounting has significantly lower fast path overhead. It also opens the door for tracking more than 2GB of log space in the grant heads. So I don't think we need to be micro-optimising this code given that there are much bigger perf gains about to land... Cheers, Dave. -- Dave Chinner david@fromorbit.com