mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 20:24:35 +03:00
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
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user