drm/i915: Track hw reported context runtime
Subsystems (2)
From: Tvrtko Ursulin <[email protected]>
GPU saves accumulated context runtime (in CS timestamp units) in PPHWSP which will be useful for us in cases when we are not able to track context busyness ourselves (like with GuC). Keep a copy of this in struct intel_context from where it can be easily read even if the context is not pinned.
QQQ: Do we want to make this accounting conditional / able to turn on/off?
v2:
(Chris)
* Do not store pphwsp address in intel_context.
* Log CS wrap-around.
* Simplify calculation by relying on integer wraparound.
--- drivers/gpu/drm/i915/gt/intel_context.c | 6 +- drivers/gpu/drm/i915/gt/intel_context.h | 17 ++++ drivers/gpu/drm/i915/gt/intel_context_types.h | 12 +++ drivers/gpu/drm/i915/gt/intel_lrc.c | 44 ++++++++- drivers/gpu/drm/i915/gt/selftest_lrc.c | 90 +++++++++++++++++++ drivers/gpu/drm/i915/i915_gpu_error.c | 11 ++- drivers/gpu/drm/i915/i915_gpu_error.h | 4 + drivers/gpu/drm/i915/intel_device_info.c | 6 ++ drivers/gpu/drm/i915/intel_device_info.h | 1 + 9 files changed, 186 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gt/intel_context.c +5 -1
@@ -220,7 +220,9 @@ static void __intel_context_retire(struct i915_active *active) {struct intel_context *ce =container_of (active,typeof (*ce), active); -CE_TRACE (ce,"retire\n" ); +CE_TRACE (ce,"retire runtime: { total:%lluns, avg:%lluns }\n" , +intel_context_get_total_runtime_ns (ce), +intel_context_get_avg_runtime_ns (ce));set_bit (CONTEXT_VALID_BIT , &ce->flags);if (ce->state)
@@ -281,6 +283,8 @@ intel_context_init(struct intel_context *ce, ce->sseu = engine->sseu; ce->ring =__intel_context_ring_size (SZ_4K ); +ewma_runtime_init (&ce->runtime.avg); + ce->vm =i915_vm_get (engine->gt->vm);INIT_LIST_HEAD (&ce->signal_link);
drivers/gpu/drm/i915/gt/intel_context.h +17 -0
@@ -12,6 +12,7 @@#include <linux/types.h> #include "i915_active.h" +#include "i915_drv.h" #include "intel_context_types.h" #include "intel_engine_types.h" #include "intel_ring_types.h"
@@ -227,4 +228,20 @@ intel_context_clear_nopreempt(struct intel_context *ce) clear_bit(CONTEXT_NOPREEMPT, &ce->flags); } +static inline u64 intel_context_get_total_runtime_ns (struct intel_context *ce) +{ +const u32 period = +RUNTIME_INFO (ce->engine->i915)->cs_timestamp_period_ns; + +return READ_ONCE (ce->runtime.total) * period; +} + +static inline u64 intel_context_get_avg_runtime_ns (struct intel_context *ce) +{ +const u32 period = +RUNTIME_INFO (ce->engine->i915)->cs_timestamp_period_ns; + +return mul_u32_u32 (ewma_runtime_read (&ce->runtime.avg), period); +} +#endif /* __INTEL_CONTEXT_H__ */
drivers/gpu/drm/i915/gt/intel_context_types.h +12 -0
@@ -7,6 +7,7 @@#ifndef __INTEL_CONTEXT_TYPES__#define __INTEL_CONTEXT_TYPES__ +#include <linux/average.h> #include <linux/kref.h> #include <linux/list.h> #include <linux/mutex.h>
@@ -19,6 +20,8 @@#define CONTEXT_REDZONE POISON_INUSE +DECLARE_EWMA (runtime,3 ,4 ); +struct i915_gem_context ;struct i915_vma ;struct intel_context ;
@@ -68,6 +71,15 @@ struct intel_context {u64 lrc_desc;u32 tag;/* cookie passed to HW to track this context on submission */ +/* Time on GPU as tracked by the hw. */ +struct { +struct ewma_runtime avg; +u64 total; +u32 last; + I915_SELFTEST_DECLARE(u32 num_underflow); + I915_SELFTEST_DECLARE(u32 max_underflow); + } runtime; +unsigned int active_count;/* protected by timeline->mutex */ atomic_t pin_count;
drivers/gpu/drm/i915/gt/intel_lrc.c +42 -2
62 lines not on this page · raw message
drivers/gpu/drm/i915/gt/selftest_lrc.c +90 -0
102 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gpu_error.c +9 -2
@@ -481,9 +481,13 @@ static void error_print_context(struct drm_i915_error_state_buf *m,const char *header, const struct i915_gem_context_coredump *ctx) { - err_printf(m, "%s%s[%d] prio %d, guilty %d active %d\n", + const u32 period = RUNTIME_INFO(m->i915)->cs_timestamp_period_ns; + +err_printf (m,"%s%s[%d] prio %d, guilty %d active %d, runtime total %lluns, avg %lluns\n" , header, ctx->comm, ctx->pid, ctx->sched_attr.priority, - ctx->guilty, ctx->active); + ctx->guilty, ctx->active, + ctx->total_runtime * period, +mul_u32_u32 (ctx->avg_runtime, period)); } static struct i915_vma_coredump *
@@ -1260,6 +1264,9 @@ static bool record_context(struct i915_gem_context_coredump *e, e->guilty =atomic_read (&ctx->guilty_count); e->active =atomic_read (&ctx->active_count); + e->total_runtime = rq->context->runtime.total; + e->avg_runtime =ewma_runtime_read (&rq->context->runtime.avg); + simulated =i915_gem_context_no_error_capture (ctx);i915_gem_context_put (ctx);
drivers/gpu/drm/i915/i915_gpu_error.h +4 -0
@@ -88,6 +88,10 @@ struct intel_engine_coredump {struct i915_gem_context_coredump {char comm[TASK_COMM_LEN ]; + +u64 total_runtime; +u32 avg_runtime; +pid_t pid;int active;int guilty;
drivers/gpu/drm/i915/intel_device_info.c +6 -0
@@ -1045,6 +1045,12 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)/* Initialize command stream timestamp frequency */ runtime->cs_timestamp_frequency_khz =read_timestamp_frequency (dev_priv); + runtime->cs_timestamp_period_ns = +div_u64 (1e6 , runtime->cs_timestamp_frequency_khz); +drm_dbg (&dev_priv->drm, +"CS timestamp wraparound in %lldms\n" , +div_u64 (mul_u32_u32 (runtime->cs_timestamp_period_ns,U32_MAX ), +USEC_PER_SEC )); } void intel_driver_caps_print(const struct intel_driver_caps *caps,
drivers/gpu/drm/i915/intel_device_info.h +1 -0
@@ -217,6 +217,7 @@ struct intel_runtime_info {struct sseu_dev_info sseu;u32 cs_timestamp_frequency_khz; +u32 cs_timestamp_period_ns;/* Media engine access to SFC per instance */ u8 vdbox_sfc_access;
Signature · 6 lines
2.25.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Track hw reported context runtime (rev3)
== Series Details ==
== Series Details ==
Series: drm/i915: Track hw reported context runtime (rev3)
URL : https://patchwork.freedesktop.org/series/73499/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 953502e2ee73 drm/i915: Track hw reported context runtime -:109: WARNING:LINE_SPACING: Missing a blank line after declarations #109: FILE: drivers/gpu/drm/i915/gt/intel_context_types.h:79: + u32 last; + I915_SELFTEST_DECLARE(u32 num_underflow);
-:197: WARNING:LINE_SPACING: Missing a blank line after declarations #197: FILE: drivers/gpu/drm/i915/gt/selftest_lrc.c:4457:
+ struct i915_request *rq;
+ IGT_TIMEOUT(end_time);
total: 0 errors, 2 warnings, 0 checks, 292 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915: Track hw reported context runtime (rev3)
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: drm/i915: Track hw reported context runtime (rev3)
URL : https://patchwork.freedesktop.org/series/73499/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_7948 -> Patchwork_16584
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_16584:
### IGT changes ###
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@i915_selftest@live_gt_lrc:
- {fi-tgl-u}: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7948/fi-tgl-u/igt@i915_selftest@live_gt_lrc.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/fi-tgl-u/igt@i915_selftest@live_gt_lrc.html
- {fi-tgl-dsi}: [PASS][3] -> [DMESG-FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7948/fi-tgl-dsi/igt@i915_selftest@live_gt_lrc.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/fi-tgl-dsi/igt@i915_selftest@live_gt_lrc.html
Known issues
------------
Here are the changes found in Patchwork_16584 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live_gtt:
- fi-kbl-7500u: [PASS][5] -> [TIMEOUT][6] ([fdo#112271])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7948/fi-kbl-7500u/igt@i915_selftest@live_gtt.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/fi-kbl-7500u/igt@i915_selftest@live_gtt.html
#### Possible fixes ####
* igt@gem_close_race@basic-threads:
- fi-byt-j1900: [INCOMPLETE][7] ([i915#45]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7948/fi-byt-j1900/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/fi-byt-j1900/igt@[email protected]
* igt@i915_selftest@live_gem_contexts:
- fi-bsw-nick: [INCOMPLETE][9] ([i915#392]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7948/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html
* igt@i915_selftest@live_gtt:
- {fi-tgl-dsi}: [TIMEOUT][11] ([fdo#112126] / [fdo#112271]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7948/fi-tgl-dsi/igt@i915_selftest@live_gtt.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/fi-tgl-dsi/igt@i915_selftest@live_gtt.html
* igt@kms_chamelium@dp-edid-read:
- fi-cml-u2: [FAIL][13] ([i915#217] / [i915#976]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7948/fi-cml-u2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/fi-cml-u2/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#112126]: https://bugs.freedesktop.org/show_bug.cgi?id=112126
[fdo#112271]: https://bugs.freedesktop.org/show_bug.cgi?id=112271
[i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
[i915#392]: https://gitlab.freedesktop.org/drm/intel/issues/392
[i915#45]: https://gitlab.freedesktop.org/drm/intel/issues/45
[i915#976]: https://gitlab.freedesktop.org/drm/intel/issues/976
Participating hosts (46 -> 35)
------------------------------
Additional (1): fi-bsw-kefka
Missing (12): fi-ehl-1 fi-bdw-samus fi-hsw-4200u fi-byt-squawks fi-bwr-2160 fi-ctg-p8600 fi-cfl-8109u fi-elk-e7500 fi-skl-lmem fi-blb-e6850 fi-byt-clapper fi-skl-6600u
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_7948 -> Patchwork_16584
CI-20190529: 20190529
CI_DRM_7948: 129a4630a618fee5d2eaa4290cd367e24893bc91 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5444: c46bae259d427f53fcfcd5f05de0181a9e82d6fe @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_16584: 953502e2ee734d9982f5f9dedb0baa48a4221601 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
953502e2ee73 drm/i915: Track hw reported context runtime
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16584/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx