infra: additional global mem limit

This commit is contained in:
Thomas Schoebel-Theuer 2019-06-25 07:42:20 +02:00
parent 5be66cacb2
commit c922bafa52
3 changed files with 9 additions and 1 deletions

View File

@ -613,7 +613,7 @@ static LIST_HEAD(rot_anchor);
// TUNING
int mars_mem_percent = 20;
EXPORT_SYMBOL_GPL(mars_mem_percent);
int mars_mem_gb = 16;
#define CONF_TRANS_SHADOW_LIMIT (1024 * 128) // don't fill the hashtable too much
@ -5657,12 +5657,18 @@ static int _main_thread(void *data)
mars_mem_percent = 0;
if (mars_mem_percent > 70)
mars_mem_percent = 70;
if (mars_mem_gb < 1)
mars_mem_gb = 1;
memlimit = (long long)brick_global_memavail * mars_mem_percent / 100;
if (memlimit > (long long)mars_mem_gb * 1024 * 1024)
memlimit = (long long)mars_mem_gb * 1024 * 1024;
/* Dynamic memlimit when /mars is becoming full */
if (memlimit > global_remaining_space / 4)
memlimit = global_remaining_space / 4;
if (memlimit < 4)
memlimit = 4;
brick_global_memlimit = memlimit;
brick_msleep(100);

View File

@ -349,6 +349,7 @@ struct ctl_table mars_table[] = {
INT_ENTRY("logger_resume", trans_logger_resume, 0600),
INT_ENTRY("logger_replay_timeout_sec", trans_logger_replay_timeout, 0600),
INT_ENTRY("mem_limit_percent", mars_mem_percent, 0600),
INT_ENTRY("mem_limit_gb", mars_mem_gb, 0600),
INT_ENTRY("logger_mem_used_kb", trans_logger_mem_usage, 0400),
INT_ENTRY("mem_used_raw_kb", brick_global_block_used,0400),
#ifdef CONFIG_MARS_MEM_PREALLOC

View File

@ -223,6 +223,7 @@ extern int mars_max_loadavg;
#endif
extern int mars_mem_percent;
extern int mars_mem_gb;
extern int main_checker(struct mars_dent *parent, const char *_name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel);