Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
Return -1 for generic kmem cache shrinker
Browse files Browse the repository at this point in the history
It has been observed that it's possible to get in a state where
shrink_slabs() will spin repeated invoking the generic kmem cache
shrinker.  It fails to detect it's not making forward progress
reclaiming from the cache and doesn't give up.  To ensure this
never occurs we unconditionally return -1 after reclaiming what
we can.

Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs/zfs#1276
Closes openzfs/zfs#1598
Closes openzfs/zfs#1432
  • Loading branch information
behlendorf committed Jul 30, 2013
1 parent c47efbc commit b9b3715
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion module/spl/spl-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,15 @@ __spl_kmem_cache_generic_shrinker(struct shrinker *shrink,
}
up_read(&spl_kmem_cache_sem);

return (unused * sysctl_vfs_cache_pressure) / 100;
/*
* After performing reclaim always return -1 to indicate we cannot
* perform additional reclaim. This prevents shrink_slabs() from
* repeatedly invoking this generic shrinker and potentially spinning.
*/
if (sc->nr_to_scan)
return -1;

return unused;
}

SPL_SHRINKER_CALLBACK_WRAPPER(spl_kmem_cache_generic_shrinker);
Expand Down

0 comments on commit b9b3715

Please sign in to comment.