nohang/nohang/nohang-desktop.conf
2020-02-15 12:39:08 +09:00

532 lines
12 KiB
Plaintext

This is nohang's config file.
Lines starting with #, tabs and spaces are comments.
Lines starting with @ contain optional parameters.
All values are case sensitive.
Be careful: nohang does not forbid you to shoot yourself in the foot.
The configuration includes the following sections:
1. Common zram settings
2. Common PSI settings
3. Poll rate
4. Warnings and notifications
5. Soft threshold
6. Hard threshold
7. Customize victim selection: adjusting badness of processes
8. Customize soft corrective actions
9. Misc settings
10. Verbosity, debug, logging
Just read the description of the parameters and edit the values.
Please restart the program after editing the config.
TODO: improve descriptions
###############################################################################
1. Common zram settings
Key: zram_checking_enabled
Description:
Type: boolean
Valid values: True and False
Default value: False
zram_checking_enabled = False
###############################################################################
2. Common PSI settings
Description:
Type: boolean
Valid values: True and False
psi_checking_enabled = True
Description:
Type: string
Valid values:
psi_path = /proc/pressure/memory
Description:
Type: string
Valid values:
psi_metrics = some_avg10
Description:
Type: float
Valid values:
psi_excess_duration = 40
Description:
Type: float
Valid values:
psi_post_action_delay = 20
###############################################################################
3. Poll rate
Description:
Type: float
Valid values:
fill_rate_mem = 4000
Description:
Type: float
Valid values:
fill_rate_swap = 1500
Description:
Type: float
Valid values:
fill_rate_zram = 4000
Description:
Type: float
Valid values:
max_sleep = 3
Description:
Type: float
Valid values:
min_sleep = 0.1
Description:
Type: float
Valid values:
over_sleep = 0.05
###############################################################################
4. Warnings and notifications
4.1. GUI notifications after corrective actions
Description:
Type: boolean
Valid values: True and False
post_action_gui_notifications = True
Description:
Type: boolean
Valid values: True and False
hide_corrective_action_type = False
4.2. Low memory warnings
Description:
Type: boolean
Valid values: True and False
low_memory_warnings_enabled = True
Description:
Type: string
Valid values:
warning_exe =
Description:
Type: float (+ % or M)
Valid values:
warning_threshold_min_mem = 20 %
Description:
Type: float (+ % or M)
Valid values:
warning_threshold_min_swap = 25 %
Description:
Type: float (+ % or M)
Valid values:
warning_threshold_max_zram = 50 %
Description:
Type: float
Valid values:
warning_threshold_max_psi = 20
Description:
Type: float
Valid values:
min_post_warning_delay = 60
Description:
Type: float
Valid values:
env_cache_time = 300
###############################################################################
5. Soft threshold
Description:
Type: float (+ % or M)
Valid values:
soft_threshold_min_mem = 6 %
Description:
Type: float (+ % or M)
Valid values:
soft_threshold_min_swap = 9 %
Description:
Type: float (+ % or M)
Valid values:
soft_threshold_max_zram = 60 %
Description:
Type: float
Valid values:
soft_threshold_max_psi = 40
###############################################################################
6. Hard threshold
hard_threshold_min_mem = 2 %
Description:
Type: float (+ % or M)
Valid values:
hard_threshold_min_swap = 3 %
Description:
Type: float (+ % or M)
Valid values:
hard_threshold_max_zram = 65 %
Description:
Type: float
Valid values:
hard_threshold_max_psi = 90
###############################################################################
7. Customize victim selection: adjusting badness of processes
7.1. Ignore positive oom_score_adj
Description:
Type: boolean
Valid values: True and False
ignore_positive_oom_score_adj = False
7.2. Forbid negative badness
Description:
Type: boolean
Valid values: True and False
forbid_negative_badness = True
7.3.1. Matching process names with RE patterns change their badness
Syntax:
@BADNESS_ADJ_RE_NAME badness_adj /// RE_pattern
New badness value will be += badness_adj
It is possible to compare multiple patterns
with different badness_adj values.
Example:
@BADNESS_ADJ_RE_NAME -500 /// ^sshd$
Prefer terminating Firefox tabs instead of terminating the entire browser.
(In Chromium and Electron-based apps child processes get oom_score_adj=300
by default.)
@BADNESS_ADJ_RE_NAME 200 /// ^Web Content$
7.3.2. Matching CGroup_v1-line with RE patterns
@BADNESS_ADJ_RE_CGROUP_V1 -50 /// ^/system\.slice/
@BADNESS_ADJ_RE_CGROUP_V1 50 /// /foo\.service$
@BADNESS_ADJ_RE_CGROUP_V1 -50 /// ^/user\.slice/
7.3.3. Matching CGroup_v2-line with RE patterns
@BADNESS_ADJ_RE_CGROUP_V2 100 /// ^/workload
7.3.4. Matching eUIDs with RE patterns
@BADNESS_ADJ_RE_UID -100 /// ^0$
7.3.5. Matching /proc/[pid]/exe realpath with RE patterns
Example:
@BADNESS_ADJ_RE_REALPATH 20 /// ^/usr/bin/foo$
Protect X.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/libexec/Xorg|/usr/lib/xorg/Xorg|/usr/lib/Xorg|/usr/bin/X|/usr/bin/Xwayland|/usr/bin/weston|/usr/bin/sway)$
Protect GNOME.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/gnome-shell|/usr/bin/metacity|/usr/bin/mutter|/usr/lib/gnome-session/gnome-session-binary|/usr/libexec/gnome-session-binary|/usr/libexec/gnome-session-ctl)$
Protect KDE Plasma.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/plasma-desktop|/usr/bin/plasmashell|/usr/bin/plasma_session|/usr/bin/kwin|/usr/bin/kwin_x11|/usr/bin/kwin_wayland)$
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/startplasma-wayland|/usr/lib/x86_64-linux-gnu/libexec/startplasma-waylandsession|/usr/bin/ksmserver)$
Protect Cinnamon.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/cinnamon|/usr/bin/muffin|/usr/bin/cinnamon-session|/usr/bin/cinnamon-launcher)$
Protect Xfce.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/xfwm4|/usr/bin/xfce4-session|/usr/bin/xfce4-panel|/usr/bin/xfdesktop)$
Protect Mate.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/marco|/usr/bin/mate-session|/usr/bin/caja|/usr/bin/mate-panel)$
Protect LXQt.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/lxqt-panel|/usr/bin/pcmanfm-qt|/usr/bin/lxqt-session)$
Protect Budgie Desktop.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/budgie-wm|/usr/bin/budgie-panel)$
Protect other.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/compiz|/usr/bin/openbox|/usr/bin/fluxbox|/usr/bin/awesome|/usr/bin/icewm|/usr/bin/enlightenment|/usr/bin/gala|/usr/bin/wingpanel)$
Protect display managers.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/sbin/gdm|/usr/sbin/gdm3|/usr/sbin/sddm|/usr/bin/sddm|/usr/lib/x86_64-linux-gnu/sddm/sddm-helper|/usr/bin/slim|/usr/sbin/lightdm|/usr/libexec/gdm-session-worker|/usr/libexec/gdm-wayland-session|/usr/lib/gdm3/gdm-wayland-session|/usr/lib/gdm3/gdm-session-worker)$
@BADNESS_ADJ_RE_REALPATH -200 /// ^/usr/lib/gdm3/
Protect systemd-logind.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/lib/systemd/systemd-logind|/usr/lib/systemd/systemd-logind)$
Protect `systemd --user`.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/lib/systemd/systemd|/usr/lib/systemd/systemd)$
Protect dbus.
@BADNESS_ADJ_RE_REALPATH -200 /// ^(/usr/bin/dbus-daemon|/usr/bin/dbus-run-session)$
Prefer stress.
@BADNESS_ADJ_RE_REALPATH 900 /// ^(/usr/bin/stress|/usr/bin/stress-ng)$
7.3.6. Matching cwd with RE patterns
@BADNESS_ADJ_RE_CWD 200 /// ^/home/
7.3.7. Matching cmdlines with RE patterns
WARNING: using this option can greatly slow down the search for a victim
in conditions of heavily swapping.
Prefer Chromium tabs and Electron-based apps
@BADNESS_ADJ_RE_CMDLINE 200 /// --type=renderer
Prefer Firefox tabs (Web Content and WebExtensions)
@BADNESS_ADJ_RE_CMDLINE 100 /// -appomni
@BADNESS_ADJ_RE_CMDLINE -200 /// ^/usr/lib/virtualbox
7.3.8. Matching environ with RE patterns
WARNING: using this option can greatly slow down the search for a victim
in conditions of heavily swapping.
@BADNESS_ADJ_RE_ENVIRON 100 /// USER=user
Note that you can control badness also via systemd units via
OOMScoreAdjust, see
www.freedesktop.org/software/systemd/man/systemd.exec.html#OOMScoreAdjust=
###############################################################################
8. Customize soft corrective actions
TODO: docs
Syntax:
KEY REGEXP SEPARATOR COMMAND
@SOFT_ACTION_RE_NAME ^foo$ /// kill -KILL $PID
@SOFT_ACTION_RE_NAME ^bash$ /// kill -9 $PID
@SOFT_ACTION_RE_CGROUP_V1 ^/system\.slice/ /// systemctl restart $SERVICE
@SOFT_ACTION_RE_CGROUP_V1 /foo\.service$ /// systemctl restart $SERVICE
@SOFT_ACTION_RE_NAME ^tail$ /// kill -TERM $PID
$PID will be replaced by process PID.
$NAME will be replaced by process name.
$SERVICE will be replaced by .service if it exists (overwise it will be
relpaced by empty line)
###############################################################################
9. Misc settings
Description:
Type: float
Valid values:
max_soft_exit_time = 10
Description:
Type: string
Valid values:
post_kill_exe =
Description:
Type: integer
Valid values:
min_badness = 5
Description:
Type: float
Valid values:
post_soft_action_delay = 3
Description:
Type: float
Valid values:
post_zombie_delay = 0.1
Description:
Type: float
Valid values:
victim_cache_time = 10
Description:
Type: float
Valid values:
exe_timeout = 20
###############################################################################
10. Verbosity, debug, logging
Description:
Type: boolean
Valid values: True and False
print_config_at_startup = False
Description:
Type: boolean
Valid values: True and False
print_mem_check_results = False
Description:
Type: float
Valid values:
min_mem_report_interval = 60
Description:
Type: boolean
Valid values: True and False
print_proc_table = False
Description:
WARNING: using "cmdline" or "environ" keys can greatly slow down
the search for a victim in conditions of heavily swapping.
Type: string
Valid values:
None
cgroup_v1
cgroup_v2
realpath
cwd
cmdline
environ
extra_table_info = None
Description:
Type: boolean
Valid values: True and False
print_victim_status = True
Description:
Type: boolean
Valid values: True and False
print_victim_cmdline = False
Description:
Type: integer
Valid values:
max_victim_ancestry_depth = 3
Description:
Type: boolean
Valid values: True and False
print_statistics = True
Description:
Type: boolean
Valid values: True and False
debug_psi = False
Description:
Type: boolean
Valid values: True and False
debug_gui_notifications = False
Description:
Type: boolean
Valid values: True and False
debug_sleep = False
Description:
Type: boolean
Valid values: True and False
debug_threading = False
Description:
Type: boolean
Valid values: True and False
separate_log = False
###############################################################################
Use cases, feature requests and any questions are welcome:
https://github.com/hakavlad/nohang/issues