Skip to content

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 <behlendorf1@llnl.gov>
Issue openzfs/zfs#1276
Issue openzfs/zfs#1598
  • Loading branch information
behlendorf authored and ryao committed Aug 4, 2013
1 parent 9d8eb3c commit 5aed38f
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 @@ -2139,7 +2139,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 5aed38f

Please sign in to comment.