Linux 6.4 Preparing DRM Deadline Hints To Help Influence GPU Frequency/Performance

Written by Michael Larabel in Linux Kernel on 26 March 2023 at 07:10 AM EDT. 7 Comments
LINUX KERNEL
Rob Clark on Saturday sent out a pull request adding the DMA-BUF/DMA-FENCE deadline awareness code to the Direct Rendering Manager (DRM) subsystem with the upcoming Linux 6.4 cycle.

This pull request provides the core infrastructure for allowing a "deadline" hint for use by the DRM graphics/display drivers. This pull request doesn't implement the deadline support for any of the DRM drivers but at least now allows for drivers to do so in their own pull requests.

This deadline awareness support is a hint for fences so that real-time deadlines like vblanks can be communicated to the fence signaler for enhancing power/frequency management decisions. This deadline awareness support was inspired in part by handling currently done by Intel's kernel graphics driver.

DMA-Fence Deadline Awareness


When implemented by the DRM drivers, the hope is that with these deadline hints the GPUs will boost their clock frequency / power state if needed as to not miss the deadlines. A code comment with the new DRM deadline hints goes on to explain:
In an ideal world, it would be possible to pipeline a workload sufficiently that a utilization based device frequency governor could arrive at a minimum frequency that meets the requirements of the use-case, in order to minimize power consumption. But in the real world there are many workloads which defy this ideal. For example, but not limited to:

Workloads that ping-pong between device and CPU, with alternating periods of CPU waiting for device, and device waiting on CPU. This can result in devfreq and cpufreq seeing idle time in their respective domains and in result reduce frequency.

Workloads that interact with a periodic time based deadline, such as double buffered GPU rendering vs vblank sync'd page flipping. In this scenario, missing a vblank deadline results in an *increase* in idle time on the GPU (since it has to wait an additional vblank period), sending a signal to the GPU's devfreq to reduce frequency, when in fact the opposite is what is needed.

To this end, deadline hint(s) can be set on a &dma_fence via &dma_fence_set_deadline. The deadline hint provides a way for the waiting driver, or userspace, to convey an appropriate sense of urgency to the signaling driver.

A deadline hint is given in absolute ktime (CLOCK_MONOTONIC for userspace facing APIs). The time could either be some point in the future (such as the vblank based deadline for page-flipping, or the start of a compositor's composition cycle), or the current time to indicate an immediate deadline hint (Ie. forward progress cannot be made until this fence is signaled).

Multiple deadlines may be set on a given fence, even in parallel. See the documentation for &dma_fence_ops.set_deadline.

The deadline hint is just that, a hint. The driver that created the fence may react by increasing frequency, making different scheduling choices, etc. Or doing nothing at all.

The core code around the DRM DMA-BUF/DMA-FENCE deadline awareness can be found via this pull request. Patches have already been floated for implementing the deadline hint handling within the likes of the Intel and Freedreno drivers so it's possible they too could be ready for the Linux 6.4 cycle kicking off in about one month.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week