Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13A10606A320 for ; Tue, 1 Dec 2026 15:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=C1hJz6EJ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C0F710FA34; Tue, 1 Dec 2026 15:42:45 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id BBDC610FA34 for ; Tue, 1 Dec 2026 15:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:From:Reply-To; bh=a6LOxx0vXir+BdcYS5/VsxD7coWUdP5Dn/GL1WwF+1A=; t=1796139758; x=2111499758; b=C1hJz6EJFviVVdIui7i7u4OAlvV+33UXdlVuCPhpi7t4/v5czYNpzJEyy3XWokUhL03BuMMZ4yQ RQ62s5Yx8JrBFuCSfB80VoQhizYarum23ZXXtMo6g2FonrJt8Q6uwCGb8D0VrnnMZ/YmCLzbCziSX Sz/h6ph8zFEpOR/cfcbgXe3lem2h1Aw3fydL8zYYNTsQWllfUqzphv9GRYQ9jPwScYghZ8u5X8Sv4 C4vVkScjpFe61+NjRMKqFhni+Hmo8Mm8d+T/hWtONoeMXSGexHkkDNzMLR24h+bN/botFEtevFN7G 5Gj4KzkxH1XEhxc577/myN1IzgxEdkpo8MZg==; Received: from [81.79.79.1] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1xYQ05-00000000ilR-1HiJ; Tue, 01 Dec 2026 16:42:37 +0100 From: Tvrtko Ursulin To: amd-gfx@lists.freedesktop.org Cc: kernel-dev@igalia.com, Tvrtko Ursulin , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , =?UTF-8?q?Timur=20Krist=C3=B3f?= Subject: [RFC v3 4/4] drm/amdgpu: Use high priority scheduler workqueue for high priority rings Date: Tue, 1 Dec 2026 15:42:32 +0000 Message-ID: <20261201154232.78320-5-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261201154232.78320-1-tvrtko.ursulin@igalia.com> References: <20261201154232.78320-1-tvrtko.ursulin@igalia.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-17.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Back when DRM scheduler was kthread based the submission threads were using SCHED_FIFO to minimize the delays in feeding the GPU. This was lost with the conversion to workqueues but has recently been shown on other drivers (panthor, xe) that modern userspace can still suffer severe submission latencies under CPU load. Lets convert amdgpu to use own workqueues and make the high priority rings use WQ_HIGHPRI while at it. This is not expected to be a significant latency improvement, but it paves the way to start using WQ_RT which is queued for 7.5. At that point we can switch to using it with a single line patch and bring submission latencies under CPU load back to what they were in the past. Signed-off-by: Tvrtko Ursulin References: a6149f039369 ("drm/sched: Convert drm scheduler to use a work queue rather than kthread") References: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/49 References: https://lore.kernel.org/dri-devel/20261104095225.32654-1-tvrtko.ursulin@igalia.com/ References: https://lore.kernel.org/dri-devel/5582fb8a609eb8a2348811ecb6f539a7@kernel.org/ Cc: Alex Deucher Cc: Christian König Cc: Timur Kristóf --- v2: * Free the workqueue if it has been allocated. --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 4 files changed, 15 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index d0b08d2daea2..7638e4230307 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2367,6 +2367,7 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) args.credit_limit = ring->num_hw_submission; args.score = ring->sched_score; args.name = ring->name; + args.submit_wq = ring->sched_wq; r = drm_sched_init(&ring->sched, &args); if (r) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 3c85db006b6b..31af04522068 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -601,6 +601,9 @@ void amdgpu_fence_driver_fini_ring(struct amdgpu_ring *ring) if (ring->sched.ops) drm_sched_fini(&ring->sched); + if (ring->sched_wq) + destroy_workqueue(ring->sched_wq); + for (i = 0; i <= ring->fence_drv.num_fences_mask; ++i) dma_fence_put(ring->fence_drv.fences[i]); kfree(ring->fence_drv.fences); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index aacad6c823e7..3083126d56ce 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c @@ -360,6 +360,16 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, if (!ring->no_scheduler && ring->funcs->type < AMDGPU_HW_IP_NUM) { struct amdgpu_sched *gpu_sched = &adev->gpu_sched[ring->funcs->type][hw_prio]; + unsigned int flags = WQ_MEM_RECLAIM; + + if (hw_prio > AMDGPU_RING_PRIO_DEFAULT) + flags |= WQ_HIGHPRI; + + ring->sched_wq = alloc_ordered_workqueue(ring->name, flags); + if (!ring->sched_wq) { + r = -ENOMEM; + goto err; + } gpu_sched->sched[gpu_sched->num_scheds++] = &ring->sched; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index 9e9565b0e286..6eed8e63d513 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h @@ -309,6 +309,7 @@ struct amdgpu_ring { struct amdgpu_fence_driver fence_drv; struct drm_gpu_scheduler sched; + struct workqueue_struct *sched_wq; struct amdgpu_bo *ring_obj; uint32_t *ring; /* backups for resets */ -- 2.56.0