fix readme
This commit is contained in:
parent
a1e7b25ad0
commit
24c928aea2
10
README.md
10
README.md
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
Nohang is a highly configurable daemon for Linux which is able to correctly prevent [out of memory](https://en.wikipedia.org/wiki/Out_of_memory) (OOM) and keep system responsiveness in low memory conditions.
|
Nohang is a highly configurable daemon for Linux which is able to correctly prevent [out of memory](https://en.wikipedia.org/wiki/Out_of_memory) (OOM) and keep system responsiveness in low memory conditions.
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## What is the problem?
|
## What is the problem?
|
||||||
|
|
||||||
OOM conditions may cause [freezes](https://en.wikipedia.org/wiki/Hang_(computing)), [livelocks](https://en.wikipedia.org/wiki/Deadlock#Livelock), drop [caches](https://en.wikipedia.org/wiki/Page_cache) and processes to be killed (via sending [SIGKILL](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL)) instead of trying to terminate them correctly (via sending [SIGTERM](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGTERM) or takes other corrective action). Some applications may crash if it's impossible to allocate memory.
|
OOM conditions may cause [freezes](https://en.wikipedia.org/wiki/Hang_(computing)), [livelocks](https://en.wikipedia.org/wiki/Deadlock#Livelock), drop [caches](https://en.wikipedia.org/wiki/Page_cache) and processes to be killed (via sending [SIGKILL](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL)) instead of trying to terminate them correctly (via sending [SIGTERM](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGTERM) or takes other corrective action). Some applications may crash if it's impossible to allocate memory.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
Here are the statements of some users:
|
Here are the statements of some users:
|
||||||
|
|
||||||
> "How do I prevent Linux from freezing when out of memory?
|
> "How do I prevent Linux from freezing when out of memory?
|
||||||
@ -27,7 +27,10 @@ Also look at [Why are low memory conditions handled so badly?](https://www.reddi
|
|||||||
|
|
||||||
- Use of [earlyoom](https://github.com/rfjakob/earlyoom). This is a simple and very lightweight OOM preventer written in C (the best choice for emedded and old servers). It has a minimum dependencies and can work with oldest kernels.
|
- Use of [earlyoom](https://github.com/rfjakob/earlyoom). This is a simple and very lightweight OOM preventer written in C (the best choice for emedded and old servers). It has a minimum dependencies and can work with oldest kernels.
|
||||||
- Use of [oomd](https://github.com/facebookincubator/oomd). This is a userspace OOM killer for linux systems whitten in C++ and developed by Facebook. Needs Linux 4.20+.
|
- Use of [oomd](https://github.com/facebookincubator/oomd). This is a userspace OOM killer for linux systems whitten in C++ and developed by Facebook. Needs Linux 4.20+.
|
||||||
- Use of nohang (maybe this is a good choice for modern desktops and servers if you need fine tuning).
|
- Use of `nohang` (maybe this is a good choice for modern desktops and servers if you need fine tuning).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
The tools listed above may work at the same time on one computer.
|
The tools listed above may work at the same time on one computer.
|
||||||
|
|
||||||
@ -211,6 +214,7 @@ Please create [issues](https://github.com/hakavlad/nohang/issues). Use cases, fe
|
|||||||
- Add the ability to send any signal instead of SIGTERM for processes with certain names
|
- Add the ability to send any signal instead of SIGTERM for processes with certain names
|
||||||
- Handle `UnicodeDecodeError` if victim name consists of many unicode characters
|
- Handle `UnicodeDecodeError` if victim name consists of many unicode characters
|
||||||
- Improve user input validation
|
- Improve user input validation
|
||||||
|
- Fix `mlockall()` using `MCL_ONFAULT` and lock all memory by default
|
||||||
|
|
||||||
- [v0.1](https://github.com/hakavlad/nohang/releases/tag/v0.1), 2018-11-23
|
- [v0.1](https://github.com/hakavlad/nohang/releases/tag/v0.1), 2018-11-23
|
||||||
- 1st release
|
- 1st release
|
||||||
|
11
nohang
11
nohang
@ -427,7 +427,7 @@ def send_notify_etc(pid, name, command):
|
|||||||
pid: str process pid
|
pid: str process pid
|
||||||
"""
|
"""
|
||||||
title = 'Hang prevention'
|
title = 'Hang prevention'
|
||||||
body = 'Victim is process <b>{}</b> [{}]\nExecute the command:\n<b>{}</b>'.format(
|
body = 'Victim is process <b>{}</b>, {}\nExecute the command:\n<b>{}</b>'.format(
|
||||||
name.replace('&', '*'),
|
name.replace('&', '*'),
|
||||||
pid,
|
pid,
|
||||||
command.replace('&', '*')
|
command.replace('&', '*')
|
||||||
@ -691,8 +691,12 @@ def find_victim_and_send_signal(signal):
|
|||||||
|
|
||||||
len_vm = len(str(vm_size))
|
len_vm = len(str(vm_size))
|
||||||
|
|
||||||
|
try:
|
||||||
realpath = os.path.realpath('/proc/' + pid + '/exe')
|
realpath = os.path.realpath('/proc/' + pid + '/exe')
|
||||||
|
except FileNotFoundError:
|
||||||
|
print('Victim died: /proc/{}/exe does not exists'.format(pid))
|
||||||
|
|
||||||
|
|
||||||
state = pid_to_state(pid)
|
state = pid_to_state(pid)
|
||||||
pname = pid_to_name(ppid.strip('\n '))
|
pname = pid_to_name(ppid.strip('\n '))
|
||||||
# print([ppid], [pname])
|
# print([ppid], [pname])
|
||||||
@ -737,7 +741,6 @@ def find_victim_and_send_signal(signal):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
|
||||||
# нахер такое ветвление
|
# нахер такое ветвление
|
||||||
|
|
||||||
victim_info = '\033[4mFound a process with highest badness:\033[0m' \
|
victim_info = '\033[4mFound a process with highest badness:\033[0m' \
|
||||||
@ -958,11 +961,13 @@ def calculate_percent(arg_key):
|
|||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
# Lock all memory
|
||||||
|
|
||||||
|
|
||||||
mlockall()
|
mlockall()
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
# find mem_total
|
# find mem_total
|
||||||
|
Loading…
Reference in New Issue
Block a user