linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: optimise xfs_mod_icount/ifree when delta < 0
@ 2019-11-04 11:29 Shaokun Zhang
  2019-11-04 15:25 ` Christoph Hellwig
  2019-11-04 20:49 ` Dave Chinner
  0 siblings, 2 replies; 13+ messages in thread
From: Shaokun Zhang @ 2019-11-04 11:29 UTC (permalink / raw)
  To: linux-xfs, linux-kernel; +Cc: Yang Guo, Darrick J. Wong, Shaokun Zhang

From: Yang Guo <guoyang2@huawei.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@oracle.com>
Signed-off-by: Yang Guo <guoyang2@huawei.com>
Signed-off-by: Shaokun Zhang <zhangshaokun@hisilicon.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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-11-21  6:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 11:29 [PATCH] xfs: optimise xfs_mod_icount/ifree when delta < 0 Shaokun Zhang
2019-11-04 15:25 ` Christoph Hellwig
2019-11-05  3:08   ` Shaokun Zhang
2019-11-04 20:49 ` Dave Chinner
2019-11-05  3:26   ` Shaokun Zhang
2019-11-05  4:03     ` Dave Chinner
2019-11-06  6:00       ` Shaokun Zhang
2019-11-06 21:20         ` Dave Chinner
2019-11-08  5:58           ` Shaokun Zhang
2019-11-15  9:16             ` Shaokun Zhang
2019-11-18  8:12             ` Dave Chinner
2019-11-20 21:08               ` Dave Chinner
2019-11-21  6:56                 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).