From: Christoph Lameter <christoph@engr.sgi.com>
To: akpm@osdl.org, nickpiggin@yahoo.com.au
Cc: linux-mm@vger.kernel.org
Subject: Avoid excessive time spend on concurrent slab shrinking
Date: Fri, 31 Mar 2006 14:44:33 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.64.0603311441400.8465@schroedinger.engr.sgi.com> (raw)
We experienced that concurrent slab shrinking on 2.6.16 can slow down a
system excessively due to lock contention. Slab shrinking is a global
operation so it does not make sense for multiple slab shrink operations
to be ongoing at the same time. The single shrinking task can perform the
shrinking for all nodes and processors in the system. Introduce an atomic
counter that works in the same was as in shrink_zone to limit concurrent
shrinking.
Also calculate the time it took to do the shrinking and wait at least twice
that time before doing it again. If we are spending excessive time
on slab shrinking then we need to pause for some time to insure that the
system is capable of archiving other tasks.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Index: linux-2.6.16/mm/vmscan.c
===================================================================
--- linux-2.6.16.orig/mm/vmscan.c 2006-03-19 21:53:29.000000000 -0800
+++ linux-2.6.16/mm/vmscan.c 2006-03-31 14:38:18.000000000 -0800
@@ -130,6 +130,8 @@ static long total_memory;
static LIST_HEAD(shrinker_list);
static DECLARE_RWSEM(shrinker_rwsem);
+static atomic_t active_shrinkers;
+static unsigned long next_slab_shrink;
/*
* Add a shrinker callback to be called from the vm
@@ -187,12 +189,18 @@ int shrink_slab(unsigned long scanned, g
{
struct shrinker *shrinker;
int ret = 0;
+ unsigned long shrinkstart;
if (scanned == 0)
scanned = SWAP_CLUSTER_MAX;
- if (!down_read_trylock(&shrinker_rwsem))
- return 1; /* Assume we'll be able to shrink next time */
+ if (atomic_read(&active_shrinkers) ||
+ time_before(jiffies, next_slab_shrink) ||
+ !down_read_trylock(&shrinker_rwsem))
+ /* Assume we'll be able to shrink next time */
+ return 1;
+ atomic_inc(&active_shrinkers);
+ shrinkstart = jiffies;
list_for_each_entry(shrinker, &shrinker_list, list) {
unsigned long long delta;
@@ -239,6 +247,12 @@ int shrink_slab(unsigned long scanned, g
shrinker->nr += total_scan;
}
+ /*
+ * If slab shrinking took a long time then lets at least wait
+ * twice as long as it took before we do it again.
+ */
+ next_slab_shrink = jiffies + 2 * (jiffies - shrinkstart);
+ atomic_dec(&active_shrinkers);
up_read(&shrinker_rwsem);
return ret;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2006-03-31 22:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-31 22:44 Christoph Lameter [this message]
[not found] ` <20060331150120.21fad488.akpm@osdl.org>
2006-03-31 23:17 ` Christoph Lameter
2006-03-31 23:46 ` Andrew Morton
[not found] ` <20060331153235.754deb0c.akpm@osdl.org>
2006-03-31 23:48 ` Christoph Lameter
2006-04-01 0:00 ` Andrew Morton
2006-04-01 0:14 ` Andrew Morton
2006-04-01 0:22 ` Christoph Lameter
2006-04-01 1:25 ` Andrew Morton
2006-04-01 2:34 ` Nick Piggin
2006-04-01 5:59 ` Nathan Scott
2006-04-01 18:30 ` David Chinner
2006-04-01 18:49 ` Christoph Lameter
2006-04-01 18:24 ` David Chinner
2006-03-31 23:45 ` Andrew Morton
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=Pine.LNX.4.64.0603311441400.8465@schroedinger.engr.sgi.com \
--to=christoph@engr.sgi.com \
--cc=akpm@osdl.org \
--cc=linux-mm@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
/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