Re: [PATCH bpf-next v2] selftests/bpf: Fall back when memcg_proactive_reclaim data lands in shmem

From: Alexei Starovoitov

Date: Tue Nov 17 2026 - 22:49:13 EST


On Tue, Nov 17, 2026 at 09:07 AM Kurt Lin <lylin1023@xxxxxxxxx> wrote:
> After writing the file, check memory.stat and move on to the next
> candidate directory if most of the data was charged as shmem; skip only
> when none is left. Give each candidate its own cgroup so that stale
> stats from a previous attempt cannot interfere, and poll memory.stat
> until the write shows up, as reading it does not force a stats flush.
> Fail the test if memory.stat cannot be read or never shows the write.

This is overkill.

> To exercise the polling, FILE_SIZE was temporarily cut to 2 MiB in a
> 128-vCPU guest, which keeps the write below the flush threshold.

So the test with 32 MiB didn't hit it.
Pls don't add code just because a bot said so.

Here is what I mean. I didn't compile it:

diff --git a/tools/testing/selftests/bpf/prog_tests/arena_memcg.c b/tools/testing/selftests/bpf/prog_tests/arena_memcg.c
index c76a7eb..334bfa6 100644
--- a/tools/testing/selftests/bpf/prog_tests/arena_memcg.c
+++ b/tools/testing/selftests/bpf/prog_tests/arena_memcg.c
@@ -53,8 +53,12 @@ static int alloc_pagecache(size_t size)
fd = open(".", O_TMPFILE | O_RDWR | O_EXCL, 0600);
if (fd < 0)
return errno == EOPNOTSUPP ? -EOPNOTSUPP : -1;
- /* tmpfs hands out shmem pages, which are not reclaimable without swap */
- if (fstatfs(fd, &stfs) || stfs.f_type == TMPFS_MAGIC) {
+ /*
+ * tmpfs hands out shmem pages, which are not reclaimable without swap.
+ * overlayfs hides the type of its upper layer, which can be tmpfs.
+ */
+ if (fstatfs(fd, &stfs) || stfs.f_type == TMPFS_MAGIC ||
+ stfs.f_type == OVERLAYFS_SUPER_MAGIC) {
close(fd);
return -EOPNOTSUPP;
}
diff --git a/tools/testing/selftests/bpf/prog_tests/memcg_proactive_reclaim.c b/tools/testing/selftests/bpf/prog_tests/memcg_proactive_reclaim.c
index c22dcfa..2ba0791 100644
--- a/tools/testing/selftests/bpf/prog_tests/memcg_proactive_reclaim.c
+++ b/tools/testing/selftests/bpf/prog_tests/memcg_proactive_reclaim.c
@@ -30,7 +30,8 @@ struct reclaim_args {
* being available, and a read-only mount cannot host the file at all (EROFS
* applies to root too). /tmp is tmpfs on many systems, and test_progs is
* routinely run from a tmpfs working directory, so both candidates need the
- * check.
+ * check. overlayfs hides the type of its upper layer, which is tmpfs for /tmp
+ * in virtme-ng guests.
*/
static const char *workload_dir(void)
{
@@ -40,7 +41,8 @@ static const char *workload_dir(void)

for (i = 0; i < ARRAY_SIZE(dirs); i++)
if (!statfs(dirs[i], &st) && st.f_type != TMPFS_MAGIC &&
- st.f_type != RAMFS_MAGIC && !access(dirs[i], W_OK))
+ st.f_type != RAMFS_MAGIC &&
+ st.f_type != OVERLAYFS_SUPER_MAGIC && !access(dirs[i], W_OK))
return dirs[i];

return NULL;

pw-bot: cr