From patchwork Sat Dec 23 10:21:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10131467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6885660318 for ; Sat, 23 Dec 2017 10:21:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 516A0298D2 for ; Sat, 23 Dec 2017 10:21:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 349C629977; Sat, 23 Dec 2017 10:21:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F6F1298D2 for ; Sat, 23 Dec 2017 10:21:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 830FB897E4; Sat, 23 Dec 2017 10:21:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8ED97898F3 for ; Sat, 23 Dec 2017 10:21:37 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 10105255-1500050 for multiple; Sat, 23 Dec 2017 10:21:26 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Sat, 23 Dec 2017 10:21:25 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Sat, 23 Dec 2017 10:21:24 +0000 Message-Id: <20171223102124.26568-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.15.1 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH] drm/i915: Reconstruct active state on starting busy-stats X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Tvrtko Ursulin --- 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;