]> www.infradead.org Git - users/jedix/linux-maple.git/commit
vmscan: shrinker->nr updates race and go wrong
authorDave Chinner <dchinner@redhat.com>
Fri, 8 Jul 2011 04:14:35 +0000 (14:14 +1000)
committerJerry Snitselaar <jerry.snitselaar@oracle.com>
Sun, 7 Oct 2012 06:00:01 +0000 (23:00 -0700)
commit58d555dbf52b0489e7fe9f77eae573b166cca9e2
treed303415a2731cb592294566c6e9bf3ea0fe5a757
parent25f7e7860d5d66250994da29355dc277c17f7649
vmscan: shrinker->nr updates race and go wrong

commit acf92b485cccf028177f46918e045c0c4e80ee10 upstream.

Stable note: Not tracked in Bugzilla. This patch reduces excessive
reclaim of slab objects reducing the amount of information
that has to be brought back in from disk.

shrink_slab() allows shrinkers to be called in parallel so the
struct shrinker can be updated concurrently. It does not provide any
exclusio for such updates, so we can get the shrinker->nr value
increasing or decreasing incorrectly.

As a result, when a shrinker repeatedly returns a value of -1 (e.g.
a VFS shrinker called w/ GFP_NOFS), the shrinker->nr goes haywire,
sometimes updating with the scan count that wasn't used, sometimes
losing it altogether. Worse is when a shrinker does work and that
update is lost due to racy updates, which means the shrinker will do
the work again!

Fix this by making the total_scan calculations independent of
shrinker->nr, and making the shrinker->nr updates atomic w.r.t. to
other updates via cmpxchg loops.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6a5091a09f9278f8f821e3f33ac748633d143cea)

Signed-off-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
mm/vmscan.c