0001
0002
0003 #include "util/debug.h"
0004 #include "util/rlimit.h"
0005 #include <sys/time.h>
0006 #include <sys/resource.h>
0007
0008
0009
0010
0011
0012
0013 void rlimit__bump_memlock(void)
0014 {
0015 struct rlimit rlim;
0016
0017 if (getrlimit(RLIMIT_MEMLOCK, &rlim) == 0) {
0018 rlim.rlim_cur *= 4;
0019 rlim.rlim_max *= 4;
0020
0021 if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0) {
0022 rlim.rlim_cur /= 2;
0023 rlim.rlim_max /= 2;
0024
0025 if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0)
0026 pr_debug("Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc\n");
0027 }
0028 }
0029 }