diff options
author | Nathan Scott <nathans@redhat.com> | 2021-08-06 16:45:30 +1000 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-08-09 07:56:13 +0200 |
commit | 1bd95983b2703cb313ea301367ff3199fabd1f9d (patch) | |
tree | de70612626231c6f522ddf1a43ef36ec041fbb48 /pcp/PCPProcessList.c | |
parent | aa0424ade806715ea0f410dc068a1eb648300bb9 (diff) |
Add columns for process autogroup identifier and nice value
Adds AGRP (autogroup) and ANI (autogroup nice) columns that
report the information from /proc/PID/autogroup, as well as
handlers for '{' and '}' to change the autogroup nice value.
This is guarded by /proc/sys/kernel/sched_autogroup_enabled
such that sampling and/or changing values wont be attempted
unless the kernel feature is enabled.
Fixes: #720
Diffstat (limited to 'pcp/PCPProcessList.c')
-rw-r--r-- | pcp/PCPProcessList.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pcp/PCPProcessList.c b/pcp/PCPProcessList.c index ae974435..b0fe7666 100644 --- a/pcp/PCPProcessList.c +++ b/pcp/PCPProcessList.c @@ -89,13 +89,20 @@ void ProcessList_delete(ProcessList* pl) { free(this); } -static inline unsigned long Metric_instance_s32(int metric, int pid, int offset, unsigned long fallback) { +static inline long Metric_instance_s32(int metric, int pid, int offset, long fallback) { pmAtomValue value; if (Metric_instance(metric, pid, offset, &value, PM_TYPE_32)) return value.l; return fallback; } +static inline long long Metric_instance_s64(int metric, int pid, int offset, long long fallback) { + pmAtomValue value; + if (Metric_instance(metric, pid, offset, &value, PM_TYPE_64)) + return value.l; + return fallback; +} + static inline unsigned long Metric_instance_u32(int metric, int pid, int offset, unsigned long fallback) { pmAtomValue value; if (Metric_instance(metric, pid, offset, &value, PM_TYPE_U32)) @@ -222,6 +229,11 @@ static void PCPProcessList_readOomData(PCPProcess* pp, int pid, int offset) { pp->oom = Metric_instance_u32(PCP_PROC_OOMSCORE, pid, offset, 0); } +static void PCPProcessList_readAutogroup(PCPProcess* pp, int pid, int offset) { + pp->autogroup_id = Metric_instance_s64(PCP_PROC_AUTOGROUP_ID, pid, offset, -1); + pp->autogroup_nice = Metric_instance_s32(PCP_PROC_AUTOGROUP_NICE, pid, offset, 0); +} + static void PCPProcessList_readCtxtData(PCPProcess* pp, int pid, int offset) { pmAtomValue value; unsigned long ctxt = 0; @@ -403,6 +415,9 @@ static bool PCPProcessList_updateProcesses(PCPProcessList* this, double period, if (settings->flags & PROCESS_FLAG_CWD) PCPProcessList_readCwd(pp, pid, offset); + if (settings->flags & PROCESS_FLAG_LINUX_AUTOGROUP) + PCPProcessList_readAutogroup(pp, pid, offset); + if (proc->state == 'Z' && !proc->cmdline && command[0]) { Process_updateCmdline(proc, command, 0, strlen(command)); } else if (Process_isThread(proc)) { @@ -651,6 +666,9 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { Metric_enable(PCP_PROC_NVCTXSW, flagged && enabled); flagged = settings->flags & PROCESS_FLAG_LINUX_SECATTR; Metric_enable(PCP_PROC_LABELS, flagged && enabled); + flagged = settings->flags & PROCESS_FLAG_LINUX_AUTOGROUP; + Metric_enable(PCP_PROC_AUTOGROUP_ID, flagged && enabled); + Metric_enable(PCP_PROC_AUTOGROUP_NICE, flagged && enabled); /* Sample smaps metrics on every second pass to improve performance */ static int smaps_flag; |