fix psi support
This commit is contained in:
parent
97c153247f
commit
aa7ad46aed
38
nohang
38
nohang
@ -27,6 +27,12 @@ wait_time = 2
|
||||
cache_time = 30
|
||||
cache_path = '/dev/shm/nohang_env_cache'
|
||||
|
||||
|
||||
psi_support = os.path.exists('/proc/pressure/memory')
|
||||
|
||||
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
||||
|
||||
@ -34,10 +40,14 @@ cache_path = '/dev/shm/nohang_env_cache'
|
||||
|
||||
|
||||
def psi_mem_some_avg_total():
|
||||
if os.path.exists('/proc/pressure/memory'):
|
||||
if psi_support:
|
||||
return float(rline1('/proc/pressure/memory').rpartition('=')[2])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def check_mem():
|
||||
"""find mem_available"""
|
||||
return int(rline1('/proc/meminfo').split(':')[1].strip(' kB\n'))
|
||||
@ -1518,7 +1528,6 @@ stdout.flush()
|
||||
|
||||
|
||||
|
||||
psi_support = os.path.exists('/proc/pressure/memory')
|
||||
|
||||
|
||||
|
||||
@ -1536,6 +1545,9 @@ avg_min_time = 3
|
||||
sigterm_psi = 60
|
||||
sigkill_psi = 80
|
||||
|
||||
|
||||
#print(psi_support)
|
||||
|
||||
if psi_support:
|
||||
ta0 = time()
|
||||
a0 = psi_mem_some_avg_total()
|
||||
@ -1547,15 +1559,23 @@ while True:
|
||||
if psi_support:
|
||||
|
||||
ta1= time()
|
||||
dt = ta1 - ta0
|
||||
#print(dt)
|
||||
if dt < avg_min_time:
|
||||
pass
|
||||
|
||||
#a0 = a1 + (psi_mem_some_avg_total() - a0)
|
||||
|
||||
else:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
a1 = psi_mem_some_avg_total()
|
||||
avg = (a1 - a0) / (ta1 - ta0) / 100
|
||||
a0 = a1
|
||||
|
||||
print('PSI mem avg:', round(avg, 2))
|
||||
|
||||
|
||||
|
||||
|
||||
if avg >= sigkill_psi:
|
||||
time0 = time()
|
||||
mem_info = 'avg > sigkill_avg'
|
||||
@ -1567,6 +1587,10 @@ while True:
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
ta0 = ta1
|
||||
|
||||
|
||||
mem_available, swap_total, swap_free = check_mem_and_swap()
|
||||
|
||||
# if swap_min_sigkill is set in percent
|
||||
|
Loading…
Reference in New Issue
Block a user