diff --git a/nohang b/nohang index a7a1ec3..cba3cac 100755 --- a/nohang +++ b/nohang @@ -13,13 +13,13 @@ from sre_constants import error as invalid_re start_time = time() -help_mess = """usage: nohang [-h] [-v] [-t] [--ppt] [-c CONFIG] +help_mess = """usage: nohang [-h] [-v] [-t] [-p] [-c CONFIG] optional arguments: -h, --help show this help message and exit -v, --version print version -t, --test print some tests - --ppt, --print-proc-table + -p, --print-proc-table print table of processes with their badness values -c CONFIG, --config CONFIG path to the config file, default values: @@ -1628,7 +1628,7 @@ elif len(argv) == 2: print_version() elif argv[1] == '--test' or argv[1] == '-t': test() - elif argv[1] == '--print-proc-table' or argv[1] == '--ppt': + elif argv[1] == '--print-proc-table' or argv[1] == '-p': print_proc_table_flag = True if os.path.exists('./nohang.conf'): config = os.getcwd() + '/nohang.conf' diff --git a/nohang.1 b/nohang.1 index e17401e..bda7e00 100644 --- a/nohang.1 +++ b/nohang.1 @@ -40,7 +40,7 @@ Nohang is a highly configurable daemon for Linux which is able to correctly prev -t, --test print some tests - --ppt, --print-proc-table + -p, --print-proc-table print table of processes with their badness values -c CONFIG, --config CONFIG diff --git a/misc/FAQ.ru.md b/trash/FAQ.ru.md similarity index 100% rename from misc/FAQ.ru.md rename to trash/FAQ.ru.md diff --git a/misc/isascii b/trash/isascii similarity index 100% rename from misc/isascii rename to trash/isascii diff --git a/misc/memco.py b/trash/memco.py similarity index 100% rename from misc/memco.py rename to trash/memco.py diff --git a/misc/mm b/trash/mm similarity index 100% rename from misc/mm rename to trash/mm diff --git a/misc/new5.conf b/trash/new5.conf similarity index 100% rename from misc/new5.conf rename to trash/new5.conf diff --git a/misc/nonascii-nohang.conf b/trash/nonascii-nohang.conf similarity index 100% rename from misc/nonascii-nohang.conf rename to trash/nonascii-nohang.conf diff --git a/misc/oom-trigger b/trash/oom-trigger similarity index 89% rename from misc/oom-trigger rename to trash/oom-trigger index 2f2959e..39db963 100755 --- a/misc/oom-trigger +++ b/trash/oom-trigger @@ -3,6 +3,40 @@ # интерактивный oom-trigger + +from ctypes import CDLL + + + + +def mlockall(): + """Lock all memory to prevent swapping nohang process.""" + + MCL_CURRENT = 1 + MCL_FUTURE = 2 + MCL_ONFAULT = 4 + + libc = CDLL('libc.so.6', use_errno=True) + + result = libc.mlockall( + MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT + ) + if result != 0: + result = libc.mlockall( + MCL_CURRENT | MCL_FUTURE + ) + if result != 0: + log('Cannot lock all memory') + else: + log('All memory locked with MCL_CURRENT | MCL_FUTURE') + else: + log('All memory locked with MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT') + + +mlockall() + + + from memco import * # печать показателей на этапах работы @@ -105,7 +139,7 @@ def lim2avail(): 'Вы ввели не целое положительное число' ) return 0 - + if n == 0: print( 'Вы ввели не целое положительное число' diff --git a/misc/proc2log b/trash/proc2log similarity index 100% rename from misc/proc2log rename to trash/proc2log diff --git a/misc/psi-monitor b/trash/psi-monitor similarity index 100% rename from misc/psi-monitor rename to trash/psi-monitor diff --git a/misc/psi_dummy b/trash/psi_dummy similarity index 100% rename from misc/psi_dummy rename to trash/psi_dummy diff --git a/misc/random-trigger b/trash/random-trigger similarity index 100% rename from misc/random-trigger rename to trash/random-trigger diff --git a/misc/zram-off b/trash/zram-off similarity index 100% rename from misc/zram-off rename to trash/zram-off diff --git a/misc/zram-on b/trash/zram-on similarity index 100% rename from misc/zram-on rename to trash/zram-on