Skip to content

Commit a18fda1

Browse files
jrfastabborkmann
authored andcommitted
bpf: reduce runtime of test_sockmap tests
When test_sockmap was running outside of selftests and was not being run by build bots it was reasonable to spend significant amount of time running various tests. The number of tests is high because many different I/O iterators are run. However, now that test_sockmap is part of selftests rather than iterate through all I/O sides only test a minimal set of min/max values along with a few "normal" I/O ops. Also remove the long running tests. They can be run from other test frameworks on a regular cadence. This significanly reduces runtime of test_sockmap. Before: $ time sudo ./test_sockmap > /dev/null real 4m47.521s user 0m0.370s sys 0m3.131s After: $ time sudo ./test_sockmap > /dev/null real 0m0.514s user 0m0.104s sys 0m0.430s The CLI is still available for users that want to test the long running tests that do the larger send/recv tests. Signed-off-by: John Fastabend <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent bf91a76 commit a18fda1

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

tools/testing/selftests/bpf/test_sockmap.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
344344
if (err < 0)
345345
perror("recv start time: ");
346346
while (s->bytes_recvd < total_bytes) {
347-
timeout.tv_sec = 1;
348-
timeout.tv_usec = 0;
347+
timeout.tv_sec = 0;
348+
timeout.tv_usec = 10;
349349

350350
/* FD sets */
351351
FD_ZERO(&w);
@@ -903,12 +903,10 @@ static int test_exec(int cgrp, struct sockmap_options *opt)
903903
{
904904
int err = __test_exec(cgrp, SENDMSG, opt);
905905

906-
sched_yield();
907906
if (err)
908907
goto out;
909908

910909
err = __test_exec(cgrp, SENDPAGE, opt);
911-
sched_yield();
912910
out:
913911
return err;
914912
}
@@ -928,19 +926,18 @@ static int test_loop(int cgrp)
928926
opt.iov_length = 0;
929927
opt.rate = 0;
930928

931-
for (r = 1; r < 100; r += 33) {
932-
for (i = 1; i < 100; i += 33) {
933-
for (l = 1; l < 100; l += 33) {
934-
opt.rate = r;
935-
opt.iov_count = i;
936-
opt.iov_length = l;
937-
err = test_exec(cgrp, &opt);
938-
if (err)
939-
goto out;
940-
}
929+
r = 1;
930+
for (i = 1; i < 100; i += 33) {
931+
for (l = 1; l < 100; l += 33) {
932+
opt.rate = r;
933+
opt.iov_count = i;
934+
opt.iov_length = l;
935+
err = test_exec(cgrp, &opt);
936+
if (err)
937+
goto out;
941938
}
942939
}
943-
940+
sched_yield();
944941
out:
945942
return err;
946943
}
@@ -1031,6 +1028,7 @@ static int test_send(struct sockmap_options *opt, int cgrp)
10311028
if (err)
10321029
goto out;
10331030
out:
1031+
sched_yield();
10341032
return err;
10351033
}
10361034

@@ -1168,7 +1166,7 @@ static int test_start_end(int cgrp)
11681166
opt.iov_length = 100;
11691167
txmsg_cork = 1600;
11701168

1171-
for (i = 99; i <= 1600; i += 100) {
1169+
for (i = 99; i <= 1600; i += 500) {
11721170
txmsg_start = 0;
11731171
txmsg_end = i;
11741172
err = test_exec(cgrp, &opt);
@@ -1177,7 +1175,7 @@ static int test_start_end(int cgrp)
11771175
}
11781176

11791177
/* Test start/end with cork but pull data in middle */
1180-
for (i = 199; i <= 1600; i += 100) {
1178+
for (i = 199; i <= 1600; i += 500) {
11811179
txmsg_start = 100;
11821180
txmsg_end = i;
11831181
err = test_exec(cgrp, &opt);
@@ -1221,6 +1219,7 @@ static int test_start_end(int cgrp)
12211219
out:
12221220
txmsg_start = 0;
12231221
txmsg_end = 0;
1222+
sched_yield();
12241223
return err;
12251224
}
12261225

0 commit comments

Comments
 (0)