From aff1f7713ca8f3836e1b76611b3222628f9c2b84 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Sep 26 2012 19:09:36 +0000 Subject: sanlock: configurable mlockall level -l 0 -> no mlockall -l 1 -> mlockall(CURRENT) -l 2 -> mlockall(CURRENT|FUTURE) The default is now set to 1 (was 2). CURRENT|FUTURE results in each pthread_create using 8MB of RSS for the thread stack. CURRENT alone does not. Signed-off-by: David Teigland --- diff --git a/src/main.c b/src/main.c index dea78f7..9645e3e 100644 --- a/src/main.c +++ b/src/main.c @@ -1249,16 +1249,21 @@ static void sigterm_handler(int sig GNUC_UNUSED) static void setup_priority(void) { struct sched_param sched_param; - int rv; + int rv = 0; - if (!com.high_priority) - return; + if (com.mlock_level == 1) + rv = mlockall(MCL_CURRENT); + else if (com.mlock_level == 2) + rv = mlockall(MCL_CURRENT | MCL_FUTURE); - rv = mlockall(MCL_CURRENT | MCL_FUTURE); if (rv < 0) { - log_error("mlockall failed: %s", strerror(errno)); + log_error("mlockall %d failed: %s", + com.mlock_level, strerror(errno)); } + if (!com.high_priority) + return; + rv = sched_get_priority_max(SCHED_RR); if (rv < 0) { log_error("could not get max scheduler priority err %d", errno); @@ -1956,6 +1961,9 @@ static int read_command_line(int argc, char *argv[]) case 'h': com.high_priority = atoi(optionarg); break; + case 'l': + com.mlock_level = atoi(optionarg); + break; case 'o': if (com.action == ACT_STATUS) { com.sort_arg = *optionarg; @@ -2386,6 +2394,7 @@ int main(int argc, char *argv[]) memset(&com, 0, sizeof(com)); com.use_watchdog = DEFAULT_USE_WATCHDOG; com.high_priority = DEFAULT_HIGH_PRIORITY; + com.mlock_level = DEFAULT_MLOCK_LEVEL; com.max_worker_threads = DEFAULT_MAX_WORKER_THREADS; com.io_timeout_arg = DEFAULT_IO_TIMEOUT; com.aio_arg = DEFAULT_USE_AIO; diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h index 2c67fc8..53e5866 100644 --- a/src/sanlock_internal.h +++ b/src/sanlock_internal.h @@ -239,6 +239,7 @@ EXTERN struct client *client; #define DEFAULT_GRACE_SEC 40 #define DEFAULT_USE_WATCHDOG 1 #define DEFAULT_HIGH_PRIORITY 1 +#define DEFAULT_MLOCK_LEVEL 1 /* 1=CURRENT, 2=CURRENT|FUTURE */ #define DEFAULT_SOCKET_UID 0 #define DEFAULT_SOCKET_GID 0 #define DEFAULT_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) @@ -254,6 +255,7 @@ struct command_line { int quiet_fail; int use_watchdog; int high_priority; + int mlock_level; int max_worker_threads; int aio_arg; int io_timeout_arg;