From: Dave Chinner Date: Fri, 8 Jul 2011 04:14:35 +0000 (+1000) Subject: vmscan: shrinker->nr updates race and go wrong X-Git-Tag: v3.1-rc1~282^2~49 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acf92b485cccf028177f46918e045c0c4e80ee10;p=pandora-kernel.git vmscan: shrinker->nr updates race and go wrong 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 Signed-off-by: Al Viro --- Reading git-diff-tree failed