From 9d888e794ad8ca67275e56e1f9fc6a7fba68e8ff Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Thu, 12 Jul 2018 03:21:53 +0900 Subject: [PATCH] print reaction time if victim got signal --- README.md | 28 +++++++++++++++++++++++----- nohang | 9 ++++++++- nohang.conf | 4 ++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 57c34f9..2d37e5a 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,29 @@ OOM killer doesn't prevent OOM conditions. ### An example of output ``` - MemAvailable (0 MiB, 0.0 %) < mem_min_sigterm (588 MiB, 10.0 %) - SwapFree (943 MiB, 8.8 %) < swap_min_sigterm (1076 MiB, 10.0 %) - Preventing OOM: trying to send the SIGTERM signal to tail, - Pid: 14636, Badness: 777, VmRSS: 4446 MiB, VmSwap: 8510 MiB - Success +MemAvail: 2515 M, 42.8 % +MemAvail: 1510 M, 25.7 % +MemAvail: 909 M, 15.5 % +MemAvail: 520 M, 8.9 % +* MemAvailable (520 MiB, 8.9 %) < mem_min_sigterm (529 MiB, 9.0 %) + SwapFree (0 MiB, 0.0 %) < swap_min_sigterm (0 MiB, - %) + Preventing OOM: trying to send the SIGTERM signal to stress, + Pid: 9828, Badness: 82, VmRSS: 485 MiB, VmSwap: 0 MiB + Success; reaction time: 11 ms +MemAvail: 4114 M, 70.0 % +MemAvail: 2532 M, 43.1 % +MemAvail: 1495 M, 25.4 % +MemAvail: 927 M, 15.8 % +MemAvail: 553 M, 9.4 % +MemAvail: 342 M, 5.8 % +* MemAvailable (342 MiB, 5.8 %) < mem_min_sigkill (353 MiB, 6.0 %) + SwapFree (0 MiB, 0.0 %) < swap_min_sigkill (0 MiB, - %) + Preventing OOM: trying to send the SIGKILL signal to stress, + Pid: 9841, Badness: 87, VmRSS: 513 MiB, VmSwap: 0 MiB + Success; reaction time: 11 ms +MemAvail: 4084 M, 69.5 % +MemAvail: 2543 M, 43.3 % +MemAvail: 1535 M, 26.1 % ``` ### Requirements diff --git a/nohang b/nohang index 5e0fa40..ecb1dc2 100755 --- a/nohang +++ b/nohang @@ -229,6 +229,8 @@ def sleep_after_send_signal(signal): def find_victim_and_send_signal(signal): + time0 = time() + print(mem_info) # выставляем потолок для oom_score_adj всех процессов @@ -326,7 +328,9 @@ def find_victim_and_send_signal(signal): try: os.kill(int(pid), signal) - send_result = ' Success' + success_time = time() + delta_success = success_time - time0 + send_result = ' Success; reaction time: {} ms'.format(round(delta_success * 1000)) if desktop_notifications: send_notify(signal, name, pid, oom_score, vm_rss, vm_swap) @@ -1247,6 +1251,7 @@ while True: break + # если swap_min_sigkill задан в процентах if swap_kill_is_percent: swap_min_sigkill_kb = swap_total * swap_min_sigkill_percent / 100.0 @@ -1396,8 +1401,10 @@ while True: warn_timer = 0 sleep_after_check_mem() + # SLEEP BETWEEN MEM CHECKS else: + sleep_after_check_mem() diff --git a/nohang.conf b/nohang.conf index 3ccd46e..50abe46 100644 --- a/nohang.conf +++ b/nohang.conf @@ -68,8 +68,8 @@ zram_max_sigkill = 60 % Valid values are positive floating-point numbers. -rate_mem = 4 -rate_swap = 2 +rate_mem = 6 +rate_swap = 3 rate_zram = 1 #####################################################################