summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorPu Lehui <pulehui@huawei.com>2026-09-30 08:35:20 +0000
committerAlexei Starovoitov <ast@kernel.org>2026-10-11 13:35:34 +0000
commit153a855d0b3d3b740d7470fc248fe4ebccf06970 (patch)
tree5d776eae4ed9687d9985b01a050dd0af08e8323a /tools/testing
parentb4a1ecae94ae803fcd75fb16a7653ff86b64ed8b (diff)
downloadlinux-next-153a855d0b3d3b740d7470fc248fe4ebccf06970.tar.gz
linux-next-153a855d0b3d3b740d7470fc248fe4ebccf06970.zip
selftests/bpf: Avoid jiffies quantization error in setget_sockopt
The setget_sockopt selftest fails on kernels with HZ=250 (such as the default on riscv64), specifically in the TCP_BPF_DELACK_MAX and TCP_BPF_RTO_MIN sub-tests. The test sets a socket option value in microseconds via bpf_setsockopt() and immediately reads it back via bpf_getsockopt() to verify that it matches. However, the kernel converts the value to jiffies internally for storage and converts it back to microseconds upon retrieval. When HZ=250 (4000 us per jiffy), 30000 us cannot be divided evenly: usecs_to_jiffies(30000) -> 8 jiffies jiffies_to_usecs(8) -> 32000 us (!= 30000 us) This mismatch triggers an assertion failure. Change the test value from 30000 to 40000. 40000 us divides evenly across common kernel timer frequencies (HZ=100, HZ=250, and HZ=1000), avoiding quantization errors and making the test robust across different architectures. Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20260930083522.1914145-3-pulehui@huaweicloud.com
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/bpf/progs/setget_sockopt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/progs/setget_sockopt.c b/tools/testing/selftests/bpf/progs/setget_sockopt.c
index d96e99b67aeb..95e6a337ab71 100644
--- a/tools/testing/selftests/bpf/progs/setget_sockopt.c
+++ b/tools/testing/selftests/bpf/progs/setget_sockopt.c
@@ -61,8 +61,8 @@ static const struct sockopt_test sol_tcp_tests[] = {
{ .opt = TCP_NOTSENT_LOWAT, .new = 1314, .expected = 1314, },
{ .opt = TCP_BPF_SOCK_OPS_CB_FLAGS, .new = BPF_SOCK_OPS_ALL_CB_FLAGS,
.expected = BPF_SOCK_OPS_ALL_CB_FLAGS, },
- { .opt = TCP_BPF_DELACK_MAX, .new = 30000, .expected = 30000, },
- { .opt = TCP_BPF_RTO_MIN, .new = 30000, .expected = 30000, },
+ { .opt = TCP_BPF_DELACK_MAX, .new = 40000, .expected = 40000, },
+ { .opt = TCP_BPF_RTO_MIN, .new = 40000, .expected = 40000, },
{ .opt = TCP_RTO_MAX_MS, .new = 2000, .expected = 2000, },
{ .opt = 0, },
};