From 31a9194a8b33e6c57989c79f231da48dcf14e918 Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Fri, 23 Nov 2018 03:16:27 +0900 Subject: [PATCH] small fixes --- Makefile | 2 +- nohang | 16 ++++++++-------- nohang.conf | 10 ++++++---- default_values_backup.conf => nohang.conf.backup | 6 +++--- nohang.service | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) rename default_values_backup.conf => nohang.conf.backup (97%) diff --git a/Makefile b/Makefile index 3e5ef62..05a2b66 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ install: install -d $(DESTDIR)/$(PREFIX)/etc/nohang install -m0644 ./nohang.conf $(DESTDIR)/$(PREFIX)/etc/nohang - install -m0644 ./default_values_backup.conf $(DESTDIR)/$(PREFIX)/etc/nohang + install -m0644 ./nohang.conf.backup $(DESTDIR)/$(PREFIX)/etc/nohang install -d $(DESTDIR)/$(PREFIX)/usr/share/man/man1 gzip -k -c nohang.1 > $(DESTDIR)/$(PREFIX)/usr/share/man/man1/nohang.1.gz diff --git a/nohang b/nohang index 77bc0a3..0eba8f6 100755 --- a/nohang +++ b/nohang @@ -1427,8 +1427,8 @@ while True: if mem_available <= mem_min_sigkill_kb and swap_free <= swap_min_sigkill_kb: time0 = time() - mem_info = 'Low memory; corrective action required!\n MemAvailable ({} MiB, {} %) < mem_min_sigkill ({} MiB, {} %)\n Swa' \ - 'pFree ({} MiB, {} %) < swap_min_sigkill ({} MiB, {} %)'.format( + mem_info = 'Low memory; corrective action required!\n MemAvailable [{} MiB, {} %] <= mem_min_sigkill [{} MiB, {} %]\n Swa' \ + 'pFree [{} MiB, {} %] <= swap_min_sigkill [{} MiB, {} %]'.format( kib_to_mib(mem_available), percent(mem_available / mem_total), @@ -1447,7 +1447,7 @@ while True: elif mem_used_zram >= zram_max_sigkill_kb: time0 = time() - mem_info = 'Low memory; corrective action required!\n MemUsedZram ({} MiB, {} %) > zram_max_sigkill ({} MiB, {} %)'.format( + mem_info = 'Low memory; corrective action required!\n MemUsedZram [{} MiB, {} %] >= zram_max_sigkill [{} MiB, {} %]'.format( kib_to_mib(mem_used_zram), percent(mem_used_zram / mem_total), kib_to_mib(zram_max_sigkill_kb), @@ -1460,8 +1460,8 @@ while True: time0 = time() - mem_info = 'Low memory; corrective action required!\n MemAvailable ({} MiB, {} %) < mem_min_sigterm ({} MiB, {} %)\n Sw' \ - 'apFree ({} MiB, {} %) < swap_min_sigterm ({} MiB, {} %)'.format( + mem_info = 'Low memory; corrective action required!\n MemAvailable [{} MiB, {} %] <= mem_min_sigterm [{} MiB, {} %]\n Sw' \ + 'apFree [{} MiB, {} %] <= swap_min_sigterm [{} MiB, {} %]'.format( kib_to_mib(mem_available), percent(mem_available / mem_total), @@ -1485,8 +1485,8 @@ while True: elif mem_used_zram >= zram_max_sigterm_kb: time0 = time() - mem_info = 'Low memory; corrective action required!\n MemUsedZram ({} MiB, {} %) > zram_max_sigter' \ - 'm ({} M, {} %)'.format( + mem_info = 'Low memory; corrective action required!\n MemUsedZram [{} MiB, {} %] >= zram_max_sigter' \ + 'm [{} M, {} %]'.format( kib_to_mib(mem_used_zram), percent(mem_used_zram / mem_total), kib_to_mib(zram_max_sigterm_kb), @@ -1497,7 +1497,7 @@ while True: # LOW MEMORY WARNINGS elif gui_low_memory_warnings: - if mem_available < mem_min_warnings_kb and swap_free < swap_min_warnings_kb + 0.1 or mem_used_zram > zram_max_warnings_kb: + if mem_available <= mem_min_warnings_kb and swap_free <= swap_min_warnings_kb + 0.1 or mem_used_zram >= zram_max_warnings_kb: warn_time_delta = time() - warn_time_now warn_time_now = time() warn_timer += warn_time_delta diff --git a/nohang.conf b/nohang.conf index ee9e5fc..09514d9 100644 --- a/nohang.conf +++ b/nohang.conf @@ -26,7 +26,7 @@ 1. Thresholds below which a signal should be sent to the victim - Sets the available memory levels below which SIGTERM or SIGKILL + Sets the available memory levels at or below which SIGTERM or SIGKILL signals are sent. The signal will be sent if MemAvailable and SwapFree (in /proc/meminfo) at the same time will drop below the corresponding values. Can be specified in % (percent) and M (MiB). @@ -77,6 +77,8 @@ rate_mem = 6 rate_swap = 3 rate_zram = 1 + See also https://github.com/rfjakob/earlyoom/issues/61 + ##################################################################### 3. The prevention of killing innocent victims @@ -250,18 +252,18 @@ mlockall = False Valid values are integers from the range [-20; 19]. -niceness = -15 +niceness = -9 Set oom_score_adj for the nohang process. Valid values are integers from the range [-1000; 1000]. Setting the values to -1000 will prohibit suicide. -oom_score_adj = -100 +oom_score_adj = -50 Read `man ionice` to understand the following parameters. Setting the True value requires the root privileges. -realtime_ionice = True +realtime_ionice = False 'For realtime and best-effort, 0-7 are valid data (priority levels), and 0 represents the highest priority level.' diff --git a/default_values_backup.conf b/nohang.conf.backup similarity index 97% rename from default_values_backup.conf rename to nohang.conf.backup index 57395bf..03cb68c 100644 --- a/default_values_backup.conf +++ b/nohang.conf.backup @@ -68,9 +68,9 @@ zram_max_warnings = 40 % 7. Preventing the slowing down of the program mlockall = False -niceness = -15 -oom_score_adj = -100 -realtime_ionice = True +niceness = -9 +oom_score_adj = -50 +realtime_ionice = False realtime_ionice_classdata = 4 ##################################################################### diff --git a/nohang.service b/nohang.service index 9e9c4d4..5358add 100644 --- a/nohang.service +++ b/nohang.service @@ -1,5 +1,5 @@ [Unit] -Description=No hang daemon +Description=Highly configurable out of memory preventer After=sysinit.target Documentation=man:nohang(1) https://github.com/hakavlad/nohang