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/LinuxProcess.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/LinuxProcess.c')
-rw-r--r-- | linux/LinuxProcess.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 2b42d8c8..5d145fff 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -109,6 +109,8 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { #ifdef SCHEDULER_SUPPORT [SCHEDULERPOLICY] = { .name = "SCHEDULERPOLICY", .title = "SCHED ", .description = "Current scheduling policy of the process", .flags = PROCESS_FLAG_SCHEDPOL, }, #endif + [GPU_TIME] = { .name = "GPU_TIME", .title = " GPU_TIME", .description = "Total GPU time in nano seconds", .flags = PROCESS_FLAG_LINUX_GPU, .defaultSortDesc = true, .autoWidth = true, .autoTitleRightAlign = true, }, + [GPU_PERCENT] = { .name = "GPU_PERCENT", .title = "GPU% ", .description = "Percentage of the GPU time the process used in the last sampling", .flags = PROCESS_FLAG_LINUX_GPU, .defaultSortDesc = true, }, }; Process* LinuxProcess_new(const Machine* host) { @@ -239,6 +241,8 @@ static void LinuxProcess_rowWriteField(const Row* super, RichString* str, Proces switch (field) { case CMINFLT: Row_printCount(str, lp->cminflt, coloring); return; case CMAJFLT: Row_printCount(str, lp->cmajflt, coloring); return; + case GPU_PERCENT: Row_printPercentage(lp->gpu_percent, buffer, n, 5, &attr); break; + case GPU_TIME: Row_printTime(str, lp->gpu_time / 1000 / 1000 / 10 /* nano to centi seconds */, coloring); return; case M_DRS: Row_printBytes(str, lp->m_drs * lhost->pageSize, coloring); return; case M_LRS: if (lp->m_lrs) { @@ -422,6 +426,15 @@ static int LinuxProcess_compareByKey(const Process* v1, const Process* v2, Proce return SPACESHIP_NUMBER(p1->autogroup_id, p2->autogroup_id); case AUTOGROUP_NICE: return SPACESHIP_NUMBER(p1->autogroup_nice, p2->autogroup_nice); + case GPU_PERCENT: { + int r = compareRealNumbers(p1->gpu_percent, p2->gpu_percent); + if (r) + return r; + + return SPACESHIP_NUMBER(p1->gpu_time, p2->gpu_time); + } + case GPU_TIME: + return SPACESHIP_NUMBER(p1->gpu_time, p2->gpu_time); default: return Process_compareByKey_Base(v1, v2, key); } |