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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E4EF3C55172 for ; Tue, 4 Aug 2026 10:19:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EFCDC10E671; Tue, 4 Aug 2026 10:19:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="m5jQx+FS"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id D145B10E671 for ; Tue, 4 Aug 2026 10:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:From:Reply-To; bh=UxWTUmWK4iBD/ChCAecu2Tlv0cbJ+ERCz/+/ZIEzh7Y=; b= m5jQx+FShULl8zpgCl8BBVfFfvSkclWTDYsz6yfRG9mhOgUf6OPTOutZgFrzXmgPnjXxl0s5KBzWs HT4Jr/1HTn2oCqJw9Src4y4oGzKEDc9VOLUt4wzPJ0MQwnquBJS9Oa/fVKtxSZDoGR2ukIEV3H7nG 04ZbFLKuYcKVFe/6PTeBElXDi+FLSDWosTliOKtiyXsQMyO82DbN+qKEcoiIPIFxoLQEIFnnI0ByQ a66Zpg5cAr8yemWPkHcwfQT+14BVTCAASQjONwf5LHkUdXZ9UEhoDhpo9eizRkDQ51u2PFbUhDBpk IpWPsUr0eFnCX7qFMNF9OrW3NhTvuefNew==; Received: from [90.248.143.204] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wrCF6-00DlqL-7G; Tue, 04 Aug 2026 12:19:28 +0200 From: Tvrtko Ursulin To: dri-devel@lists.freedesktop.org Cc: Boris Brezillon , Steven Price , Liviu Dudau , Chia-I Wu , Matthew Brost , kernel-dev@igalia.com, linux-kernel@vger.kernel.org, Tvrtko Ursulin , Chia-I Wu , Tejun Heo Subject: [RFC v4 0/2] Realtime workqueues and panthor realtime submission Date: Tue, 4 Aug 2026 11:19:23 +0100 Message-ID: <20260804101925.55414-1-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This is a continuation of the previous discussion which was here: https://lore.kernel.org/dri-devel/20260702143745.79293-1-tvrtko.ursulin@igalia.com/ Work is now converted to a much simpler approach by adding real-time scheduling workqueues based on Tejun's feedback To re-cap, when an userspace thread submits GPU work, due how the DRM scheduler uses workqueues to feed the GPU, and regardless of the GPU rendering context priority, or the CPU scheduling priority of the userspace thread itself, the use of workqueues can add significant latency to the submit path. When CPU is busy with enough backround load this translates to severe latency spikes measured as time between userspace submitting work and GPU actually being given that work to execute. With the panthor workqueue upgraded to use WQ_HIGHPRI and varying the CPU priority of the submit thread, the test program from https://gitlab.freedesktop.org/panfrost/linux/-/work_items/49 reproduces these kind of latencies: . N RT M 27 28 32 95% 163 246 809 98% 924 991 1882 Legend: M = Median submit latency in us 95% = Percentile latency in us . = Userspace submit thread SCHED_OTHER N = -||= nice -1 RT = -||- FIFO 1 Upgrading the panthor workqueues so that the realtime GPU priority queue uses WQ_RTPRI, submit latency becomes completely controlled with the median of 14us and 95 and 98-th percentiles at 23us and 25us respectively. Important to note is that VK_QUEUE_GLOBAL_PRIORITY_REALTIME already required the userspace to have CAP_SYS_NICE, meaning access to real-time workqueues is effectively also guared behind this capability. v2: * See patch 1 changelog. v3: * See patch 1 changelog + apologies for v3 following so quickly after v2. I have found a race condition as I expanded the testing to a second platform. v4: * See patch 1 changelog. Cc: Boris Brezillon Cc: Chia-I Wu Cc: Liviu Dudau Cc: Matthew Brost Cc: Steven Price Cc: Tejun Heo Tvrtko Ursulin (2): workqueue: Add support for real-time workers drm/panthor: Create per queue priority workqueues Documentation/core-api/workqueue.rst | 5 ++ drivers/gpu/drm/panthor/panthor_sched.c | 38 ++++++++++-- include/linux/workqueue.h | 23 +++++-- kernel/workqueue.c | 80 +++++++++++++++++++------ 4 files changed, 119 insertions(+), 27 deletions(-) -- 2.54.0