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 B225B606A329 for ; Mon, 30 Nov 2026 16:10:58 +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=J957dxLx Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34D0210E92E; Mon, 30 Nov 2026 16:10:53 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 541EB10F21B for ; Mon, 30 Nov 2026 16:10:41 +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=m38QllilylqvL0Xv1Xh6N4AEaXe25geV6sZ9Rl3wiek=; t=1796055041; x=2111415041; b=J957dxLxdUl+1VLJCCg7KmVbIavlG4uRb41UvE0Yia7k5uhstz1Ho+OscBw42+49ju+cA/wipgG L2DP7i+ImggzQZeKrHQ33PvJ6DGiKzv3ZzQY23iQJcGZhWQttd88MrRBwgjCxanYMQU1mTwQEDMOF 5FglRZkAcFsqw75vDPXFWKtAu7Fvzu+4WhYTnY20q2raz7Sr5T3yKvdoa7yekvFX/qQdXSHW2ga4s NY689GtHyR6K/U0/bqI2mqofMWIDElkhcOk6+5My6gobBljdEE5s1xVUSvHjr/OTTszMneUTDik36 V6j1vlJz5hXzGkQxYT/wK5Z6kXyZpFso5yiQ==; 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 1xY3xf-00000000Div-3mi7; Mon, 30 Nov 2026 17:10:39 +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 4/4] drm/amdgpu: Use high priority scheduler workqueue for high priority rings Date: Mon, 30 Nov 2026 16:10:16 +0000 Message-ID: <20261130161016.64542-5-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261130161016.64542-1-tvrtko.ursulin@igalia.com> References: <20261130161016.64542-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 --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) 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 58219aa04013..318826a16803 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c @@ -593,8 +593,10 @@ void amdgpu_fence_driver_sw_fini(struct amdgpu_device *adev) * The natural check would be sched.ready, which is * set as drm_sched_init() finishes... */ - if (ring->sched.ops) + if (ring->sched.ops) { drm_sched_fini(&ring->sched); + destroy_workqueue(ring->sched_wq); + } for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) dma_fence_put(ring->fence_drv.fences[j]); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index 2a96cb7d891b..3fb4b5340ef5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c @@ -352,6 +352,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 b2040f80b7f2..d2424b53af4e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h @@ -306,6 +306,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