On Mon, Oct 14, 2019 at 01:46:04AM -0700, Christoph Hellwig wrote: > On Wed, Oct 09, 2019 at 02:21:06PM +1100, Dave Chinner wrote: > > From: Dave Chinner <dchinner@xxxxxxxxxx> > > > > Introduce a mechanism for ->count_objects() to indicate to the > > shrinker infrastructure that the reclaim context will not allow > > scanning work to be done and so the work it decides is necessary > > needs to be deferred. > > > > This simplifies the code by separating out the accounting of > > deferred work from the actual doing of the work, and allows better > > decisions to be made by the shrinekr control logic on what action it > > can take. > > I hate all this boilerplate code in the scanners. Can't we just add > a a required_gfp_mask field to struct shrinker and lift the pattern > to common code? Because the deferral isn't intended to support just deferring work from GFP_NOFS reclaim context. e.g. i915_gem_shrinker_scan() stops the shrinker if it can't get a lock to avoid recursion deadlocks. There's several other shrinkers that have similar logic that punts work to avoid deadlocks, and so they could also use deferred work to punt it kswapd.... i.e. while I currently use it for GFP_NOFS deferal, that's no the only reason for defering work... Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx