From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 01/18] xfs: single thread inode cache shrinking.
Date: Tue, 14 Sep 2010 20:56:00 +1000 [thread overview]
Message-ID: <1284461777-1496-2-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1284461777-1496-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
Having multiple CPUs trying to do the same cache shrinking work can
be actively harmful to perforamnce when the shrinkers land in the
same AGs. They then lockstep on perag locks, causing contention and
slowing each other down. Reclaim walking is sufficiently efficient
that we do no need parallelism to make significant progress, so stop
parallel access at the door.
Instead, keep track of the number of objects the shrinkers want
cleaned and make sure the single running shrinker does not stop
until it has hit the threshold that the other shrinker calls have
built up.
This increases the cold-cache unlink rate of a 8-way parallel unlink
workload from about 15,000 unlinks/s to 60-70,000 unlinks/s for the
same CPU usage (~700%), resulting in the runtime for a 200M inode
unlink workload dropping from 4h50m to just under 1 hour.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/linux-2.6/xfs_sync.c | 21 +++++++++++++++++++--
fs/xfs/xfs_mount.h | 2 ++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index d59c4a6..bc54cd6 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -869,7 +869,9 @@ xfs_reclaim_inodes(
}
/*
- * Shrinker infrastructure.
+ * Shrinker infrastructure. We allow filesystem reclaim recursion here because
+ * we trylock everything in the reclaim path and hence will not deadlock with
+ * locks that may already be held through direct reclaim.
*/
static int
xfs_reclaim_inode_shrink(
@@ -883,12 +885,25 @@ xfs_reclaim_inode_shrink(
int reclaimable;
mp = container_of(shrink, struct xfs_mount, m_inode_shrink);
+
if (nr_to_scan) {
- if (!(gfp_mask & __GFP_FS))
+ int64_t scan_cnt;
+
+ if (!mutex_trylock(&mp->m_ino_shrink_lock)) {
+ atomic64_add(nr_to_scan, &mp->m_ino_shrink_nr);
return -1;
+ }
+ do {
+ scan_cnt = atomic64_read(&mp->m_ino_shrink_nr);
+ } while (scan_cnt !=
+ atomic64_cmpxchg(&mp->m_ino_shrink_nr, scan_cnt, 0));
+
+ nr_to_scan += scan_cnt;
xfs_inode_ag_iterator(mp, xfs_reclaim_inode, 0,
XFS_ICI_RECLAIM_TAG, 1, &nr_to_scan);
+ mutex_unlock(&mp->m_ino_shrink_lock);
+
/* if we don't exhaust the scan, don't bother coming back */
if (nr_to_scan > 0)
return -1;
@@ -910,6 +925,8 @@ xfs_inode_shrinker_register(
{
mp->m_inode_shrink.shrink = xfs_reclaim_inode_shrink;
mp->m_inode_shrink.seeks = DEFAULT_SEEKS;
+ atomic64_set(&mp->m_ino_shrink_nr, 0);
+ mutex_init(&mp->m_ino_shrink_lock);
register_shrinker(&mp->m_inode_shrink);
}
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 622da21..57b5644 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -199,6 +199,8 @@ typedef struct xfs_mount {
__int64_t m_update_flags; /* sb flags we need to update
on the next remount,rw */
struct shrinker m_inode_shrink; /* inode reclaim shrinker */
+ atomic64_t m_ino_shrink_nr;
+ struct mutex m_ino_shrink_lock;
} xfs_mount_t;
/*
--
1.7.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2010-09-14 10:56 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-14 10:55 [PATCH 0/18] xfs: metadata and buffer cache scalability improvements Dave Chinner
2010-09-14 10:56 ` Dave Chinner [this message]
2010-09-14 18:48 ` [PATCH 01/18] xfs: single thread inode cache shrinking Alex Elder
2010-09-14 22:48 ` Dave Chinner
2010-09-14 10:56 ` [PATCH 02/18] xfs: reduce the number of CIL lock round trips during commit Dave Chinner
2010-09-14 14:48 ` Christoph Hellwig
2010-09-14 17:21 ` Alex Elder
2010-09-14 10:56 ` [PATCH 03/18] xfs: remove debug assert for per-ag reference counting Dave Chinner
2010-09-14 14:48 ` Christoph Hellwig
2010-09-14 17:22 ` Alex Elder
2010-09-14 10:56 ` [PATCH 04/18] xfs: lockless per-ag lookups Dave Chinner
2010-09-14 12:35 ` Dave Chinner
2010-09-14 14:50 ` Christoph Hellwig
2010-09-14 17:28 ` Alex Elder
2010-09-14 10:56 ` [PATCH 05/18] xfs: convert inode cache lookups to use RCU locking Dave Chinner
2010-09-14 16:27 ` Christoph Hellwig
2010-09-14 23:17 ` Dave Chinner
2010-09-14 21:23 ` Alex Elder
2010-09-14 23:42 ` Dave Chinner
2010-09-14 10:56 ` [PATCH 06/18] xfs: convert pag_ici_lock to a spin lock Dave Chinner
2010-09-14 21:26 ` Alex Elder
2010-09-14 10:56 ` [PATCH 07/18] xfs: don't use vfs writeback for pure metadata modifications Dave Chinner
2010-09-14 14:54 ` Christoph Hellwig
2010-09-15 0:14 ` Dave Chinner
2010-09-15 0:17 ` Christoph Hellwig
2010-09-14 22:12 ` Alex Elder
2010-09-15 0:28 ` Dave Chinner
2010-11-08 10:47 ` Christoph Hellwig
2010-09-14 10:56 ` [PATCH 08/18] xfs: rename xfs_buf_get_nodaddr to be more appropriate Dave Chinner
2010-09-14 14:56 ` Christoph Hellwig
2010-09-14 22:14 ` Alex Elder
2010-09-14 10:56 ` [PATCH 09/18] xfs: introduced uncached buffer read primitve Dave Chinner
2010-09-14 14:56 ` Christoph Hellwig
2010-09-14 22:16 ` Alex Elder
2010-09-14 10:56 ` [PATCH 10/18] xfs: store xfs_mount in the buftarg instead of in the xfs_buf Dave Chinner
2010-09-14 14:57 ` Christoph Hellwig
2010-09-14 22:21 ` Alex Elder
2010-09-14 10:56 ` [PATCH 11/18] xfs: kill XBF_FS_MANAGED buffers Dave Chinner
2010-09-14 14:59 ` Christoph Hellwig
2010-09-14 22:26 ` Alex Elder
2010-09-14 10:56 ` [PATCH 12/18] xfs: use unhashed buffers for size checks Dave Chinner
2010-09-14 15:00 ` Christoph Hellwig
2010-09-14 22:29 ` Alex Elder
2010-09-14 10:56 ` [PATCH 13/18] xfs: remove buftarg hash for external devices Dave Chinner
2010-09-14 22:29 ` Alex Elder
2010-09-14 10:56 ` [PATCH 14/18] xfs: convert buffer cache hash to rbtree Dave Chinner
2010-09-14 16:29 ` Christoph Hellwig
2010-09-15 17:46 ` Alex Elder
2010-09-14 10:56 ` [PATCH 15/18] xfs; pack xfs_buf structure more tightly Dave Chinner
2010-09-14 16:30 ` Christoph Hellwig
2010-09-15 18:01 ` Alex Elder
2010-09-14 10:56 ` [PATCH 16/18] xfs: convert xfsbud shrinker to a per-buftarg shrinker Dave Chinner
2010-09-14 16:32 ` Christoph Hellwig
2010-09-15 20:19 ` Alex Elder
2010-09-16 0:28 ` Dave Chinner
2010-09-14 10:56 ` [PATCH 17/18] xfs: add a lru to the XFS buffer cache Dave Chinner
2010-09-14 23:16 ` Christoph Hellwig
2010-09-15 0:05 ` Dave Chinner
2010-09-15 21:28 ` Alex Elder
2010-09-14 10:56 ` [PATCH 18/18] xfs: stop using the page cache to back the " Dave Chinner
2010-09-14 23:20 ` Christoph Hellwig
2010-09-15 0:06 ` Dave Chinner
2010-09-14 14:25 ` [PATCH 0/18] xfs: metadata and buffer cache scalability improvements Christoph Hellwig
2010-09-17 13:21 ` Alex Elder
2010-09-21 2:02 ` Dave Chinner
2010-09-21 16:23 ` Alex Elder
2010-09-21 22:34 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1284461777-1496-2-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox