Re: [PATCH] i915: slab shrinker have to return -1 if it cantshrink any objects

From: Dave Chinner
Date: Wed Jul 13 2011 - 06:42:43 EST


On Wed, Jul 13, 2011 at 05:19:22PM +0900, KOSAKI Motohiro wrote:
> (2011/07/13 16:41), Chris Wilson wrote:
> >> (snip)
> >> while (total_scan >= SHRINK_BATCH) {
> >> long this_scan = SHRINK_BATCH;
> >> int shrink_ret;
> >> int nr_before;
> >>
> >> nr_before = do_shrinker_shrink(shrinker, shrink, 0);
> >> shrink_ret = do_shrinker_shrink(shrinker, shrink,
> >> this_scan);
> >> if (shrink_ret == -1)
> >> break;
> >>
> >
> > And fifteen lines above that you have:
> > unsigned long max_pass = do_shrinker_shrink(shrinker, shrinker, 0);
> > ...
> > shrinker->nr += f(max_pass);
> > if (shrinker->nr < 0) printk(KERN_ERR "...");
> >
> > That's the *error* I hit when I originally returned -1.
>
> You misunderstand the code. The third argument is critically important.
> Only if it's 0 (ie sc->nr_to_scan==0), shrinker must not return negative.

And once again the shitty shrinker API bites a user.

> Thus, my patch checked nr_to_scan argument. and I've suggested look at
> shrink_icache_memory().

Which is going away real soon - it's not the model of perfection
that you make it out to be. ;)

> If you are thinking the shrinker protocol is too complicated, doc update
> patch is really welcome.

Slab shrinkers have a nasty, crappy interface and the shrink_slab()
code is full of bugs. Rather that telling people to "update the
documentation" because it's too complex, how about we fix the
interface and the bugs?

Indeed, how hard is it to require a subsystem to supply two shrinker
methods, one to return the count of reclaimable objects, the other
to scan the reclaimable objects to reclaim them? After all, that's
exactly the interface I'm exposing to filesystems underneath the
shrinker API in the per-sb shrinker patchset that gets rid of
shrink_icache_memory() rather than propagating the insanity....

Cheers,

Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/