Skip to content

Commit

Permalink
fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
hakavlad committed Sep 11, 2020
1 parent 49ce205 commit 0b2f54a
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions prelockd
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ def get_self_rss():

###############################################################################

MIB = 1024 * 1024

min_mem_available = 20 * 1024

saved_dir = '/var/lib/prelockd'
saved_path = '/var/lib/prelockd/saved_snapshot'
Expand Down Expand Up @@ -361,6 +364,7 @@ with open('/proc/meminfo') as f:
mem_list = f.readlines()
mem_total = int(mem_list[0].split(':')[1][:-4])


mem_list_names = []

for s in mem_list:
Expand Down Expand Up @@ -460,7 +464,7 @@ if '$MAX_SELF_RSS_PERCENT' in config_dict:
if max_self_rss_percent is None:
errprint('invalid $MAX_SELF_RSS_PERCENT value')
exit(1)
max_self_rss = int(mem_total * max_self_rss_percent / 100) * 1024
max_self_rss_pc = int(mem_total * max_self_rss_percent / 100) * 1024
else:
errprint('missing $MAX_FILE_SIZE_MIB key')
exit(1)
Expand All @@ -472,24 +476,33 @@ if '$MAX_SELF_RSS_MIB' in config_dict:
if max_self_rss_mib is None:
errprint('invalid $MAX_SELF_RSS_MIB value')
exit(1)
max_self_rss2 = int(max_file_size_mib * 1048576)
max_self_rss_mib = int(max_self_rss_mib * 1048576)
else:
errprint('missing $MAX_SELF_RSS_MIB key')
exit(1)


if max_self_rss2 > max_self_rss:
max_self_rss = max_self_rss2
if max_self_rss_mib <= max_self_rss_pc:
max_self_rss = max_self_rss_mib
else:
max_self_rss = max_self_rss_pc


config = os.path.abspath(config)

print('Starting prelockd with the config: {}'.format(config))

if debug:
print('$MAX_SELF_RSS_PERCENT:', round(max_self_rss_pc / MIB, 1), '(MiB)')
print('$MAX_SELF_RSS_MIB: ', round(max_self_rss_mib / MIB, 1))
print('max_self_rss: ', round(max_self_rss / MIB, 1), '(MiB)')
print('$DEBUG: ', debug)
print('$LOCK_CURRENT_MAPPED: ', lock_current_mapped)
print('$LOCK_SAVED_MAPPED: ', lock_saved_mapped)
print('$MAX_FILE_SIZE_MIB: ', max_file_size / MIB)
print('$LOCK_RE: ', lock_re)

MIB = 1024 * 1024

min_mem_available = 20 * 1024
print('Starting prelockd with the config: {}'.format(config))


r = lock_re
Expand Down

0 comments on commit 0b2f54a

Please sign in to comment.