* [PATCH] selftests: cgroup: fall back to an unlinked file without O_TMPFILE
@ 2026-11-05 1:18 Sasha Levin
2026-11-22 16:28 ` Kurt Lin
0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2026-11-05 1:18 UTC (permalink / raw)
To: Tejun Heo
Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
Muchun Song, Michal Koutný, Shuah Khan, cgroups, linux-mm,
linux-kselftest, linux-kernel
get_temp_fd() creates its page cache file with O_TMPFILE in the current
directory. On filesystems without O_TMPFILE support, such as NFS, the
open fails with EOPNOTSUPP, and with it every test that needs page cache:
test_memcg_current_peak, test_memcg_min, test_memcg_low, test_memcg_high,
test_memcg_max and test_memcg_reclaim. Boards that boot with an NFS root
fail all six.
Create a regular file with mkstemp() and unlink it in that case.
Fixes: 84092dbcf901 ("selftests: cgroup: add memory controller self-tests")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Found with KernelCI's NVIDIA lab, whose boards boot from NFS. Tested on a
144-CPU Grace with KernelCI's arm64 build of 05441d697f7f9: run from an
NFSv3 mount, all six tests fail without this patch. With it, they behave
as they do from ext4 on that machine: the other four pass, while
test_memcg_min fails and test_memcg_low sometimes fails there too.
tools/testing/selftests/cgroup/test_memcontrol.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c
index bb673012dcf08..7dc9c26628675 100644
--- a/tools/testing/selftests/cgroup/test_memcontrol.c
+++ b/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -33,7 +33,17 @@ static int page_size;
int get_temp_fd(void)
{
- return open(".", O_TMPFILE | O_RDWR | O_EXCL, 0600);
+ char name[] = "./cgroup_test_XXXXXX";
+ int fd;
+
+ fd = open(".", O_TMPFILE | O_RDWR | O_EXCL, 0600);
+ if (fd >= 0 || errno != EOPNOTSUPP)
+ return fd;
+
+ fd = mkstemp(name);
+ if (fd >= 0)
+ unlink(name);
+ return fd;
}
int alloc_pagecache(int fd, size_t size)
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] selftests: cgroup: fall back to an unlinked file without O_TMPFILE
2026-11-05 1:18 [PATCH] selftests: cgroup: fall back to an unlinked file without O_TMPFILE Sasha Levin
@ 2026-11-22 16:28 ` Kurt Lin
0 siblings, 0 replies; 2+ messages in thread
From: Kurt Lin @ 2026-11-22 16:28 UTC (permalink / raw)
To: Sasha Levin, Tejun Heo
Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
Muchun Song, Michal Koutný, Shuah Khan, cgroups, linux-mm,
linux-kselftest, linux-kernel
On Wed, Nov 04, 2026 at 08:18:24PM -0500, Sasha Levin wrote:
> get_temp_fd() creates its page cache file with O_TMPFILE in the current
> directory. On filesystems without O_TMPFILE support, such as NFS, the
> open fails with EOPNOTSUPP, and with it every test that needs page cache:
> test_memcg_current_peak, test_memcg_min, test_memcg_low, test_memcg_high,
> test_memcg_max and test_memcg_reclaim.
virtiofs is another one: run from the kernel tree shared into a
virtme-ng guest, the O_TMPFILE open fails with EOPNOTSUPP and the same
six tests fail.
With this patch on cgroup/for-7.5, test_memcontrol passes from virtiofs
(15 pass, swap_max_peak skipped as the guest has no swap), and from an
ext4 directory it still passes as before. No cgroup_test_* file is left
behind in either directory.
I found and tested this with the help of an AI coding assistant.
Tested-by: Kurt Lin <lylin1023@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-22 16:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 1:18 [PATCH] selftests: cgroup: fall back to an unlinked file without O_TMPFILE Sasha Levin
2026-11-22 16:28 ` Kurt Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox