Skip to contentSkip to conversation

selftests/net: relax cpu affinity requirement in msg_zerocopy test

PATCH In review Willem de Bruijn 3 participants 3 messages Aug 5, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/net: relax cpu affinity requirement in msg_zerocopy test

From: Willem de Bruijn <[email protected]>

The msg_zerocopy test pins the sender and receiver threads to separate cores to reduce variance between runs.

But it hardcodes the cores and skips core 0, so it fails on machines with the selected cores offline, or simply fewer cores.

The test mainly gives code coverage in automated runs. The throughput of zerocopy ('-z') and non-zerocopy runs is logged for manual inspection.

Continue even when sched_setaffinity fails. Just log to warn anyone interpreting the data.

Fixes 07b65c5b31ce ("test: add msg_zerocopy test")
---
 tools/testing/selftests/net/msg_zerocopy.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/testing/selftests/net/msg_zerocopy.c +2 -3
index 4b02933cab8a..bdc03a2097e8 100644
@@ -125,9 +125,8 @@ static int do_setcpu(int cpu)
 	CPU_ZERO(&mask);
 	CPU_SET(cpu, &mask);
 	if (sched_setaffinity(0, sizeof(mask), &mask))
-		error(1, 0, "setaffinity %d", cpu);
-
-	if (cfg_verbose)
+		fprintf(stderr, "cpu: unable to pin, may increase variance.\n");
+	else if (cfg_verbose)
 		fprintf(stderr, "cpu: %u\n", cpu);
 
 	return 0;
Signature · 1 line
2.28.0.236.gb10cc79966-goog
Acked-by on v1 1/1
#1 lore raw

ACK: [PATCH net] selftests/net: relax cpu affinity requirement in msg_zerocopy test

Quoted 29 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

The msg_zerocopy test pins the sender and receiver threads to separate cores to reduce variance between runs.

But it hardcodes the cores and skips core 0, so it fails on machines with the selected cores offline, or simply fewer cores.

The test mainly gives code coverage in automated runs. The throughput of zerocopy ('-z') and non-zerocopy runs is logged for manual inspection.

Continue even when sched_setaffinity fails. Just log to warn anyone interpreting the data.

Fixes 07b65c5b31ce ("test: add msg_zerocopy test")
---
 tools/testing/selftests/net/msg_zerocopy.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/testing/selftests/net/msg_zerocopy.c +0 -0
index 4b02933cab8a..bdc03a2097e8 100644
@@ -125,9 +125,8 @@ static int do_setcpu(int cpu)
 	CPU_ZERO(&mask);

tools/testing/selftests/net/msg_zerocopy.c static int do_setcpu(int cpu) · line 132

Quoted 10 lines
tools/testing/selftests/net/msg_zerocopy.c +2 -3
 	CPU_SET(cpu, &mask);
 	if (sched_setaffinity(0, sizeof(mask), &mask))
-		error(1, 0, "setaffinity %d", cpu);
-
-	if (cfg_verbose)
+		fprintf(stderr, "cpu: unable to pin, may increase variance.\n");
+	else if (cfg_verbose)
 		fprintf(stderr, "cpu: %u\n", cpu);
 
 	return 0;

Thanks, you solution is good for my testing requirements

maintainer
#2 lore raw
In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>
Date: Wed, 5 Aug 2020 04:40:45 -0400

Quoted 12 lines

From: Willem de Bruijn <[email protected]>

The msg_zerocopy test pins the sender and receiver threads to separate cores to reduce variance between runs.

But it hardcodes the cores and skips core 0, so it fails on machines with the selected cores offline, or simply fewer cores.

The test mainly gives code coverage in automated runs. The throughput of zerocopy ('-z') and non-zerocopy runs is logged for manual inspection.

Quoted 6 lines

Continue even when sched_setaffinity fails. Just log to warn anyone interpreting the data.

Fixes 07b65c5b31ce ("test: add msg_zerocopy test")

Applied and queued up for -stable, thanks.