On Mon, Nov 27, 2017 at 02:27:20PM +0800, jiang.biao2@xxxxxxxxxx wrote:> > I agree with your concern. How about we take another way by > > adding some warning in such case? such as, > > freeable = shrinker->count_objects(shrinker, shrinkctl); > > + if (unlikely(freeable < 0)) { > > + pr_err("shrink_slab: %pF negative objects returned. freeable=%ld\n", > > + shrinker->scan_objects, freeable); > > + freeable = 0; //maybe not needed? > > + } > > if (freeable == 0) > > return 0; > > In this way, we would not break the API, but could alert user exception > > with message, and make it more robust in such case. > > True but it would be a problem robust vs. effectivess tradeoff. > Think about that everyone want to make thier code robust. > It means they start to dump lots of defensive code so code start > to look like complicated as well as binary bloating. > So, whenever we add some more, we should think how effective > the code I am putting? > > In this case, I'm skeptical, Sorry. But others might have different > opinions. :) With all due respect. I still think the robustness is more important than effectiveness in this case. :) First, the minus value could break all the following procedure in do_shrink_slab which may lead to long time looping on *tight on memory* situations. Second, there is *unlikely* macro to minimize the cost. Third, there is already similar procedure for *total_scan < 0*. Last, it did happen in my scenario and maybe happen in other unexpected situations. Just my personal option, thanks a lot for you reply and explanation. :) Regards,