This commit is contained in:
Alexey Avramov 2019-04-20 01:49:09 +09:00
parent 67d9c3295e
commit e93bfd35fe
2 changed files with 61 additions and 32 deletions

64
nohang
View File

@ -1794,6 +1794,8 @@ print('Config:', config)
config_dict = dict() config_dict = dict()
processname_re_list = [] processname_re_list = []
cmdline_re_list = [] cmdline_re_list = []
environ_re_list = [] environ_re_list = []
uid_re_list = [] uid_re_list = []
@ -1915,6 +1917,52 @@ except FileNotFoundError:
exit(1) exit(1)
if processname_re_list == []:
regex_matching = False
else:
regex_matching = True
if cmdline_re_list == []:
re_match_cmdline = False
else:
re_match_cmdline = True
if uid_re_list == []:
re_match_uid = False
else:
re_match_uid = True
if environ_re_list == []:
re_match_environ = False
else:
re_match_environ = True
if realpath_re_list == []:
re_match_realpath = False
else:
re_match_realpath = True
if cgroup_v1_re_list == []:
re_match_cgroup_v1 = False
else:
re_match_cgroup_v1 = True
if cgroup_v2_re_list == []:
re_match_cgroup_v2 = False
else:
re_match_cgroup_v2 = True
# print(processname_re_list) # print(processname_re_list)
# print(cmdline_re_list) # print(cmdline_re_list)
# print(uid_re_list) # print(uid_re_list)
@ -1943,13 +1991,15 @@ gui_notifications = conf_parse_bool('gui_notifications')
decrease_oom_score_adj = conf_parse_bool('decrease_oom_score_adj') decrease_oom_score_adj = conf_parse_bool('decrease_oom_score_adj')
execute_the_command = conf_parse_bool('execute_the_command') execute_the_command = conf_parse_bool('execute_the_command')
ignore_psi = conf_parse_bool('ignore_psi') ignore_psi = conf_parse_bool('ignore_psi')
regex_matching = conf_parse_bool('regex_matching')
re_match_cmdline = conf_parse_bool('re_match_cmdline')
re_match_uid = conf_parse_bool('re_match_uid') # regex_matching = conf_parse_bool('regex_matching')
re_match_cgroup_v1 = conf_parse_bool('re_match_cgroup_v1') # re_match_cmdline = conf_parse_bool('re_match_cmdline')
re_match_cgroup_v2 = conf_parse_bool('re_match_cgroup_v2') # re_match_uid = conf_parse_bool('re_match_uid')
re_match_realpath = conf_parse_bool('re_match_realpath') # re_match_cgroup_v1 = conf_parse_bool('re_match_cgroup_v1')
re_match_environ = conf_parse_bool('re_match_environ') # re_match_cgroup_v2 = conf_parse_bool('re_match_cgroup_v2')
# re_match_realpath = conf_parse_bool('re_match_realpath')
# re_match_environ = conf_parse_bool('re_match_environ')
# if regex_matching or re_match_cmdline or re_match_uid or re_match_cgroup # if regex_matching or re_match_cmdline or re_match_uid or re_match_cgroup

View File

@ -11,11 +11,12 @@
4. The prevention of killing innocent victims 4. The prevention of killing innocent victims
5. Impact on the badness of processes via matching their 5. Impact on the badness of processes via matching their
- names, - names,
- cgroups,
- cmdlines and - cmdlines and
- UIDs - UIDs
with regular expressions with regular expressions
6. The execution of a specific command instead of sending the 6. Customize corrective actions: the execution of a specific command
SIGTERM signal instead of sending the SIGTERM signal
7. GUI notifications: 7. GUI notifications:
- OOM prevention results and - OOM prevention results and
- low memory warnings - low memory warnings
@ -173,10 +174,6 @@ oom_score_adj_max = 20
5.1 Matching process names with RE patterns 5.1 Matching process names with RE patterns
Valid values are True and False.
regex_matching = False
Syntax: Syntax:
@PROCESSNAME_RE badness_adj /// RE_pattern @PROCESSNAME_RE badness_adj /// RE_pattern
@ -188,60 +185,42 @@ regex_matching = False
Example: Example:
@PROCESSNAME_RE -100 /// ^Xorg$ @PROCESSNAME_RE 1000 /// ^Xorg$
@PROCESSNAME_RE -500 /// ^sshd$ @PROCESSNAME_RE -500 /// ^sshd$
5.2 Matching cmdlines with RE patterns 5.2 Matching cmdlines with RE patterns
A good option that allows fine adjustment. A good option that allows fine adjustment.
re_match_cmdline = False
@CMDLINE_RE 300 /// -childID|--type=renderer @CMDLINE_RE 300 /// -childID|--type=renderer
@CMDLINE_RE -200 /// ^/usr/lib/virtualbox @CMDLINE_RE -200 /// ^/usr/lib/virtualbox
5.3 Matching UIDs with RE patterns 5.3 Matching UIDs with RE patterns
The most slow option The most slow option
re_match_uid = False
@UID_RE -100 /// ^0$ @UID_RE -100 /// ^0$
5.4 Matching CGroup-line with RE patterns 5.4 Matching CGroup-line with RE patterns
re_match_cgroup_v1 = False
@CGROUP_V1_RE -50 /// ^/system.slice @CGROUP_V1_RE -50 /// ^/system.slice
@CGROUP_V1_RE 50 /// foo.service @CGROUP_V1_RE 50 /// foo.service
@CGROUP_V1_RE -50 /// ^/user.slice @CGROUP_V1_RE -50 /// ^/user.slice
re_match_cgroup_v2 = False
@CGROUP_V2_RE 100 /// ^/workload @CGROUP_V2_RE 100 /// ^/workload
5.5 Matching realpath with RE patterns 5.5 Matching realpath with RE patterns
re_match_realpath = False
@REALPATH_RE 20 /// ^/usr/bin/foo @REALPATH_RE 20 /// ^/usr/bin/foo
5.6 Matching environ with RE patterns 5.6 Matching environ with RE patterns
re_match_environ = False
@ENVIRON_RE 100 /// USER=user @ENVIRON_RE 100 /// USER=user
Note that you can control badness also via systemd units via OOMScoreAdjust, see Note that you can control badness also via systemd units via OOMScoreAdjust, see
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#OOMScoreAdjust= https://www.freedesktop.org/software/systemd/man/systemd.exec.html#OOMScoreAdjust=