Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6468752rwb; Tue, 9 Aug 2022 16:18:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR69jrXR2zPb7ZNCkRXf3//u47ujSnrD+xMMk+6jWd5g/RPdT8zSQ6s4ULKPPWjAwQYzCjqC X-Received: by 2002:a63:904b:0:b0:41c:227d:3781 with SMTP id a72-20020a63904b000000b0041c227d3781mr20694660pge.368.1660087110788; Tue, 09 Aug 2022 16:18:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660087110; cv=none; d=google.com; s=arc-20160816; b=sLrMZBvgeJ044O9Q/z/BGfE4yhIyVVPn92DXECtekb8WBX6yEN6WfLQFEa/YmErsa3 zNVRN5k59ePO6YVu6eDRHg8cHeZFZoM2TnhaLPEC5idpuFqY6BZSvb8tURXl1UC3AKcv qFnlA7jLp38ikVX6UdJFfzaJlMh8jxtHw+J5KzlKK0/I9o9emLS9Sy+3t9HAmvD/emZ3 w0am61JngWGQl95B9UYtAi2ivMpD5cmDEaZEirCl/npYKVAvyM3djGEV3BQPBB7kV+LR qpwEBIIrK/3QVX9k6FFA2VYwczz5oslzfPO4vxfX2rg8NSF5nlLSF9QWHqqDtZMsQ1FJ /X6A== 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=rCkomxRdKp5E6eavd2JrFTdu3cTv0gLHfol6e5BOksQ=; b=gxcHaTTbcl+ErSPf+GTyU+4oAks1IJCpeXFspaDrpljd+d5RMyTD+3UpL/bJOAGVqF v2lYAf6HBd2a2Cgbror1aKwo9nj3LFfe7TCh1/MPnXKJu7Ts/AOf3ZxSrXO2b6EF9nDB dKOb8a7OkaxsiYRx6XLMdc1k3rQU6AGxtpcQ8n2HrvBLxeZPN65hhYEyMRTXyDJYF0/b OCBmbzjAcN0LlGS4c8O8nPx+FDzXVnvOdjQwUbaRhAgjtCw+hln0bddo7uz0EzyWkAaO 2IAPfYigLYZV4LFaIQ9eq9j/QS79Y/ipm8UtC90HnPJx/9KPKH1RjQ3LkNg2NUMTpnlr c2/w== 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 s8-20020a655848000000b004150ffa044dsi11241482pgr.871.2022.08.09.16.18.16; Tue, 09 Aug 2022 16:18:30 -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 S229529AbiHIXCu (ORCPT + 99 others); Tue, 9 Aug 2022 19:02:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiHIXCt (ORCPT ); Tue, 9 Aug 2022 19:02:49 -0400 Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A59167C80; Tue, 9 Aug 2022 16:02:48 -0700 (PDT) Received: from dread.disaster.area (pa49-181-193-158.pa.nsw.optusnet.com.au [49.181.193.158]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 527B762D44C; Wed, 10 Aug 2022 09:02:46 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1oLYFI-00BDH8-PC; Wed, 10 Aug 2022 09:02:44 +1000 Date: Wed, 10 Aug 2022 09:02:44 +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: <20220809230244.GJ3600936@dread.disaster.area> References: <20220809165615.9694-1-ubizjak@gmail.com> <20220809220511.GI3600936@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220809220511.GI3600936@dread.disaster.area> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=e9dl9Yl/ c=1 sm=1 tr=0 ts=62f2e797 a=SeswVvpAPK2RnNNwqI8AaA==:117 a=SeswVvpAPK2RnNNwqI8AaA==:17 a=kj9zAlcOel0A:10 a=biHskzXt2R4A:10 a=VwQbUJbxAAAA:8 a=7-415B0cAAAA:8 a=8C0a8iNh18_4KdS3VZMA:9 a=CjuIK1q_8ugA:10 a=AjGcO6oz07-iQ99wixmX:22 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 Wed, Aug 10, 2022 at 08:05:11AM +1000, Dave Chinner wrote: > 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. FYI, the original RFC for this was posted a bit over a month ago: https://lore.kernel.org/linux-xfs/20220708015558.1134330-1-david@fromorbit.com/ Cheers, Dave. -- Dave Chinner david@fromorbit.com