Message ID | 20210122122903.23893-1-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [CI,1/9] drm/i915/gt: Show the per-engine runtime in sysfs | expand |
On 22/01/2021 12:28, Chris Wilson wrote: > Since we already report the per-engine runtime via PMU (using sampling > if a direct measure is not available), and in debugfs, also trivially > include the information for each engine under sysfs as a read-only > property. We only present the total milliseconds to hide any misleading > accuracy and to purposely reduce the precision of the global > unprivileged information. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > --- > drivers/gpu/drm/i915/gt/sysfs_engines.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c > index 967031056202..57ef5383dd4e 100644 > --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c > +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c > @@ -411,6 +411,19 @@ heartbeat_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > static struct kobj_attribute heartbeat_interval_def = > __ATTR(heartbeat_interval_ms, 0444, heartbeat_default, NULL); > > +static ssize_t > +runtime_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) > +{ > + struct intel_engine_cs *engine = kobj_to_engine(kobj); > + ktime_t dummy; > + > + return sprintf(buf, "%llu\n", > + ktime_to_ms(intel_engine_get_busy_time(engine, &dummy))); > +} > + > +static struct kobj_attribute runtime_attr = > +__ATTR(runtime_ms, 0444, runtime_show, NULL); > + > static void kobj_engine_release(struct kobject *kobj) > { > kfree(kobj); > @@ -521,6 +534,10 @@ void intel_engines_add_sysfs(struct drm_i915_private *i915) > sysfs_create_file(kobj, &preempt_timeout_attr.attr)) > goto err_engine; > > + if (intel_engine_supports_stats(engine) && > + sysfs_create_file(kobj, &runtime_attr.attr)) > + goto err_engine; > + > add_defaults(container_of(kobj, struct kobj_engine, base)); > > if (0) { > Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Regards, Tvrtko
diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c index 967031056202..57ef5383dd4e 100644 --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c @@ -411,6 +411,19 @@ heartbeat_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf) static struct kobj_attribute heartbeat_interval_def = __ATTR(heartbeat_interval_ms, 0444, heartbeat_default, NULL); +static ssize_t +runtime_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + struct intel_engine_cs *engine = kobj_to_engine(kobj); + ktime_t dummy; + + return sprintf(buf, "%llu\n", + ktime_to_ms(intel_engine_get_busy_time(engine, &dummy))); +} + +static struct kobj_attribute runtime_attr = +__ATTR(runtime_ms, 0444, runtime_show, NULL); + static void kobj_engine_release(struct kobject *kobj) { kfree(kobj); @@ -521,6 +534,10 @@ void intel_engines_add_sysfs(struct drm_i915_private *i915) sysfs_create_file(kobj, &preempt_timeout_attr.attr)) goto err_engine; + if (intel_engine_supports_stats(engine) && + sysfs_create_file(kobj, &runtime_attr.attr)) + goto err_engine; + add_defaults(container_of(kobj, struct kobj_engine, base)); if (0) {
Since we already report the per-engine runtime via PMU (using sampling if a direct measure is not available), and in debugfs, also trivially include the information for each engine under sysfs as a read-only property. We only present the total milliseconds to hide any misleading accuracy and to purposely reduce the precision of the global unprivileged information. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> --- drivers/gpu/drm/i915/gt/sysfs_engines.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)