Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2871102ybc; Wed, 20 Nov 2019 23:00:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwrKVjBxIGKRbSlSjYjjwJQDxStqyi2N/QJPY8CdkU3bE7uIcDrf+u3l7U6IYOQepXo0JSK X-Received: by 2002:a17:906:d793:: with SMTP id pj19mr11528323ejb.303.1574319619209; Wed, 20 Nov 2019 23:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574319619; cv=none; d=google.com; s=arc-20160816; b=RtMeVpo/r/PPqLRa6R3TvKJGfYg0bJ00BDqlcwPpt6rShQfvupy9Knj8zUU7C9KWph zEfI5OVWDarpnPGQ2YHL4+zgWilybHCa+PfitTpFuhSpvlyhcxQ0tn2AOfNudl5+Y5eM bZdJNqPsxxSG6kXT9vAGZBpLVIwk+C/yxa7bTjhETeapNhaMjkgepjEGTbPsX1Jsv6fz RaDouHFlVMpATPy8Xh8tazUokAu/HNIEN7PHYIKpLv47aJTvyBaYYGE4UZ21FuaywnBT kQTdUBku4loB75YWFGBV/z6aOcxs0vCXzKrR+PQQgC08+HgUsJKj+z0pxiv3T2H3hDjY nAcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MPeNAWungv26bQAwYJD7nCaq+Sl1GrBA7DY8FsKxn9M=; b=ptNG1lFbvFtXuMM6Ky7/d1Dbm8p2LnRGLXZ//VrvqO3ikkHuHOde854tDJBkqhjjC6 phu1lNr9x5DcqzXvE6gaOhIvZLNPpX4CddbUcgiUQnVlZJWpmaFEW0YFZcLzRR9Xka5N AwnbhdB0DMzYmZqgRcXvNQ2NnauVzRRv16b3H0W0xRa6tsECpPtus12QcZz1TLCefQsv 4W/mPemp17nKMTo4UnMdZaeY4/jJRi2+T3h0WvMLzvp4M2JW+TL7LIDKwmWNOkR70OmO o3Za77yD/T4gNxkPq6sRDaDXWGZnk3TEmDqJ9+7igGuCpPquRsUqqyeFiDbOVqN5rvFt Xo/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (dns failure for signature) header.i=@infradead.org header.s=bombadil.20170209 header.b=FBjdYX6V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si1615330edc.4.2019.11.20.22.59.54; Wed, 20 Nov 2019 23:00:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (dns failure for signature) header.i=@infradead.org header.s=bombadil.20170209 header.b=FBjdYX6V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726379AbfKUG4t (ORCPT + 99 others); Thu, 21 Nov 2019 01:56:49 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:38926 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfKUG4s (ORCPT ); Thu, 21 Nov 2019 01:56:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MPeNAWungv26bQAwYJD7nCaq+Sl1GrBA7DY8FsKxn9M=; b=FBjdYX6V1FG6rFKCsfrm7Lq3s TUtSU0xAgmdjmnHN6lpOuTZyt5AuU1RkqA4hpTDc5M7zIQE9eWYV4UlZ/e1xt7BXYCGHl4M8/TV0c 4E39VUaN3l6ToZ8bz+I/Ini3h5SGmAl6njkWhVw2apbaURgojGhjuqC6gq94R3BF/GJpaQpDM9N3N 7SZXtL3QLv4Ci/qjJkKfhVpuCU54MbtzBDj8wVU3eDlm7X52kEMLlGjzAHUfNULH0B0MYaXVMsfxA LeWx7J4Adc9H8ENDHCr3CAvd7/vY8jsZfLN/J0tuH7dv5F5awLxxHFAg6hIu7xoRnj207y+Fa6bbs nHJHqIzeA==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iXgOS-0004Lc-0x; Thu, 21 Nov 2019 06:56:44 +0000 Date: Wed, 20 Nov 2019 22:56:44 -0800 From: Christoph Hellwig To: Dave Chinner Cc: Shaokun Zhang , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Guo , "Darrick J. Wong" Subject: Re: [PATCH] xfs: optimise xfs_mod_icount/ifree when delta < 0 Message-ID: <20191121065644.GA21798@infradead.org> References: <1572866980-13001-1-git-send-email-zhangshaokun@hisilicon.com> <20191104204909.GB4614@dread.disaster.area> <20191105040325.GC4614@dread.disaster.area> <675693c2-8600-1cbd-ce50-5696c45c6cd9@hisilicon.com> <20191106212041.GF4614@dread.disaster.area> <20191118081212.GT4614@dread.disaster.area> <20191120210825.GB4614@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191120210825.GB4614@dread.disaster.area> User-Agent: Mutt/1.12.1 (2019-06-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static void > xfs_sb_mod8( > uint8_t *field, > int8_t delta) > { > int8_t counter = *field; > > + if (!delta) > + return; > counter += delta; > + ASSERT(counter >= 0); > *field = counter; > } I'd almost find it easier to keep the != 0 check in the caller, and in fact also move the assert there and just kill these helpers, e.g. if (tp->t_imaxpct_delta != 0) { mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta; ASSERT(mp->m_sb.sb_imax_pct >= 0); } if (tp->t_rextsize_delta != 0) { mp->m_sb.sb_rextsize += tp->t_rextsize_delta; ASSERT(mp->m_sb.sb_rextsize >= 0); } While this is 2 more lines per counter it is a lot more explicit and easier to follow. > if (idelta) { > - error = xfs_mod_icount(mp, idelta); > - if (error) > - goto out_undo_fdblocks; > + percpu_counter_add_batch(&mp->m_icount, idelta, > + XFS_ICOUNT_BATCH); > + if (idelta < 0) > + ASSERT(__percpu_counter_compare(&mp->m_icount, 0, > + XFS_ICOUNT_BATCH) >= 0) And here I wonder if keeping single use helpers wouldn't have been a little nicer. Not that it really matters.