summaryrefslogtreecommitdiffstats
path: root/linux/Platform.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2021-08-06 16:45:30 +1000
committerBenBE <BenBE@geshi.org>2021-08-09 07:56:13 +0200
commit1bd95983b2703cb313ea301367ff3199fabd1f9d (patch)
treede70612626231c6f522ddf1a43ef36ec041fbb48 /linux/Platform.c
parentaa0424ade806715ea0f410dc068a1eb648300bb9 (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 'linux/Platform.c')
-rw-r--r--linux/Platform.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/linux/Platform.c b/linux/Platform.c
index d23bf57d..64be93c7 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -150,8 +150,38 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) {
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
+static bool Platform_changeAutogroupPriority(MainPanel* panel, int delta) {
+ if (LinuxProcess_isAutogroupEnabled() == false) {
+ beep();
+ return false;
+ }
+ bool anyTagged;
+ bool ok = MainPanel_foreachProcess(panel, LinuxProcess_changeAutogroupPriorityBy, (Arg) { .i = delta }, &anyTagged);
+ if (!ok)
+ beep();
+ return anyTagged;
+}
+
+static Htop_Reaction Platform_actionHigherAutogroupPriority(State* st) {
+ if (Settings_isReadonly())
+ return HTOP_OK;
+
+ bool changed = Platform_changeAutogroupPriority(st->mainPanel, -1);
+ return changed ? HTOP_REFRESH : HTOP_OK;
+}
+
+static Htop_Reaction Platform_actionLowerAutogroupPriority(State* st) {
+ if (Settings_isReadonly())
+ return HTOP_OK;
+
+ bool changed = Platform_changeAutogroupPriority(st->mainPanel, 1);
+ return changed ? HTOP_REFRESH : HTOP_OK;
+}
+
void Platform_setBindings(Htop_Action* keys) {
keys['i'] = Platform_actionSetIOPriority;
+ keys['{'] = Platform_actionLowerAutogroupPriority;
+ keys['}'] = Platform_actionHigherAutogroupPriority;
}
const MeterClass* const Platform_meterTypes[] = {

© 2014-2024 Faster IT GmbH | imprint | privacy policy