Commit 579f1b1c authored by Eric Dumazet's avatar Eric Dumazet Committed by Liu Jian
Browse files

net: busy-poll: use ktime_get_ns() instead of local_clock()

stable inclusion
from stable-v4.19.321
commit 1b1f0890fb51fc50bf990a800106a133f9036f32
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAYZ0U

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1b1f0890fb51fc50bf990a800106a133f9036f32



-------------------------------------------------

[ Upstream commit 0870b0d8b393dde53106678a1e2cec9dfa52f9b7 ]

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: 06021292 ("net: add low latency socket poll")
Fixes: 9a3c71aa ("net: convert low latency sockets to sched_clock()")
Fixes: 37089834 ("sched, net: Fixup busy_loop_us_clock()")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Reviewed-by: default avatarJoe Damato <jdamato@fastly.com>
Link: https://patch.msgid.link/20240827114916.223377-1-edumazet@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLiu Jian <liujian56@huawei.com>
parent 928293cc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,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