Skip to content

Commit

Permalink
Return number of pages freed in the __arc_shrunker_func().
Browse files Browse the repository at this point in the history
According to the comments in the kernel's shrinker.h file, the
scan_objects callback should return the number of objects actually
freed.  Previously, the shrinker returned the number of objects which
were _attempted_ to be freed.  When the return value of a shrinker is
too high, callers may retry shrinking indefinitely.
  • Loading branch information
dweeezil committed Oct 2, 2014
1 parent cb08f06 commit af59f0e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,7 @@ arc_evictable_memory(void) {
static int
__arc_shrinker_func(struct shrinker *shrink, struct shrink_control *sc)
{
uint64_t pages;
uint64_t oldpages, pages;

/* The arc is considered warm once reclaim has occurred */
if (unlikely(arc_warm == B_FALSE))
Expand All @@ -2632,8 +2632,13 @@ __arc_shrinker_func(struct shrinker *shrink, struct shrink_control *sc)
* reap whatever we can from the various arc slabs.
*/
if (pages > 0) {
oldpages = btop(arc_evictable_memory());
arc_kmem_reap_now(ARC_RECLAIM_AGGR, ptob(sc->nr_to_scan));
pages = btop(arc_evictable_memory());
if (pages > oldpages)
pages = pages - oldpages;
else
pages = 0;
} else {
arc_kmem_reap_now(ARC_RECLAIM_CONS, ptob(sc->nr_to_scan));
pages = -1;
Expand Down

0 comments on commit af59f0e

Please sign in to comment.