Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: LGPL-2.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include "util/debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include "util/rlimit.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <sys/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <sys/resource.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * Bump the memlock so that we can get bpf maps of a reasonable size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * like the ones used with 'perf trace' and with 'perf test bpf',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  * improve this to some specific request if needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) void rlimit__bump_memlock(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	struct rlimit rlim;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	if (getrlimit(RLIMIT_MEMLOCK, &rlim) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		rlim.rlim_cur *= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 		rlim.rlim_max *= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 			rlim.rlim_cur /= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 			rlim.rlim_max /= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 			if (setrlimit(RLIMIT_MEMLOCK, &rlim) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 				pr_debug("Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }