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.

selftests: net: reduce txtimestamp deschedule flakes

This test occasionally fails due to exceeding timing bounds, as
run in continuous testing on netdev.bots:

https://netdev.bots.linux.dev/contest.html?test=txtimestamp-sh

A common pattern is a single elevated delay between USR and SND.

# 8.36 [+0.00] test SND
# 8.36 [+0.00] USR: 1767864384 s 240994 us (seq=0, len=0)
# 8.44 [+0.08] ERROR: 18461 us expected between 10000 and 18000
# 8.44 [+0.00] SND: 1767864384 s 259455 us (seq=42, len=10) (USR +18460 us)
# 8.52 [+0.07] SND: 1767864384 s 339523 us (seq=42, len=10) (USR +10005 us)
# 8.52 [+0.00] USR: 1767864384 s 409580 us (seq=0, len=0)
# 8.60 [+0.08] SND: 1767864384 s 419586 us (seq=42, len=10) (USR +10005 us)
# 8.60 [+0.00] USR: 1767864384 s 489645 us (seq=0, len=0)
# 8.68 [+0.08] SND: 1767864384 s 499651 us (seq=42, len=10) (USR +10005 us)
# 8.68 [+0.00] USR-SND: count=4, avg=12119 us, min=10005 us, max=18460 us

(Note that other delays are nowhere near the large 8ms tolerance.)

One hypothesis is that the task is descheduled between taking the USR
timestamp and sending the packet. Possibly in printing.

Delay taking the timestamp closer to sendmsg, and delay printing until
after sendmsg.

With this change, failure rate is significantly lower in current runs.

Link: https://lore.kernel.org/netdev/20260107110521.1aab55e9@kernel.org/
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20260112163355.3510150-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Willem de Bruijn and committed by
Jakub Kicinski
c65182ef 50e194b6

+5 -5
+5 -5
tools/testing/selftests/net/txtimestamp.c
··· 206 206 fprintf(stderr, "\n"); 207 207 } 208 208 209 - static void print_timestamp_usr(void) 209 + static void record_timestamp_usr(void) 210 210 { 211 211 if (clock_gettime(CLOCK_REALTIME, &ts_usr)) 212 212 error(1, errno, "clock_gettime"); 213 - 214 - __print_timestamp(" USR", &ts_usr, 0, 0); 215 213 } 216 214 217 215 static void print_timestamp(struct scm_timestamping *tss, int tstype, ··· 597 599 fill_header_udp(buf + off, family == PF_INET); 598 600 } 599 601 600 - print_timestamp_usr(); 601 - 602 602 iov.iov_base = buf; 603 603 iov.iov_len = total_len; 604 604 ··· 651 655 652 656 } 653 657 658 + record_timestamp_usr(); 659 + 654 660 val = sendmsg(fd, &msg, 0); 655 661 if (val != total_len) 656 662 error(1, errno, "send"); 663 + 664 + __print_timestamp(" USR", &ts_usr, 0, 0); 657 665 658 666 /* wait for all errors to be queued, else ACKs arrive OOO */ 659 667 if (cfg_sleep_usec)