Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3824589ybx; Mon, 4 Nov 2019 03:31:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwv3v1Qn+kO1xlTxUD1DhUKanCA71REeAKwaWoBZ6CAbHG9eRMzJ8OGnbwUTCQQGz3wqIpv X-Received: by 2002:a17:906:1cd8:: with SMTP id i24mr23309102ejh.149.1572867063102; Mon, 04 Nov 2019 03:31:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572867063; cv=none; d=google.com; s=arc-20160816; b=i5eo0Ol8vjjRKE8nocQRoaqezl3m7CtenjJmWtjOZOTmY+l8poxmJ+3DoTOdUDTnc0 cDhiCXl1tiAQpKrjXgmH2E5hWKeJKXP8GrF3Q4ACx2J2hXPg66czSKWo/FrA3u9YraWY LM18wA+5NV3H8Ltl+F4aL41bqij+fhNsDtkUjo3VFFzRa7cji2V6QYxgoQbpULxD/YRh Edwrz4CuNlgbuOqg6i6v7fAdF/CML4WJm27bwmCXI1ZLVyWvl0hlyJh1tTAMfHa8X4Fs 9tcnSVZTV9On01uPO7Qc2vxOPID4Ebq1Id9IGC3/OCVni2wPgpTZU291soK6+LPV7ErB hIrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=jt89ALtFRQ66v+vqDz2JB3megr3ZSdWhe3SsIJa2WOQ=; b=q4PDeCEuOdbfIl8myWmlDTpU9UVoLnC+nIsLMj2mrPMyCacmxGVoNWzRXm5Lf/QpwB 3g8kZ1oqFxiDoHnTCu/XMiuGJuQ+UPN++j/Gl+CC8Ta1IqjBECAvYvewCCnxAg8W7lfe bDgY0Yt/NKCNk1HnXSbhLRYeXlyEG1Xjj2V1SRzNBEXDxx/e2WfF4FVQefwNCytGiRz3 Ulo7gyV7HyPbiB9PkaojdysoGgQ3KHThZnG3Hk2oiKTdPazNQ+imcwk0D+1i0McTX17g UiI3l23iJEpr66RVaH6S8WAO1Z3A0LKZ4+rPPFq3SLiEsHAUokie+iacRg1Xf986pwS7 FQmA== ARC-Authentication-Results: i=1; mx.google.com; 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 j44si8002501eda.345.2019.11.04.03.30.39; Mon, 04 Nov 2019 03:31:03 -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; 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 S1728738AbfKDL3V (ORCPT + 99 others); Mon, 4 Nov 2019 06:29:21 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:5699 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726364AbfKDL3V (ORCPT ); Mon, 4 Nov 2019 06:29:21 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6023DD631EBB6FB0997D; Mon, 4 Nov 2019 19:29:17 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Mon, 4 Nov 2019 19:29:09 +0800 From: Shaokun Zhang To: , CC: Yang Guo , "Darrick J. Wong" , Shaokun Zhang Subject: [PATCH] xfs: optimise xfs_mod_icount/ifree when delta < 0 Date: Mon, 4 Nov 2019 19:29:40 +0800 Message-ID: <1572866980-13001-1-git-send-email-zhangshaokun@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Guo percpu_counter_compare will be called by xfs_mod_icount/ifree to check whether the counter less than 0 and it is a expensive function. let's check it only when delta < 0, it will be good for xfs's performance. Cc: "Darrick J. Wong" Signed-off-by: Yang Guo Signed-off-by: Shaokun Zhang --- fs/xfs/xfs_mount.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index ba5b6f3b2b88..5e8314e6565e 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -1174,6 +1174,9 @@ xfs_mod_icount( int64_t delta) { percpu_counter_add_batch(&mp->m_icount, delta, XFS_ICOUNT_BATCH); + if (delta > 0) + return 0; + if (__percpu_counter_compare(&mp->m_icount, 0, XFS_ICOUNT_BATCH) < 0) { ASSERT(0); percpu_counter_add(&mp->m_icount, -delta); @@ -1188,6 +1191,9 @@ xfs_mod_ifree( int64_t delta) { percpu_counter_add(&mp->m_ifree, delta); + if (delta > 0) + return 0; + if (percpu_counter_compare(&mp->m_ifree, 0) < 0) { ASSERT(0); percpu_counter_add(&mp->m_ifree, -delta); -- 2.7.4