Skip to content

Commit

Permalink
net: busy-poll: use ktime_get_ns() instead of local_clock()
Browse files Browse the repository at this point in the history
Typically, busy-polling durations are below 100 usec.

When/if the busy-poller thread migrates to another cpu,
local_clock() can be off by +/-2msec or more for small
values of HZ, depending on the platform.

Use ktimer_get_ns() to ensure deterministic behavior,
which is the whole point of busy-polling.

Fixes: 0602129 ("net: add low latency socket poll")
Fixes: 9a3c71a ("net: convert low latency sockets to sched_clock()")
Fixes: 3708983 ("sched, net: Fixup busy_loop_us_clock()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Reviewed-by: Joe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20240827114916.223377-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Aug 29, 2024
1 parent 41901c2 commit 0870b0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/net/busy_poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static inline bool sk_can_busy_loop(struct sock *sk)
static inline unsigned long busy_loop_current_time(void)
{
#ifdef CONFIG_NET_RX_BUSY_POLL
return (unsigned long)(local_clock() >> 10);
return (unsigned long)(ktime_get_ns() >> 10);
#else
return 0;
#endif
Expand Down

0 comments on commit 0870b0d

Please sign in to comment.