selftest: memcg: Skp memcg_sock test if address family not supported
Subsystems (4)
PATCH 1/1 selftest: memcg: Skp memcg_sock test if address family not supported
On systems where IPv6 isn't enabled or not configured to support SOCK_STREAM, the test_memcg_sock test always fails. The purpose of the test_memcg_sock test is to verify that memory.stat.sock and memory.current values are close. If the socket() call fails, there is no way we can test that. 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.
--- tools/testing/selftests/cgroup/test_memcontrol.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tools/testing/selftests/cgroup/test_memcontrol.c +10 -1
@@ -1280,8 +1280,11 @@ static int tcp_server(const char *cgroup, void *arg) saddr.sin6_port =htons (srv_args->port); sk =socket (AF_INET6 ,SOCK_STREAM ,0 ); -if (sk <0 ) +if (sk <0 ) { +/* Pass back errno to the ctl_fd */ +write (ctl_fd, &errno,sizeof (errno));return ret; + }if (setsockopt (sk,SOL_SOCKET ,SO_REUSEADDR , &yes,sizeof (yes)) <0 ) goto cleanup;
@@ -1414,6 +1417,9 @@ static int test_memcg_sock(const char *root)if (!err)break ; +if (err ==EAFNOSUPPORT ) +/* Skip if address family not supported by protocol */ + goto skip;if (err !=EADDRINUSE ) goto cleanup;
@@ -1460,6 +1466,9 @@ static int test_memcg_sock(const char *root)free (memcg);return ret; +skip: + ret =KSFT_SKIP ; + goto cleanup; }/*
Signature · 1 line
2.53.0
Michal Koutný
maintainerQuoted 2 lines · Waiman Long
On systems where IPv6 isn't enabled or not configured to support
SOCK_STREAM, thetest_memcg_socktest always fails.
I think IPv6 is not substantial for the check...
Quoted 2 lines
The purpose of the
test_memcg_socktest is to verify that memory.stat.sock and memory.current values are close.
... so this should work with IPv4 too.
Quoted 4 lines
If the
socket()call fails, there is no way we can test that. 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.
Yes, the skip on (any) socket creation is also (independently) good.
tools/testing/selftests/cgroup/test_memcontrol.c static int test_memcg_sock(const char *root) · line 1471
Quoted 7 lines
tools/testing/selftests/cgroup/test_memcontrol.c +3
-0@@ -1460,6 +1466,9 @@ static int test_memcg_sock(const char *root)free (memcg);return ret; +skip: + ret =KSFT_SKIP ; + goto cleanup;
Maybe make this analogous with other cases where there is no specific skip-label but
if (err == EAFNOSUPPORT) {
ret = KSFT_SKIP;
goto cleanup;
}Thanks,
Michal
Quoted 4 lines · Michal Koutný
Quoted 2 lines · Waiman Long
On systems where IPv6 isn't enabled or not configured to support
SOCK_STREAM, thetest_memcg_socktest always fails.I think IPv6 is not substantial for the check...
I mentioned it because the current code is using AF_INET6 family.
Quoted 4 lines
Quoted 3 lines
The purpose of the
test_memcg_socktest is to verify that memory.stat.sock and memory.current values are close.... so this should work with IPv4 too.
Probably, I will try that out.
Quoted 16 lines
Quoted 5 lines
If the
socket()call fails, there is no way we can test that. 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.Yes, the skip on (any) socket creation is also (independently) good.
tools/testing/selftests/cgroup/test_memcontrol.c static int test_memcg_sock(const char *root) · line 1471
Quoted 7 lines
tools/testing/selftests/cgroup/test_memcontrol.c +3
-0@@ -1460,6 +1466,9 @@ static int test_memcg_sock(const char *root)free (memcg);return ret; +skip: + ret =KSFT_SKIP ; + goto cleanup;Maybe make this analogous with other cases where there is no specific skip-label but
Quoted 4 lines
if (err == EAFNOSUPPORT) {
ret = KSFT_SKIP;
goto cleanup;
}Yes, that will work too. Will make the update in the next version.
Cheers,
Longman
Quoted 11 lines · Waiman Long
Quoted 4 lines · Michal Koutný
Quoted 2 lines · Waiman Long
On systems where IPv6 isn't enabled or not configured to support
SOCK_STREAM, thetest_memcg_socktest always fails.I think IPv6 is not substantial for the check...
I mentioned it because the current code is using
AF_INET6family.Quoted 4 lines
Quoted 3 lines
The purpose of the
test_memcg_socktest is to verify that memory.stat.sock and memory.current values are close.... so this should work with IPv4 too.
Probably, I will try that out.
On my test system, creating a socket with IPv4 does work. However, with IPv4, the memcg_sock test becomes unstable and it fails half of the times as the memory values aren't close enough. It is possible that the assumption that memory values should be close aren't quite true with IPv4. As I am not familiar with the networking code at all, I will let others who have more experience with the networking side to try that out.
Cheers,
Longman