From 3bab1878663ed31b13fe4063f66fd1584da3a90e Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Thu, 14 May 2020 16:27:39 +0300 Subject: [PATCH] lock all current and future pages from preventing of being paged and tune malloc --- nocache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nocache.c b/nocache.c index 84fd0e1..b5d27e1 100644 --- a/nocache.c +++ b/nocache.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -113,6 +114,10 @@ static void init(void) if(max_fds == 0) return; /* There's nothing to do for us here. */ + mlockall(MCL_CURRENT | MCL_FUTURE); + mallopt(M_TRIM_THRESHOLD, -1); + mallopt(M_MMAP_MAX, 0); + init_mutexes(); /* make sure to re-initialize mutex if forked */ pthread_atfork(NULL, NULL, init_mutexes); @@ -212,6 +217,7 @@ static void destroy(void) free(fds_lock); fds_lock = NULL; pthread_mutex_unlock(&fds_iter_lock); + munlockall(); } int open(const char *pathname, int flags, mode_t mode)