[Intel-gfx] [PATCH 1/6] drm/i915/gem: Move obj->lut_list under its own lock
Chris Wilson
chris at chris-wilson.co.uk
Mon Jun 29 10:50:57 UTC 2020
Quoting Chris Wilson (2020-06-29 11:12:51)
> @@ -108,7 +109,7 @@ void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file)
> struct i915_lut_handle *lut, *ln;
> LIST_HEAD(close);
>
> - i915_gem_object_lock(obj);
> + spin_lock(&obj->lut_lock);
> list_for_each_entry_safe(lut, ln, &obj->lut_list, obj_link) {
> struct i915_gem_context *ctx = lut->ctx;
>
> @@ -118,7 +119,7 @@ void i915_gem_close_object(struct drm_gem_object *gem, struct drm_file *file)
> i915_gem_context_get(ctx);
> list_move(&lut->obj_link, &close);
> }
> - i915_gem_object_unlock(obj);
> + spin_unlock(&obj->lut_lock);
This is only real worry, iterating under the spinlock.
If we worry, we can do something like
+ struct i915_lut_handle bookmark = {};
LIST_HEAD(close);
spin_lock(&obj->lut_lock);
list_for_each_entry_safe(lut, ln, &obj->lut_list, obj_link) {
struct i915_gem_context *ctx = lut->ctx;
- if (ctx->file_priv != fpriv)
- continue;
+ if (ctx && ctx->file_priv == fpriv) {
+ i915_gem_context_get(ctx);
+ list_move(&lut->obj_link, &close);
+ }
- i915_gem_context_get(ctx);
- list_move(&lut->obj_link, &close);
+ if (ln != &obj->lut_list) {
+ list_add(&bookmark->obj_link, &ln->obj_link);
+ if (cond_resched_lock(&obj->lut_lock))
+ list_safe_reset_next(&bookmark, ln, obj_link);
+ list_del_entry(&bookmark->obj_link);
+ }
}
Might as well worry.
-Chris
More information about the Intel-gfx
mailing list