We have a hole in our busy-stat accounting if the pmu is enabled during
a long running batch, the pmu will not start accumulating busy-time
until the next context switch. This then fails tests that are only
sampling a single batch.

Testcase: igt/perf_pmu/start-busy # To Be Written
Signed-off-by: Chris Wilson <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
---
We should also construct a queue of batches just to complicate things.

spin1 = spin_batch;
for (QLEN - 1) {
        rvsd1 = create_context;
        resubmit_spin1_batch;
        delete_context(rsvd1);
}
rsvd1 = create_context;
spin2 = spin_batch()
delete_context(rsvd1);

start_pmu
cancel_spin1
usleep(batch_duration)
cancel_spin2
end_pmu

assert(busy == batch_duration);
---
 drivers/gpu/drm/i915/intel_engine_cs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c 
b/drivers/gpu/drm/i915/intel_engine_cs.c
index ebdcbcbacb3c..c2f01ff96ce1 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -1946,8 +1946,15 @@ int intel_enable_engine_stats(struct intel_engine_cs 
*engine)
        spin_lock_irqsave(&engine->stats.lock, flags);
        if (engine->stats.enabled == ~0)
                goto busy;
-       if (engine->stats.enabled++ == 0)
+       if (engine->stats.enabled++ == 0) {
                engine->stats.enabled_at = ktime_get();
+
+               /* XXX submission method oblivious */
+               engine->stats.active = port_count(&engine->execlists.port[1]);
+               engine->stats.active += port_count(&engine->execlists.port[0]);
+               if (engine->stats.active)
+                       engine->stats.start = engine->stats.enabled_at;
+       }
        spin_unlock_irqrestore(&engine->stats.lock, flags);
 
        return 0;
-- 
2.15.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to