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=-13.0 required=3.0 tests=BAYES_00, 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 99D72C433DF for ; Sun, 2 Aug 2020 16:44:24 +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 5F4A620738 for ; Sun, 2 Aug 2020 16:44:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F4A620738 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 042D26E160; Sun, 2 Aug 2020 16:44:23 +0000 (UTC) Received: from fireflyinternet.com (unknown [77.68.26.236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9E09C6E159 for ; Sun, 2 Aug 2020 16:44:20 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from build.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 22010448-1500050 for multiple; Sun, 02 Aug 2020 17:44:18 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Sun, 2 Aug 2020 17:43:59 +0100 Message-Id: <20200802164412.2738-30-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200802164412.2738-1-chris@chris-wilson.co.uk> References: <20200802164412.2738-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 29/42] drm/i915/gt: Defer the kmem_cache_free() until after the HW submit 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: , Cc: Chris Wilson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Watching lock_stat, we noticed that the kmem_cache_free() would cause the occasional multi-millisecond spike (directly affecting max-holdtime and so the max-waittime). Delaying our submission of the next ELSP by a millisecond will leave the GPU idle, so defer the kmem_cache_free() until afterwards. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/gt/intel_lrc.c | 10 +++++++++- drivers/gpu/drm/i915/i915_scheduler.c | 13 +++++++++++++ drivers/gpu/drm/i915/i915_scheduler.h | 12 ++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c index e8f6d0a80c8e..7ac864cd57e3 100644 --- a/drivers/gpu/drm/i915/gt/intel_lrc.c +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c @@ -2029,6 +2029,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine) struct i915_request **port = execlists->pending; struct i915_request ** const last_port = port + execlists->port_mask; struct i915_request *last = *execlists->active; + struct list_head *free = NULL; struct virtual_engine *ve; struct rb_node *rb; bool submit = false; @@ -2316,8 +2317,9 @@ static void execlists_dequeue(struct intel_engine_cs *engine) } } + /* Remove the node, but defer the free for later */ rb_erase_cached(&p->node, &execlists->queue); - i915_priolist_free(p); + free = i915_priolist_free_defer(p, free); } done: *port++ = i915_request_get(last); @@ -2369,6 +2371,12 @@ static void execlists_dequeue(struct intel_engine_cs *engine) i915_request_put(*port); *execlists->pending = NULL; } + + /* + * We noticed that kmem_cache_free() may cause 1ms+ latencies, so + * we defer the frees until after we have submitted the ELSP. + */ + i915_priolist_free_many(free); } static inline void clear_ports(struct i915_request **ports, int count) diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c index a9973d7a724c..bfbbd94dfcbc 100644 --- a/drivers/gpu/drm/i915/i915_scheduler.c +++ b/drivers/gpu/drm/i915/i915_scheduler.c @@ -126,6 +126,19 @@ void __i915_priolist_free(struct i915_priolist *p) kmem_cache_free(global.slab_priorities, p); } +void i915_priolist_free_many(struct list_head *list) +{ + while (list) { + struct i915_priolist *p; + + p = container_of(list, typeof(*p), requests); + list = p->requests.next; + + GEM_BUG_ON(p->priority == I915_PRIORITY_NORMAL); + kmem_cache_free(global.slab_priorities, p); + } +} + struct sched_cache { struct list_head *priolist; }; diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h index b089d5cace1d..d8bf335c5e96 100644 --- a/drivers/gpu/drm/i915/i915_scheduler.h +++ b/drivers/gpu/drm/i915/i915_scheduler.h @@ -46,4 +46,16 @@ static inline void i915_priolist_free(struct i915_priolist *p) __i915_priolist_free(p); } +void i915_priolist_free_many(struct list_head *list); + +static inline struct list_head * +i915_priolist_free_defer(struct i915_priolist *p, struct list_head *free) +{ + if (p->priority != I915_PRIORITY_NORMAL) { + p->requests.next = free; + free = &p->requests; + } + return free; +} + #endif /* _I915_SCHEDULER_H_ */ -- 2.20.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx