[PATCH 29/29] debug delayed free objects

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Wed Sep 22 10:41:05 UTC 2021


Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c
index dc0d2da297a0..99d1656a7822 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -256,6 +256,19 @@ void __i915_gem_free_object(struct drm_i915_gem_object *obj)
 		i915_vm_resv_put(obj->shares_resv_from);
 }
 
+static void _i915_gem_free_object(struct drm_i915_gem_object *obj)
+{
+	if (obj->ops->delayed_free) {
+		obj->ops->delayed_free(obj);
+		return;
+	}
+
+	__i915_gem_free_object(obj);
+
+	/* But keep the pointer alive for RCU-protected lookups */
+	call_rcu(&obj->rcu, __i915_gem_free_object_rcu);
+}
+
 static void __i915_gem_free_objects(struct drm_i915_private *i915,
 				    struct llist_node *freed)
 {
@@ -263,14 +276,7 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 
 	llist_for_each_entry_safe(obj, on, freed, freed) {
 		might_sleep();
-		if (obj->ops->delayed_free) {
-			obj->ops->delayed_free(obj);
-			continue;
-		}
-		__i915_gem_free_object(obj);
-
-		/* But keep the pointer alive for RCU-protected lookups */
-		call_rcu(&obj->rcu, __i915_gem_free_object_rcu);
+		_i915_gem_free_object(obj);
 		cond_resched();
 	}
 }
@@ -326,7 +332,9 @@ static void i915_gem_free_object(struct drm_gem_object *gem_obj)
 	 * crude but effective memory throttling.
 	 */
 
-	if (llist_add(&obj->freed, &i915->mm.free_list))
+	if (!in_atomic() && !irqs_disabled())
+		_i915_gem_free_object(obj);
+	else if (llist_add(&obj->freed, &i915->mm.free_list))
 		queue_work(i915->wq, &i915->mm.free_work);
 }
 
-- 
2.33.0



More information about the Intel-gfx-trybot mailing list