diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2023-08-29 13:03:31 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2024-03-27 19:49:23 +0100 |
commit | f8c5bdd86478a852c8d3967630dd81fdd70fa030 (patch) | |
tree | 868c30988bd44ee8e8be487ad2dd22f23e3cc46b /linux/LinuxProcessTable.c | |
parent | ec608672cea2b857a7b43832bfabae2bbe6c04da (diff) |
Linux: add GPU meter and process column
Based on the DRM client usage stats[1] add statistics for GPU time spend
and percentage utilization.
[1]: https://www.kernel.org/doc/html/latest/gpu/drm-usage-stats.html
Diffstat (limited to 'linux/LinuxProcessTable.c')
-rw-r--r-- | linux/LinuxProcessTable.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/linux/LinuxProcessTable.c b/linux/LinuxProcessTable.c index 82cfdab3..84308423 100644 --- a/linux/LinuxProcessTable.c +++ b/linux/LinuxProcessTable.c @@ -49,6 +49,8 @@ in the source distribution for its full text. #include "UsersTable.h" #include "XUtils.h" #include "linux/CGroupUtils.h" +#include "linux/GPU.h" +#include "linux/GPUMeter.h" #include "linux/LinuxMachine.h" #include "linux/LinuxProcess.h" #include "linux/Platform.h" // needed for GNU/hurd to get PATH_MAX // IWYU pragma: keep @@ -1617,6 +1619,14 @@ static bool LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_ar } #endif + if (ss->flags & PROCESS_FLAG_LINUX_GPU || GPUMeter_active()) { + if (parent) { + lp->gpu_time = ((const LinuxProcess*)parent)->gpu_time; + } else { + GPU_readProcessData(this, lp, procFd); + } + } + if (!proc->cmdline && statCommand[0] && (proc->state == ZOMBIE || Process_isKernelThread(proc) || settings->showThreadNames)) { Process_updateCmdline(proc, statCommand, 0, strlen(statCommand)); @@ -1674,9 +1684,9 @@ errorReadingProcess: void ProcessTable_goThroughEntries(ProcessTable* super) { LinuxProcessTable* this = (LinuxProcessTable*) super; - const Machine* host = super->super.host; + Machine* host = super->super.host; const Settings* settings = host->settings; - const LinuxMachine* lhost = (const LinuxMachine*) host; + LinuxMachine* lhost = (LinuxMachine*) host; if (settings->ss->flags & PROCESS_FLAG_LINUX_AUTOGROUP) { // Refer to sched(7) 'autogroup feature' section @@ -1688,6 +1698,17 @@ void ProcessTable_goThroughEntries(ProcessTable* super) { this->haveAutogroup = false; } + /* Shift GPU values */ + { + lhost->prevGpuTime = lhost->curGpuTime; + lhost->curGpuTime = 0; + + for (GPUEngineData* engine = lhost->gpuEngineData; engine; engine = engine->next) { + engine->prevTime = engine->curTime; + engine->curTime = 0; + } + } + /* PROCDIR is an absolute path */ assert(PROCDIR[0] == '/'); #ifdef HAVE_OPENAT |