Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftest: memcg: skip memcg_sock test if address family not supported

The test_memcg_sock test in memcontrol.c sets up an IPv6 socket and send
data over it to consume memory and verify that memory.stat.sock and
memory.current values are close.

On systems where IPv6 isn't enabled or not configured to support
SOCK_STREAM, the test_memcg_sock test always fails. When the socket()
call fails, there is no way we can test the memory consumption and verify
the above claim. I believe it is better to just skip the test in this
case instead of reporting a test failure hinting that there may be
something wrong with the memcg code.

Link: https://lkml.kernel.org/r/20260311200526.885899-1-longman@redhat.com
Fixes: 5f8f019380b8 ("selftests: cgroup/memcontrol: add basic test for socket accounting")
Signed-off-by: Waiman Long <longman@redhat.com>
Acked-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Waiman Long and committed by
Andrew Morton
2d028f3e f08f610e

+10 -1
+10 -1
tools/testing/selftests/cgroup/test_memcontrol.c
··· 1280 1280 saddr.sin6_port = htons(srv_args->port); 1281 1281 1282 1282 sk = socket(AF_INET6, SOCK_STREAM, 0); 1283 - if (sk < 0) 1283 + if (sk < 0) { 1284 + /* Pass back errno to the ctl_fd */ 1285 + write(ctl_fd, &errno, sizeof(errno)); 1284 1286 return ret; 1287 + } 1285 1288 1286 1289 if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) 1287 1290 goto cleanup; ··· 1414 1411 if (read(args.ctl[0], &err, sizeof(err)) != sizeof(err)) 1415 1412 goto cleanup; 1416 1413 close(args.ctl[0]); 1414 + 1415 + /* Skip if address family not supported by protocol */ 1416 + if (err == EAFNOSUPPORT) { 1417 + ret = KSFT_SKIP; 1418 + goto cleanup; 1419 + } 1417 1420 1418 1421 if (!err) 1419 1422 break;