All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] fs/superblock: Avoid locking counting inodes and dentries before reclaiming them
       [not found] <409cc1e38244136e72e97883445187941d1405b8.1378465804.git.tim.c.chen@linux.intel.com>
@ 2013-09-06 18:24 ` Tim Chen
  0 siblings, 0 replies; only message in thread
From: Tim Chen @ 2013-09-06 18:24 UTC (permalink / raw)
  To: Dave Chinner, Alexander Viro, Jan Kara
  Cc: Andi Kleen, Dave Hansen, Matthew Wilcox, linux-fsdevel,
	linux-kernel, Kirill A. Shutemov

We remove the call to grab_super_passive in call to super_cache_count.
This becomes a scalability bottleneck as multiple threads are trying
to do memory reclamation, e.g. when we are doing large amount of
file read and page cache is under pressure.  The cached objects
quickly got reclaimed down to 0 and we are aborting the cache_scan()
reclaim.  But counting creates a log jam acquiring the sb_lock.

We are holding the shrinker_rwsem which ensures the safety of
call to list_lru_count_node() and s_op->nr_cached_objects.  The
shrinker is unregistered now before ->kill_sb() so the operation is
safe when we are doing unmount.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
 fs/super.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index b724f35..b5c9fdf 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -112,9 +112,14 @@ static unsigned long super_cache_count(struct shrinker *shrink,
 
 	sb = container_of(shrink, struct super_block, s_shrink);
 
-	if (!grab_super_passive(sb))
-		return 0;
-
+	/*
+	 * Don't call grab_super_passive as it is a potential
+	 * scalability bottleneck. The counts could get updated
+	 * between super_cache_count and super_cache_scan anyway.
+	 * Call to super_cache_count with shrinker_rwsem held
+	 * ensures the safety of call to list_lru_count_node() and
+	 * s_op->nr_cached_objects().
+	 */
 	if (sb->s_op && sb->s_op->nr_cached_objects)
 		total_objects = sb->s_op->nr_cached_objects(sb,
 						 sc->nid);
@@ -125,7 +130,6 @@ static unsigned long super_cache_count(struct shrinker *shrink,
 						 sc->nid);
 
 	total_objects = vfs_pressure_ratio(total_objects);
-	drop_super(sb);
 	return total_objects;
 }
 
-- 
1.7.11.7



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-09-06 18:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <409cc1e38244136e72e97883445187941d1405b8.1378465804.git.tim.c.chen@linux.intel.com>
2013-09-06 18:24 ` [PATCH 2/2] fs/superblock: Avoid locking counting inodes and dentries before reclaiming them Tim Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.