public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Use memfd_create instead of shm_open in cgroup_iter_memcg
@ 2026-04-12 21:06 Alexei Starovoitov
  2026-04-12 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Alexei Starovoitov @ 2026-04-12 21:06 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, martin.lau, memxor, eddyz87

From: Alexei Starovoitov <ast@kernel.org>

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>
---
 tools/testing/selftests/bpf/prog_tests/cgroup_iter_memcg.c | 7 +++----
 1 file 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)
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: Use memfd_create instead of shm_open in cgroup_iter_memcg
  2026-04-12 21:06 [PATCH bpf-next] selftests/bpf: Use memfd_create instead of shm_open in cgroup_iter_memcg Alexei Starovoitov
@ 2026-04-12 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-04-12 22:00 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: bpf, daniel, andrii, martin.lau, memxor, eddyz87

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Kumar Kartikeya Dwivedi <memxor@gmail.com>:

On Sun, 12 Apr 2026 14:06:36 -0700 you wrote:
> From: Alexei Starovoitov <ast@kernel.org>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: Use memfd_create instead of shm_open in cgroup_iter_memcg
    https://git.kernel.org/bpf/bpf-next/c/47687a29b2c3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-12 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12 21:06 [PATCH bpf-next] selftests/bpf: Use memfd_create instead of shm_open in cgroup_iter_memcg Alexei Starovoitov
2026-04-12 22:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox