summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeill Kapron <nkapron@google.com>2024-04-09 17:04:25 +0000
committerNeill Kapron <nkapron@google.com>2024-04-09 17:22:02 +0000
commitbc4ae410ff7253c3c1afe99863c576c17a3758c3 (patch)
treecdf70f503e9c1ac9c7242fd1fc3eee6c8d253f50
parentfebb949db406f62d443bed25952ad5f87a7f7e9d (diff)
downloadbpf-bc4ae410ff7253c3c1afe99863c576c17a3758c3.tar.gz
BpfLoadTest: Set rlimit memlock for old kernels
BpfLoadTest was failing on android13-5.10 kernels due to the rlimit memlock not being configured large enough for the test process. Add the necessary call to set rlimit memlock for pre-5.11 kernels. 5.11 kernels introduced cgroup-based memory accounting for bpf as discussed at https://lore.kernel.org/bpf/20201201215900.3569844-1-guro@fb.com/ Flag: n/a Test: atest libbpf_load_test Bug: 326156952 Change-Id: I8eda9fe6cee099b1fd979720a4e94d685a571943 Signed-off-by: Neill Kapron <nkapron@google.com>
-rw-r--r--loader/BpfLoadTest.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/loader/BpfLoadTest.cpp b/loader/BpfLoadTest.cpp
index 8a2d072..e14aa7b 100644
--- a/loader/BpfLoadTest.cpp
+++ b/loader/BpfLoadTest.cpp
@@ -36,9 +36,21 @@ class BpfLoadTest : public TestWithParam<std::string> {
int mProgFd;
std::string mTpProgPath;
std::string mTpNeverLoadProgPath;
- std::string mTpMapPath;;
+ std::string mTpMapPath;
void SetUp() {
+ /*
+ * b/326156952
+ *
+ * Kernels prior to 5.11 used rlimit memlock accounting for bpf memory
+ * allocations, and therefore require increasing the rlimit of this
+ * process for the maps to be created successfully.
+ *
+ * 5.11 introduces cgroup-based accounting as discussed here:
+ * https://lore.kernel.org/bpf/20201201215900.3569844-1-guro@fb.com/
+ */
+ if (!isAtLeastKernelVersion(5, 11, 0)) EXPECT_EQ(setrlimitForTest(), 0);
+
mTpProgPath = "/sys/fs/bpf/prog_" + GetParam() + "_tracepoint_sched_sched_switch";
unlink(mTpProgPath.c_str());