From: Tim Chen <tim.c.chen@linux.intel.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
Dave Chinner <dchinner@redhat.com>
Cc: Dave Hansen <dave.hansen@intel.com>,
Andi Kleen <ak@linux.intel.com>,
Matthew Wilcox <willy@linux.intel.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] Avoid useless inodes and dentries reclamation
Date: Wed, 28 Aug 2013 14:52:12 -0700 [thread overview]
Message-ID: <1377726732.3625.31.camel@schen9-DESK> (raw)
This patch detects that when free inodes and dentries are really
low, their reclamation is skipped so we do not have to contend
on the global sb_lock uselessly under memory pressure. Otherwise
we create a log jam trying to acquire the sb_lock in prune_super(),
with little or no freed memory to show for the effort.
The profile below shows a multi-threaded large file read exerting
pressure on memory with page cache usage. It is dominated
by the sb_lock contention in the cpu cycles profile. The patch
eliminates the sb_lock contention almost entirely for prune_super().
43.94% usemem [kernel.kallsyms] [k] _raw_spin_lock
|
--- _raw_spin_lock
|
|--32.44%-- grab_super_passive
| prune_super
| shrink_slab
| do_try_to_free_pages
| try_to_free_pages
| __alloc_pages_nodemask
| alloc_pages_current
|
|--32.18%-- put_super
| drop_super
| prune_super
| shrink_slab
| do_try_to_free_pages
| try_to_free_pages
| __alloc_pages_nodemask
| alloc_pages_current
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
fs/super.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/super.c b/fs/super.c
index 68307c0..70fa26c 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -53,6 +53,7 @@ static char *sb_writers_name[SB_FREEZE_LEVELS] = {
* shrinker path and that leads to deadlock on the shrinker_rwsem. Hence we
* take a passive reference to the superblock to avoid this from occurring.
*/
+#define SB_CACHE_LOW 5
static int prune_super(struct shrinker *shrink, struct shrink_control *sc)
{
struct super_block *sb;
@@ -68,6 +69,13 @@ static int prune_super(struct shrinker *shrink, struct shrink_control *sc)
if (sc->nr_to_scan && !(sc->gfp_mask & __GFP_FS))
return -1;
+ /*
+ * Don't prune if we have few cached objects to reclaim to
+ * avoid useless sb_lock contention
+ */
+ if ((sb->s_nr_dentry_unused + sb->s_nr_inodes_unused) <= SB_CACHE_LOW)
+ return -1;
+
if (!grab_super_passive(sb))
return -1;
--
1.7.11.7
next reply other threads:[~2013-08-28 21:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-28 21:52 Tim Chen [this message]
2013-08-28 21:19 ` Kirill A. Shutemov
2013-08-28 22:54 ` Tim Chen
2013-08-29 11:07 ` Dave Chinner
2013-08-29 18:07 ` Tim Chen
2013-08-29 18:36 ` Dave Hansen
2013-08-30 1:56 ` Dave Chinner
2013-08-30 1:40 ` Dave Chinner
2013-08-30 16:21 ` Tim Chen
2013-08-31 9:00 ` Dave Chinner
2013-09-03 18:38 ` Tim Chen
2013-09-06 0:55 ` Dave Chinner
2013-09-06 18:26 ` Tim Chen
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=1377726732.3625.31.camel@schen9-DESK \
--to=tim.c.chen@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=dchinner@redhat.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@linux.intel.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
all inboxes | Powered by JetHome®