public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Damato <jdamato@fastly.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com,
	Mina Almasry <almasrymina@google.com>,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH net] net: busy-poll: use ktime_get_ns() instead of local_clock()
Date: Tue, 27 Aug 2024 12:58:07 +0100	[thread overview]
Message-ID: <Zs2_TzLC1najJ2Ip@LQ3V64L9R2> (raw)
In-Reply-To: <20240827114916.223377-1-edumazet@google.com>

On Tue, Aug 27, 2024 at 11:49:16AM +0000, Eric Dumazet wrote:
> 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: 060212928670 ("net: add low latency socket poll")
> Fixes: 9a3c71aa8024 ("net: convert low latency sockets to sched_clock()")
> Fixes: 37089834528b ("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>
> Cc: Joe Damato <jdamato@fastly.com>
> ---
>  include/net/busy_poll.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
> index 9b09acac538eed8dbaa2576bf2af926ecd98eb44..522f1da8b747ac73578d8fd93301d31835a6dae0 100644
> --- a/include/net/busy_poll.h
> +++ b/include/net/busy_poll.h
> @@ -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
> -- 
> 2.46.0.295.g3b9ea8a38a-goog

Makes sense to me, thanks.

Reviewed-by: Joe Damato <jdamato@fastly.com>

  reply	other threads:[~2024-08-27 11:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27 11:49 [PATCH net] net: busy-poll: use ktime_get_ns() instead of local_clock() Eric Dumazet
2024-08-27 11:58 ` Joe Damato [this message]
2024-08-29  1:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zs2_TzLC1najJ2Ip@LQ3V64L9R2 \
    --to=jdamato@fastly.com \
    --cc=almasrymina@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox