[Intel-gfx] [RFC 4/5] drm/i915: Expose per-engine client busyness
Chris Wilson
chris at chris-wilson.co.uk
Fri Oct 25 14:42:16 UTC 2019
Quoting Tvrtko Ursulin (2019-10-25 15:21:30)
> +static int busy_add(int id, void *p, void *data)
> +{
> + struct busy_ctx *bc = data;
> + struct i915_gem_context *ctx = p;
> + unsigned int engine_class = bc->engine_class;
> + struct i915_gem_engines_iter it;
> + struct intel_context *ce;
> + uint64_t total = bc->total;
> +
> + for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it) {
> + if (ce->engine->uabi_class == engine_class)
> + total += ktime_to_ns(intel_context_get_busy_time(ce));
> + }
> + i915_gem_context_unlock_engines(ctx);
> +
> + bc->total = total;
> +
> + return 0;
> +}
> +
> +static ssize_t
> +show_client_busy(struct device *kdev, struct device_attribute *attr, char *buf)
> +{
> + struct i915_engine_busy_attribute *i915_attr =
> + container_of(attr, typeof(*i915_attr), attr);
> + struct drm_i915_file_private *file_priv = i915_attr->file_priv;
> + struct busy_ctx bc = { .engine_class = i915_attr->engine_class };
> + int ret;
> +
> + ret = mutex_lock_interruptible(&file_priv->context_idr_lock);
> + if (ret)
> + return ret;
> +
> + idr_for_each(&file_priv->context_idr, busy_add, &bc);
If you don a hard hat, this can all be done under rcu_read_lock().
-Chris
More information about the Intel-gfx
mailing list