From patchwork Mon Mar 19 18:16:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10293879 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 4C504602C2 for ; Mon, 19 Mar 2018 18:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A39328543 for ; Mon, 19 Mar 2018 18:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ED3929310; Mon, 19 Mar 2018 18:16:53 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 BFCD928543 for ; Mon, 19 Mar 2018 18:16:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 768FF6E5F9; Mon, 19 Mar 2018 18:16:49 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52C786E5F0 for ; Mon, 19 Mar 2018 18:16:38 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id a20so13875409wmd.1 for ; Mon, 19 Mar 2018 11:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XDwgJC3JRp1ncZFi7XWaMTbss/Ucs+YF5OFlQkCA50c=; b=2IXUHr7Yxx+FFe1gKdqhpgh7mvmgth1cOcEOst05GfpCaxpcsesOvVRamu+YGUjzFw 1C7jRYFJcLealLzvkfOE3lVvLzLl3pMWsfLf/gy36h8JaKls6EvIe6FVV058NDP6RJ8W 11LHDJfxB8TOpuUKmpIVh9Hk+pjHjYkN8riy6WLSYPp06acPCp6FqUrdB3qAyETscIwu Pp9+CEC1u5n+BwUbTN1smyShAMn20zAw40z/xD1dNNPD5PluhWL/snqINwY1QVFlTCFo F6hrS/icJGhRdtWFSXAGgm2pBsChZ5KZioxIckBj0pK4BCsIMBAkwFohSW46pvcWIIPL c+Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XDwgJC3JRp1ncZFi7XWaMTbss/Ucs+YF5OFlQkCA50c=; b=N/NiOVcE9tUny3ML6DbApoWZd1Hy/ExtBB1+DpUmWx7vHnp1BJv/QBWafaEU0fWQn+ dNXEeSPswgmyOyPMRNxR3HBqX2eFqj/XBzdlMRa/DXGa1FFnkNkpz/MJewPLr3O8qRjE yq7Pkn3Nggzc3uBeYcniAQMcta/JZpP6ie3IlIvavWASfomLeV/NL1RIFGCTwjmT8aRX R/5wVngIojoaE4ktWnE79Z7D+gOVk2Ro7Mqt8V+oVNvuD+QkC6OcLCSASL06Ijwcd0id BlVk+vrtb9FkV3Vdq+feBXZ3pzme/chjAbVh6cwvBoy3iDhmV3UwgU1weN/k8UD2FCyU Pj8A== X-Gm-Message-State: AElRT7HJ/YgysZ3cqszbWG0sdd+oFxb4zKbQQSGzQ/C8GZyRh0xeS5Fb 6/hMpkvd4z/vp6/RAY7zu7Kv7sht X-Google-Smtp-Source: AG47ELsjlZ1xTftp5AuitKdnqkrbseW6FbMxhAQ7OQ5tONkQPP1EW9HNnlzb+crXsseqz0WJ5dpsjw== X-Received: by 10.28.196.143 with SMTP id u137mr8645737wmf.74.1521483396736; Mon, 19 Mar 2018 11:16:36 -0700 (PDT) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id r19sm1234030wmd.48.2018.03.19.11.16.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 11:16:36 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Mon, 19 Mar 2018 18:16:20 +0000 Message-Id: <20180319181625.29292-3-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180319181625.29292-1-tvrtko.ursulin@linux.intel.com> References: <20180319181625.29292-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH 2/7] drm/i915: Keep a count of requests waiting for a slot on GPU X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 From: Tvrtko Ursulin Keep a per-engine number of runnable (waiting for GPU time) requests. v2: * Move queued increment from insert_request to execlist_submit_request to avoid bumping when re-ordering for priority. * Support the counter on the ringbuffer submission path as well, albeit just notionally. (Chris Wilson) v3: * Rebase. v4: * Rename and move the stats into a container structure. (Chris Wilson) v5: * Re-order fields in struct intel_engine_cs. (Chris Wilson) v6-v8: * Rebases. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_request.c | 7 +++++++ drivers/gpu/drm/i915/intel_engine_cs.c | 5 +++-- drivers/gpu/drm/i915/intel_lrc.c | 1 + drivers/gpu/drm/i915/intel_ringbuffer.h | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 43c7134a9b93..2052028c1d68 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -525,6 +525,9 @@ void __i915_request_submit(struct i915_request *request) engine->emit_breadcrumb(request, request->ring->vaddr + request->postfix); + GEM_BUG_ON(engine->request_stats.runnable == 0); + engine->request_stats.runnable--; + spin_lock(&request->timeline->lock); list_move_tail(&request->link, &timeline->requests); spin_unlock(&request->timeline->lock); @@ -542,6 +545,8 @@ void i915_request_submit(struct i915_request *request) /* Will be called from irq-context when using foreign fences. */ spin_lock_irqsave(&engine->timeline->lock, flags); + engine->request_stats.runnable++; + __i915_request_submit(request); spin_unlock_irqrestore(&engine->timeline->lock, flags); @@ -581,6 +586,8 @@ void __i915_request_unsubmit(struct i915_request *request) timeline = request->timeline; GEM_BUG_ON(timeline == engine->timeline); + engine->request_stats.runnable++; + spin_lock(&timeline->lock); list_move(&request->link, &timeline->requests); spin_unlock(&timeline->lock); diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c index 337dfa56a738..3726544cfb00 100644 --- a/drivers/gpu/drm/i915/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/intel_engine_cs.c @@ -1917,12 +1917,13 @@ void intel_engine_dump(struct intel_engine_cs *engine, if (i915_terminally_wedged(&engine->i915->gpu_error)) drm_printf(m, "*** WEDGED ***\n"); - drm_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms], inflight %d\n", + drm_printf(m, "\tcurrent seqno %x, last %x, hangcheck %x [%d ms], inflight %d, runnable %u\n", intel_engine_get_seqno(engine), intel_engine_last_submit(engine), engine->hangcheck.seqno, jiffies_to_msecs(jiffies - engine->hangcheck.action_timestamp), - engine->timeline->inflight_seqnos); + engine->timeline->inflight_seqnos, + engine->request_stats.runnable); drm_printf(m, "\tReset count: %d (global %d)\n", i915_reset_engine_count(error, engine), i915_reset_count(error)); diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 53f1c009ed7b..46bacd98a360 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -1033,6 +1033,7 @@ static void execlists_submit_request(struct i915_request *request) queue_request(engine, &request->priotree, rq_prio(request)); submit_queue(engine, rq_prio(request)); + engine->request_stats.runnable++; GEM_BUG_ON(!engine->execlists.first); GEM_BUG_ON(list_empty(&request->priotree.link)); diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index 828a1f924405..e98e007cb96b 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h @@ -338,6 +338,15 @@ struct intel_engine_cs { struct drm_i915_gem_object *default_state; + struct { + /** + * @runnable: Number of runnable requests sent to the backend. + * + * Count of requests waiting for the GPU to execute them. + */ + unsigned int runnable; + } request_stats; + atomic_t irq_count; unsigned long irq_posted; #define ENGINE_IRQ_BREADCRUMB 0