* [PATCH] net: core: fix msleep() is not accurate
@ 2020-12-10 9:35 Yejune Deng
2020-12-10 10:19 ` Eric Dumazet
0 siblings, 1 reply; 5+ messages in thread
From: Yejune Deng @ 2020-12-10 9:35 UTC (permalink / raw)
To: davem, kuba, ast, andriin, daniel, edumazet, ap420073,
bjorn.topel, xiyou.wangcong, jiri
Cc: netdev, linux-kernel, yejune.deng
See Documentation/timers/timers-howto.rst, msleep() is not
for (1ms - 20ms), There is a more advanced API is used.
Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
net/core/dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index d33099f..6e83ee03 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6726,9 +6726,9 @@ void napi_disable(struct napi_struct *n)
set_bit(NAPI_STATE_DISABLE, &n->state);
while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
- msleep(1);
+ fsleep(1000);
while (test_and_set_bit(NAPI_STATE_NPSVC, &n->state))
- msleep(1);
+ fsleep(1000);
hrtimer_cancel(&n->timer);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: core: fix msleep() is not accurate
2020-12-10 9:35 [PATCH] net: core: fix msleep() is not accurate Yejune Deng
@ 2020-12-10 10:19 ` Eric Dumazet
2020-12-11 2:43 ` Yejune Deng
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2020-12-10 10:19 UTC (permalink / raw)
To: Yejune Deng
Cc: David Miller, Jakub Kicinski, Alexei Starovoitov,
Andrii Nakryiko, Daniel Borkmann, Taehee Yoo,
Björn Töpel, Cong Wang, Jiri Pirko, netdev, LKML
On Thu, Dec 10, 2020 at 10:35 AM Yejune Deng <yejune.deng@gmail.com> wrote:
>
> See Documentation/timers/timers-howto.rst, msleep() is not
> for (1ms - 20ms), There is a more advanced API is used.
>
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> ---
> net/core/dev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d33099f..6e83ee03 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -6726,9 +6726,9 @@ void napi_disable(struct napi_struct *n)
> set_bit(NAPI_STATE_DISABLE, &n->state);
>
> while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
> - msleep(1);
> + fsleep(1000);
> while (test_and_set_bit(NAPI_STATE_NPSVC, &n->state))
> - msleep(1);
> + fsleep(1000);
>
I would prefer explicit usleep_range().
fsleep() is not common in the kernel, I had to go to its definition.
I would argue that we should use usleep_range(10, 200) to have an
opportunity to spend less time in napi_disable() in some cases.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: core: fix msleep() is not accurate
2020-12-10 10:19 ` Eric Dumazet
@ 2020-12-11 2:43 ` Yejune Deng
0 siblings, 0 replies; 5+ messages in thread
From: Yejune Deng @ 2020-12-11 2:43 UTC (permalink / raw)
To: Eric Dumazet
Cc: David Miller, Jakub Kicinski, Alexei Starovoitov,
Andrii Nakryiko, Daniel Borkmann, Taehee Yoo,
Björn Töpel, Cong Wang, Jiri Pirko, netdev, LKML
Does anyone else have a different opinion? If not,I will adopt it and resubmit.
On Thu, Dec 10, 2020 at 6:19 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Thu, Dec 10, 2020 at 10:35 AM Yejune Deng <yejune.deng@gmail.com> wrote:
> >
> > See Documentation/timers/timers-howto.rst, msleep() is not
> > for (1ms - 20ms), There is a more advanced API is used.
> >
> > Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> > ---
> > net/core/dev.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index d33099f..6e83ee03 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -6726,9 +6726,9 @@ void napi_disable(struct napi_struct *n)
> > set_bit(NAPI_STATE_DISABLE, &n->state);
> >
> > while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
> > - msleep(1);
> > + fsleep(1000);
> > while (test_and_set_bit(NAPI_STATE_NPSVC, &n->state))
> > - msleep(1);
> > + fsleep(1000);
> >
>
> I would prefer explicit usleep_range().
>
> fsleep() is not common in the kernel, I had to go to its definition.
>
> I would argue that we should use usleep_range(10, 200) to have an
> opportunity to spend less time in napi_disable() in some cases.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: core: fix msleep() is not accurate
2020-12-15 2:04 Yejune Deng
@ 2020-12-16 19:33 ` Jakub Kicinski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2020-12-16 19:33 UTC (permalink / raw)
To: Yejune Deng
Cc: davem, ast, andriin, jiri, edumazet, ap420073, bjorn.topel,
netdev, linux-kernel
On Tue, 15 Dec 2020 10:04:25 +0800 Yejune Deng wrote:
> See Documentation/timers/timers-howto.rst, msleep() is not
> for (1ms - 20ms), use usleep_range() instead.
>
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
# Form letter - net-next is closed
We have already sent the networking pull request for 5.11 and therefore
net-next is closed for new drivers, features, code refactoring and
optimizations. We are currently accepting bug fixes only.
Please repost when net-next reopens after 5.11-rc1 is cut.
Look out for the announcement on the mailing list or check:
http://vger.kernel.org/~davem/net-next.html
RFC patches sent for review only are obviously welcome at any time.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] net: core: fix msleep() is not accurate
@ 2020-12-15 2:04 Yejune Deng
2020-12-16 19:33 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: Yejune Deng @ 2020-12-15 2:04 UTC (permalink / raw)
To: davem, kuba, ast, andriin, jiri, edumazet, ap420073, bjorn.topel
Cc: netdev, linux-kernel, yejune.deng
See Documentation/timers/timers-howto.rst, msleep() is not
for (1ms - 20ms), use usleep_range() instead.
Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
net/core/dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index d33099f..c0aa52f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6726,9 +6726,9 @@ void napi_disable(struct napi_struct *n)
set_bit(NAPI_STATE_DISABLE, &n->state);
while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
- msleep(1);
+ usleep_range(10, 200);
while (test_and_set_bit(NAPI_STATE_NPSVC, &n->state))
- msleep(1);
+ usleep_range(10, 200);
hrtimer_cancel(&n->timer);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-16 19:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 9:35 [PATCH] net: core: fix msleep() is not accurate Yejune Deng
2020-12-10 10:19 ` Eric Dumazet
2020-12-11 2:43 ` Yejune Deng
2020-12-15 2:04 Yejune Deng
2020-12-16 19:33 ` Jakub Kicinski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.