From: Kurt Lin <lylin1023@gmail.com>
To: Hui Zhu <zhuhui@kylinos.cn>, Hui Zhu <hui.zhu@linux.dev>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Emil Tsalapatis <emil@etsalapatis.com>,
Barry Song <baohua@kernel.org>, Shuah Khan <shuah@kernel.org>,
Jiayuan Chen <jiayuan.chen@linux.dev>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Kurt Lin <lylin1023@gmail.com>
Subject: [PATCH bpf-next v3] selftests/bpf: Keep memcg test page cache off overlayfs
Date: Fri, 20 Nov 2026 02:39:25 +0800 [thread overview]
Message-ID: <20261119183925.1482217-1-lylin1023@gmail.com> (raw)
memcg_proactive_reclaim and arena_memcg keep their page cache off tmpfs,
because shmem cannot be reclaimed without swap. But statfs() only sees
the top of a stacking filesystem: with /tmp on overlayfs over tmpfs, as
in virtme-ng guests, the check passes and the data is still charged as
shmem. memcg_proactive_reclaim then fails in a full test_progs run with:
test_memcg_proactive_reclaim:FAIL:reclaimed unexpected reclaimed: actual 0 <= expected 0
and arena_memcg, run from such a directory, with:
serial_test_arena_memcg:FAIL:child faulted the arena in unexpected child faulted the arena in: got FALSE
Reject overlayfs as well, so that memcg_proactive_reclaim moves on to
the next candidate directory and arena_memcg skips.
An AI coding assistant (Claude) was used to find and analyze the
failure and to draft this changelog.
Fixes: 0f9b1e9ef584 ("selftests/bpf: Add bpf_proactive_reclaim test")
Fixes: 1fe5a5cd01e4 ("selftests/bpf: Add a test for arena fault-in under memory.max")
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Kurt Lin <lylin1023@gmail.com>
---
Notes:
Changes in v3:
- Drop the memory.stat check, the polling and the per-directory cgroups,
and reject overlayfs in the statfs() checks instead (Alexei).
- Apply the same fix to arena_memcg.
Changes in v2:
- Fall back to the next candidate directory instead of skipping.
- Poll memory.stat until the write shows up.
- Fail when memory.stat cannot be read.
Tested in virtme-ng guests without swap (/tmp is overlayfs over tmpfs,
the working directory is virtiofs):
- memcg_proactive_reclaim passes from the default setup, from a tmpfs
/tmp and from an ext4 working directory, and skips when the working
directory is read-only or also overlayfs over tmpfs.
- arena_memcg passes from an ext4 working directory and now skips from
overlayfs over tmpfs, where it failed before.
- A full test_progs run passes memcg_proactive_reclaim; the only
failures are fs_kfuncs (no xattrs on the overlayfs /tmp) and
xdp_synproxy (no iptables-legacy on the host), both unrelated.
v2: https://lore.kernel.org/bpf/20261117170704.1146730-1-lylin1023@gmail.com/
v1: https://lore.kernel.org/bpf/20261113180159.602033-1-lylin1023@gmail.com/
tools/testing/selftests/bpf/prog_tests/arena_memcg.c | 8 ++++++--
.../selftests/bpf/prog_tests/memcg_proactive_reclaim.c | 6 ++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/arena_memcg.c b/tools/testing/selftests/bpf/prog_tests/arena_memcg.c
index c76a7eb2f01d..334bfa61be76 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 c22dcfabe856..2ba07916bdc9 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;
base-commit: 0021f17128de5dc0b19f1a523f448df2440d8088
--
2.56.1
reply other threads:[~2026-11-19 18:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119183925.1482217-1-lylin1023@gmail.com \
--to=lylin1023@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=baohua@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=hui.zhu@linux.dev \
--cc=ihor.solodrai@linux.dev \
--cc=jiayuan.chen@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
--cc=zhuhui@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®