diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2026-04-13 00:06:36 +0300 |
|---|---|---|
| committer | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2026-04-13 00:46:32 +0300 |
| commit | 47687a29b2c3acc9aa553737d482645813878aed (patch) | |
| tree | aaa93bd431036dee45dc9430f071be4755e3c79c /tools/testing | |
| parent | fa2942918afbd0cb765277e2fd09fe0aaef6dd8d (diff) | |
| download | linux-47687a29b2c3acc9aa553737d482645813878aed.tar.xz | |
selftests/bpf: Use memfd_create instead of shm_open in cgroup_iter_memcg
Replace shm_open/shm_unlink with memfd_create in the shmem subtest.
shm_open requires /dev/shm to be mounted, which is not always available
in test environments, causing the test to fail with ENOENT.
memfd_create creates an anonymous shmem-backed fd without any filesystem
dependency while exercising the same shmem accounting path.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20260412210636.47516-1-alexei.starovoitov@gmail.com
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c b/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c index 88fc3e83d2b7..b7c18d590b99 100644 --- a/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c @@ -107,10 +107,10 @@ static void test_shmem(struct bpf_link *link, struct memcg_query *memcg_query) /* * Increase memcg shmem usage by creating and writing - * to a shmem object. + * to a memfd backed by shmem/tmpfs. */ - fd = shm_open("/tmp_shmem", O_CREAT | O_RDWR, 0644); - if (!ASSERT_OK_FD(fd, "shm_open")) + fd = memfd_create("tmp_shmem", 0); + if (!ASSERT_OK_FD(fd, "memfd_create")) return; if (!ASSERT_OK(fallocate(fd, 0, 0, len), "fallocate")) @@ -123,7 +123,6 @@ static void test_shmem(struct bpf_link *link, struct memcg_query *memcg_query) cleanup: close(fd); - shm_unlink("/tmp_shmem"); } static void test_pgfault(struct bpf_link *link, struct memcg_query *memcg_query) |
