Fix list empty check in i915_gem_evict_everything
diff mbox

Message ID 1440572486-14715-1-git-send-email-zhiyuan.lv@intel.com
State New
Headers show

Commit Message

Zhiyuan Lv Aug. 26, 2015, 7:01 a.m. UTC
That seems to be a typo. The original code will override the previous
list empty check value in the loop. As the result, only the last vm in
vm_list impacts the empty check. The problem is fixed by using local
bool variable inside the loop.

Signed-off-by: Zhiyuan Lv <zhiyuan.lv@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_evict.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Chris Wilson Aug. 26, 2015, 7:28 a.m. UTC | #1
On Wed, Aug 26, 2015 at 03:01:26PM +0800, Zhiyuan Lv wrote:
> That seems to be a typo. The original code will override the previous
> list empty check value in the loop. As the result, only the last vm in
> vm_list impacts the empty check. The problem is fixed by using local
> bool variable inside the loop.

Or we could just delete the code entirely since it is no longer used
(except for a mistake in shrink-all).
-Chris
Zhiyuan Lv Aug. 26, 2015, 7:52 a.m. UTC | #2
Hi Chris,

Thanks for the reply! Do you mean we could completely delete
i915_gem_evict_everything() and rely on others to do gem_retire_requests()?
Sorry that I am still learning the code :-)

Regards,
-Zhiyuan

On Wed, Aug 26, 2015 at 08:28:43AM +0100, Chris Wilson wrote:
> On Wed, Aug 26, 2015 at 03:01:26PM +0800, Zhiyuan Lv wrote:
> > That seems to be a typo. The original code will override the previous
> > list empty check value in the loop. As the result, only the last vm in
> > vm_list impacts the empty check. The problem is fixed by using local
> > bool variable inside the loop.
> 
> Or we could just delete the code entirely since it is no longer used
> (except for a mistake in shrink-all).
> -Chris
> 
> -- 
> Chris Wilson, Intel Open Source Technology Centre

Patch
diff mbox

diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index d09e35e..a45cffa 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -255,10 +255,12 @@  i915_gem_evict_everything(struct drm_device *dev)
 	int ret;
 
 	list_for_each_entry(vm, &dev_priv->vm_list, global_link) {
-		lists_empty = (list_empty(&vm->inactive_list) &&
+		bool empty = (list_empty(&vm->inactive_list) &&
 			       list_empty(&vm->active_list));
-		if (!lists_empty)
+		if (!empty) {
 			lists_empty = false;
+			break;
+		}
 	}
 
 	if (lists_empty)