From mboxrd@z Thu Jan 1 00:00:00 1970 From: KOSAKI Motohiro Subject: Re: [PATCH] i915: slab shrinker have to return -1 if it cant shrink any objects Date: Tue, 12 Jul 2011 18:36:50 +0900 Message-ID: <4E1C15B2.9020800@jp.fujitsu.com> References: <4E0444CA.3080407@jp.fujitsu.com> <1309424153_44559@CP5-2952> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1309424153_44559@CP5-2952> Sender: linux-kernel-owner@vger.kernel.org To: chris@chris-wilson.co.uk Cc: keithp@keithp.com, linux-kernel@vger.kernel.org, airlied@linux.ie, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org Hi, sorry for the delay. > On Wed, 29 Jun 2011 20:53:54 -0700, Keith Packard wrote: >> On Fri, 24 Jun 2011 17:03:22 +0900, KOSAKI Motohiro wrote: >> >>> Now, i915_gem_inactive_shrink() should return -1 instead of 0 if it >>> can't take a lock. Otherwise, vmscan is getting a lot of confusing >>> because vmscan can't distinguish "can't take a lock temporary" and >>> "we've shrank all of i915 objects". >> >> This doesn't look like the cleanest change possible. I think it would be >> better if the shrink function could uniformly return an error >> indication so that we wouldn't need the weird looking conditional return. shrink_icache_memory() is good sample code. It doesn't take a lock if sc->nr_to_scan==0. i915_gem_inactive_shrink() should do it too, ideally. My patch only take a first-aid. Plus, if I understand correctly, i915_gem_inactive_shrink() have more fundamental issue. actually, shrinker code shouldn't use mutex. Instead, use spinlock. IOW, Don't call kmalloc(GFP_KERNEL) while taking dev->struct_mutex. Otherwise, vmscan in its call path completely fail to shrink i915 cache and it makes big memory reclaim confusing if i915 have a lot of shrinkable pages. > Unless I am mistaken, and there are more patches in flight, the return > code from i915_gem_inactive_shrink() is promoted to unsigned long and then > used in the calculation of how may objects to evict... shrinker->shrink has int type value. you can't change i915_gem_inactive_shrink() unless generic shrinker code. Do you really want to change it?