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 B5F8A606A31A for ; Tue, 1 Dec 2026 17:31:50 +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=rluxRWr/ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51AF210FB59; Tue, 1 Dec 2026 17:31:45 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC0FE10FB63 for ; Tue, 1 Dec 2026 17:31:36 +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=ksNOKFHPP+xJ7vRYnMZYY3FQVmUykB6rtVtOOt+iyTk=; t=1796146296; x=2111506296; b=rluxRWr/DJmJFTFZeiDjJBJHS0RJpOqbAT0KdAMUDAckef4ff/pJ1RdWcVt//ysE8QneZcFec2p gKYdZLgj9+FQfF1v+3gYAKQJrs8clDSMJnAzYm+bSJTe4A5nKhac14LRpo6f91hktfNzmfUqKDPjx qGZYxxsXggeXdeKCvcUVf79TNLA/On8PVpz2KzVo/qPuTeSsBJKFi40SaMiu8egv4oHtwBBnL4WEK kDwze7y1Mqx+pzm163oBz7Mg3HKIc83d+fA+Cm7l6T6m6kpRjmCvYdXUjUrBSOqxZmBP12AOOh4Wh O0I8w3DxPht916TTh821j0g58jwkNcOwcMOw==; 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) (envelope-from ) id 1xYRhX-00000000ljQ-1YJX; Tue, 01 Dec 2026 18:31:35 +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 v4 4/4] drm/amdgpu: Use high priority scheduler workqueue for high priority rings Date: Tue, 1 Dec 2026 17:31:31 +0000 Message-ID: <20261201173131.79944-5-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261201173131.79944-1-tvrtko.ursulin@igalia.com> References: <20261201173131.79944-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. v3: * Prevent double destroy_workqueue. --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 4 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 499ed9a3ba23..9b007ba6c05c 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 c58d7c72eb30..52a15ac0fc0b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -602,6 +602,11 @@ void amdgpu_fence_driver_fini_ring(struct amdgpu_ring *ring) ring->fence_drv.fences = NULL; } + if (ring->sched_wq) { + destroy_workqueue(ring->sched_wq); + ring->sched_wq = NULL; + } + ring->fence_drv.initialized = false; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 692ed3bc3fbf..a1d8d59d5aa9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c @@ -357,6 +357,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 cc91fe05ceaa..1f2c48623033 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