Repository navigation
Conversation
Processes without any DRM engine time are only rescanned every 5 seconds. When such a process starts using the GPU, the whole busy time accumulated since the last scan was divided by a single refresh interval, so the first GPU% sample was inflated by up to 5s/delay (a process keeping the engine 50% busy showed up as 147% with a 1s delay). Divide by the time elapsed since the scan that produced lp->gpu_time instead. Assisted-by: Claude Opus 5.5 Signed-off-by: Artsem Lebiadzevich <artyomlebedevich@gmail.com>
|
No actionable comments were generated in the recent review.
|
ravi-arnan
left a comment
There was a problem hiding this comment.
Nice catch on the DRM fdinfo rescan timing.
Reviewed the diff in linux/GPU.c:
- Math & timing verification: When an idle process is throttled behind
lp->gpu_activityMs != 0 && host->monotonicMs - lp->gpu_activityMs < 5000, the subsequent non-zeronew_gpu_timeindeed represents accumulated work over the entire scan interval (~5s), not the single refresh delta(host->monotonicMs - host->prevMonotonicMs). Dividing by(lastScanMs ? lastScanMs : host->prevMonotonicMs)properly normalizes the utilization over the real measurement window. - Transition back to active: Because
lp->gpu_activityMsis reset to0at line 224 when active, subsequent consecutive refreshes correctly evaluatelastScanMs == 0and fall back tohost->prevMonotonicMs, keeping real-time reporting accurate. - Div-by-zero safety:
host->monotonicMs - lastScanMs >= 5000is guaranteed by the earlier guard at line 88, somonotonicTimeDeltaremains strictly positive whenlastScanMs != 0. - Build verification: Compiled cleanly under Linux GCC with htop's full strict warning set (
-Wall -Wextra -Wcast-align -Wshadow -Wnull-dereferenceetc.) with 0 warnings.
LGTM.
|
@BenBE @natoscott gentle ping: could one of you take a look when you have time? It fixes inflated per-process GPU usage after the fdinfo rescan throttling. |
Processes with no DRM engine time are only rescanned every 5 seconds (
gpu_activityMs). When such a process starts using the GPU,GPU_readProcessData()takes the busy time accumulated since that last scan but divides it by one refresh interval (monotonicMs - prevMonotonicMs), so the first GPU% value is inflated by up to 5s/delay.The fix remembers when the previous scan happened and divides by the time since then. For processes that were scanned on the previous refresh nothing changes.
Tested on Linux (Debian trixie container) with htop built
--with-proc=/fakeproc: a fake PID whosefdinfohas an i915 client withdrm-engine-renderat 0 ns, which after ~2 s starts growing at 50% of wall time,-d 10, columns PID / GPU% / GPU_TIME, screen read withtmux capture-paneevery second:(29.2% is the average over the 5 s since the previous scan, 1.47 s busy.)