[PATCH] shrinker->nr = LONG_MAX means deadlock for icache
With Andrew Morton <akpm@osdl.org> The slab scanning code tries to balance the scanning rate of slabs versus the scanning rate of LRU pages. To do this, it retains state concerning how many slabs have been scanned - if a particular slab shrinker didn't scan enough objects, we remember that for next time, and scan more objects on the next pass. The problem with this is that with (say) a huge number of GFP_NOIO direct-reclaim attempts, the number of objects which are to be scanned when we finally get a GFP_KERNEL request can be huge. Because some shrinker handlers just bail out if !__GFP_FS. So the patch clamps the number of objects-to-be-scanned to 2* the total number of objects in the slab cache. Signed-off-by: Andrea Arcangeli <andrea@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
154f484b92
commit
ea164d73a7
1 changed files with 15 additions and 3 deletions
18
mm/vmscan.c
18
mm/vmscan.c
|
@ -201,13 +201,25 @@ static int shrink_slab(unsigned long scanned, gfp_t gfp_mask,
|
|||
list_for_each_entry(shrinker, &shrinker_list, list) {
|
||||
unsigned long long delta;
|
||||
unsigned long total_scan;
|
||||
unsigned long max_pass = (*shrinker->shrinker)(0, gfp_mask);
|
||||
|
||||
delta = (4 * scanned) / shrinker->seeks;
|
||||
delta *= (*shrinker->shrinker)(0, gfp_mask);
|
||||
delta *= max_pass;
|
||||
do_div(delta, lru_pages + 1);
|
||||
shrinker->nr += delta;
|
||||
if (shrinker->nr < 0)
|
||||
shrinker->nr = LONG_MAX; /* It wrapped! */
|
||||
if (shrinker->nr < 0) {
|
||||
printk(KERN_ERR "%s: nr=%ld\n",
|
||||
__FUNCTION__, shrinker->nr);
|
||||
shrinker->nr = max_pass;
|
||||
}
|
||||
|
||||
/*
|
||||
* Avoid risking looping forever due to too large nr value:
|
||||
* never try to free more than twice the estimate number of
|
||||
* freeable entries.
|
||||
*/
|
||||
if (shrinker->nr > max_pass * 2)
|
||||
shrinker->nr = max_pass * 2;
|
||||
|
||||
total_scan = shrinker->nr;
|
||||
shrinker->nr = 0;
|
||||
|
|
Loading…
Reference in a new issue