[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1572866980-13001-1-git-send-email-zhangshaokun@hisilicon.com>
Date: Mon, 4 Nov 2019 19:29:40 +0800
From: Shaokun Zhang <zhangshaokun@...ilicon.com>
To: <linux-xfs@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: Yang Guo <guoyang2@...wei.com>,
"Darrick J. Wong" <darrick.wong@...cle.com>,
Shaokun Zhang <zhangshaokun@...ilicon.com>
Subject: [PATCH] xfs: optimise xfs_mod_icount/ifree when delta < 0
From: Yang Guo <guoyang2@...wei.com>
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" <darrick.wong@...cle.com>
Signed-off-by: Yang Guo <guoyang2@...wei.com>
Signed-off-by: Shaokun Zhang <zhangshaokun@...ilicon.com>
---
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
Powered by blists - more mailing lists