From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DF6BC33CAD for ; Mon, 13 Jan 2020 14:04:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 155A72073D for ; Mon, 13 Jan 2020 14:04:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 155A72073D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E0AA89E38; Mon, 13 Jan 2020 14:04:23 +0000 (UTC) Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6252689E38 for ; Mon, 13 Jan 2020 14:04:22 +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 19862272-1500050 for multiple; Mon, 13 Jan 2020 14:04:09 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 13 Jan 2020 14:04:07 +0000 Message-Id: <20200113140407.1856468-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.25.0.rc2 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: Preemptive timeline retirement X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Currently, we only retire the oldest request on the timeline before allocating the next, but only if there is a spare request. However, since we rearranged the locking, e.g. commit df9f85d8582e ("drm/i915: Serialise i915_active_fence_set() with itself"), we no longer benefit from keeping the active chain intact underneath the struct_mutex. As such, retire all completed requests in the client's timeline before creating the next, trying to keep our memory and resource usage tight and ideally only penalising the heavy users. References: df9f85d8582e ("drm/i915: Serialise i915_active_fence_set() with itself") Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_request.c | 44 ++++------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 9ed0d3bc7249..5743edb50688 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -558,21 +558,12 @@ request_alloc_slow(struct intel_timeline *tl, gfp_t gfp) { struct i915_request *rq; - if (list_empty(&tl->requests)) - goto out; + if (gfpflags_allow_blocking(gfp)) + return NULL; - if (!gfpflags_allow_blocking(gfp)) + if (list_empty(&tl->requests)) goto out; - /* Move our oldest request to the slab-cache (if not in use!) */ - rq = list_first_entry(&tl->requests, typeof(*rq), link); - i915_request_retire(rq); - - rq = kmem_cache_alloc(global.slab_requests, - gfp | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); - if (rq) - return rq; - /* Ratelimit ourselves to prevent oom from malicious clients */ rq = list_last_entry(&tl->requests, typeof(*rq), link); cond_synchronize_rcu(rq->rcustate); @@ -739,9 +730,7 @@ i915_request_create(struct intel_context *ce) return ERR_CAST(tl); /* Move our oldest request to the slab-cache (if not in use!) */ - rq = list_first_entry(&tl->requests, typeof(*rq), link); - if (!list_is_last(&rq->link, &tl->requests)) - i915_request_retire(rq); + retire_requests(tl); intel_context_enter(ce); rq = __i915_request_create(ce, GFP_KERNEL); @@ -1304,14 +1293,13 @@ void i915_request_add(struct i915_request *rq) { struct intel_timeline * const tl = i915_request_timeline(rq); struct i915_sched_attr attr = {}; - struct i915_request *prev; lockdep_assert_held(&tl->mutex); lockdep_unpin_lock(&tl->mutex, rq->cookie); trace_i915_request_add(rq); - prev = __i915_request_commit(rq); + __i915_request_commit(rq); if (rcu_access_pointer(rq->context->gem_context)) attr = i915_request_gem_context(rq)->sched; @@ -1344,28 +1332,6 @@ void i915_request_add(struct i915_request *rq) __i915_request_queue(rq, &attr); local_bh_enable(); /* Kick the execlists tasklet if just scheduled */ - /* - * In typical scenarios, we do not expect the previous request on - * the timeline to be still tracked by timeline->last_request if it - * has been completed. If the completed request is still here, that - * implies that request retirement is a long way behind submission, - * suggesting that we haven't been retiring frequently enough from - * the combination of retire-before-alloc, waiters and the background - * retirement worker. So if the last request on this timeline was - * already completed, do a catch up pass, flushing the retirement queue - * up to this client. Since we have now moved the heaviest operations - * during retirement onto secondary workers, such as freeing objects - * or contexts, retiring a bunch of requests is mostly list management - * (and cache misses), and so we should not be overly penalizing this - * client by performing excess work, though we may still performing - * work on behalf of others -- but instead we should benefit from - * improved resource management. (Well, that's the theory at least.) - */ - if (prev && - i915_request_completed(prev) && - rcu_access_pointer(prev->timeline) == tl) - i915_request_retire_upto(prev); - mutex_unlock(&tl->mutex); } -- 2.25.0.rc2 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx