public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH] selftest: memcg: Skp memcg_sock test if address family not supported
@ 2026-03-09 16:02 Waiman Long
  2026-03-09 18:07 ` Michal Koutný
  0 siblings, 1 reply; 4+ messages in thread
From: Waiman Long @ 2026-03-09 16:02 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Andrew Morton, Tejun Heo, Michal Koutný,
	Shuah Khan, Mike Rapoport
  Cc: linux-kernel, cgroups, linux-mm, linux-kselftest, Waiman Long

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.

Fixes: 5f8f019380b8 ("selftests: cgroup/memcontrol: add basic test for socket accounting")
Signed-off-by: Waiman Long <longman@redhat.com>
---
 tools/testing/selftests/cgroup/test_memcontrol.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c
index 2fb096a2a9f9..3c13ef67fafb 100644
--- a/tools/testing/selftests/cgroup/test_memcontrol.c
+++ b/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -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;
 }
 
 /*
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftest: memcg: Skp memcg_sock test if address family not supported
  2026-03-09 16:02 [PATCH] selftest: memcg: Skp memcg_sock test if address family not supported Waiman Long
@ 2026-03-09 18:07 ` Michal Koutný
  2026-03-10  0:04   ` Waiman Long
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Koutný @ 2026-03-09 18:07 UTC (permalink / raw)
  To: Waiman Long
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Andrew Morton, Tejun Heo, Shuah Khan, Mike Rapoport,
	linux-kernel, cgroups, linux-mm, linux-kselftest

[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]

On Mon, Mar 09, 2026 at 12:02:05PM -0400, Waiman Long <longman@redhat.com> wrote:
> On systems where IPv6 isn't enabled or not configured to support
> SOCK_STREAM, the test_memcg_sock test always fails.

I think IPv6 is not substantial for the check...

> The purpose of the test_memcg_sock test is to verify that
> memory.stat.sock and memory.current values are close.

... so this should work with IPv4 too.

> 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.

> @@ -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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftest: memcg: Skp memcg_sock test if address family not supported
  2026-03-09 18:07 ` Michal Koutný
@ 2026-03-10  0:04   ` Waiman Long
  2026-03-10 14:09     ` Waiman Long
  0 siblings, 1 reply; 4+ messages in thread
From: Waiman Long @ 2026-03-10  0:04 UTC (permalink / raw)
  To: Michal Koutný
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Andrew Morton, Tejun Heo, Shuah Khan, Mike Rapoport,
	linux-kernel, cgroups, linux-mm, linux-kselftest

On 3/9/26 2:07 PM, Michal Koutný wrote:
> On Mon, Mar 09, 2026 at 12:02:05PM -0400, Waiman Long <longman@redhat.com> wrote:
>> On systems where IPv6 isn't enabled or not configured to support
>> SOCK_STREAM, the test_memcg_sock test always fails.
> I think IPv6 is not substantial for the check...
I mentioned it because the current code is using AF_INET6 family.
>
>> The purpose of the test_memcg_sock test 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.
>
>> 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.
>
>> @@ -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;
> 	}

Yes, that will work too. Will make the update in the next version.

Cheers,
Longman



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftest: memcg: Skp memcg_sock test if address family not supported
  2026-03-10  0:04   ` Waiman Long
@ 2026-03-10 14:09     ` Waiman Long
  0 siblings, 0 replies; 4+ messages in thread
From: Waiman Long @ 2026-03-10 14:09 UTC (permalink / raw)
  To: Michal Koutný
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Andrew Morton, Tejun Heo, Shuah Khan, Mike Rapoport,
	linux-kernel, cgroups, linux-mm, linux-kselftest

On 3/9/26 8:04 PM, Waiman Long wrote:
> On 3/9/26 2:07 PM, Michal Koutný wrote:
>> On Mon, Mar 09, 2026 at 12:02:05PM -0400, Waiman Long 
>> <longman@redhat.com> wrote:
>>> On systems where IPv6 isn't enabled or not configured to support
>>> SOCK_STREAM, the test_memcg_sock test always fails.
>> I think IPv6 is not substantial for the check...
> I mentioned it because the current code is using AF_INET6 family.
>>
>>> The purpose of the test_memcg_sock test 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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-10 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 16:02 [PATCH] selftest: memcg: Skp memcg_sock test if address family not supported Waiman Long
2026-03-09 18:07 ` Michal Koutný
2026-03-10  0:04   ` Waiman Long
2026-03-10 14:09     ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox