* [PATCH net] net_sched: gen_estimator:
@ 2025-08-26 18:05 Eric Dumazet
2025-08-26 18:06 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2025-08-26 18:05 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet,
syzbot+72db9ee39db57c3fecc5, Sebastian Andrzej Siewior
syzbot reported a WARNING in est_timer() [1]
Problem here is that with CONFIG_PREEMPT_RT=y, timer callbacks
can be preempted.
Adopt preempt_disable_nested()/preempt_enable_nested() to fix this.
[1]
WARNING: CPU: 0 PID: 16 at ./include/linux/seqlock.h:221 __seqprop_assert include/linux/seqlock.h:221 [inline]
WARNING: CPU: 0 PID: 16 at ./include/linux/seqlock.h:221 est_timer+0x6dc/0x9f0 net/core/gen_estimator.c:93
Modules linked in:
CPU: 0 UID: 0 PID: 16 Comm: ktimers/0 Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:__seqprop_assert include/linux/seqlock.h:221 [inline]
RIP: 0010:est_timer+0x6dc/0x9f0 net/core/gen_estimator.c:93
Call Trace:
<TASK>
call_timer_fn+0x17e/0x5f0 kernel/time/timer.c:1747
expire_timers kernel/time/timer.c:1798 [inline]
__run_timers kernel/time/timer.c:2372 [inline]
__run_timer_base+0x648/0x970 kernel/time/timer.c:2384
run_timer_base kernel/time/timer.c:2393 [inline]
run_timer_softirq+0xb7/0x180 kernel/time/timer.c:2403
handle_softirqs+0x22c/0x710 kernel/softirq.c:579
__do_softirq kernel/softirq.c:613 [inline]
run_ktimerd+0xcf/0x190 kernel/softirq.c:1043
smpboot_thread_fn+0x53f/0xa60 kernel/smpboot.c:160
kthread+0x70e/0x8a0 kernel/kthread.c:463
ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Fixes: d2d6422f8bd1 ("x86: Allow to enable PREEMPT_RT.")
Reported-by: syzbot+72db9ee39db57c3fecc5@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/68adf6fa.a70a0220.3cafd4.0000.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
net/core/gen_estimator.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index 7d426a8e29f30b67655cf706060bfc6c478f3123..f112156db587ba54a995a68ead5a35fe0cb16230 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -90,10 +90,12 @@ static void est_timer(struct timer_list *t)
rate = (b_packets - est->last_packets) << (10 - est->intvl_log);
rate = (rate >> est->ewma_log) - (est->avpps >> est->ewma_log);
+ preempt_disable_nested();
write_seqcount_begin(&est->seq);
est->avbps += brate;
est->avpps += rate;
write_seqcount_end(&est->seq);
+ preempt_enable_nested();
est->last_bytes = b_bytes;
est->last_packets = b_packets;
--
2.51.0.261.g7ce5a0a67e-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net_sched: gen_estimator:
2025-08-26 18:05 [PATCH net] net_sched: gen_estimator: Eric Dumazet
@ 2025-08-26 18:06 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2025-08-26 18:06 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, netdev, eric.dumazet, syzbot+72db9ee39db57c3fecc5,
Sebastian Andrzej Siewior
On Tue, Aug 26, 2025 at 11:05 AM Eric Dumazet <edumazet@google.com> wrote:
>
> syzbot reported a WARNING in est_timer() [1]
>
> Problem here is that with CONFIG_PREEMPT_RT=y, timer callbacks
> can be preempted.
>
> Adopt preempt_disable_nested()/preempt_enable_nested() to fix this.
>
Patch title is messed up.
It should read :
net_sched: gen_estimator: fix est_timer() vs CONFIG_PREEMPT_RT=y
> [1]
> WARNING: CPU: 0 PID: 16 at ./include/linux/seqlock.h:221 __seqprop_assert include/linux/seqlock.h:221 [inline]
> WARNING: CPU: 0 PID: 16 at ./include/linux/seqlock.h:221 est_timer+0x6dc/0x9f0 net/core/gen_estimator.c:93
> Modules linked in:
> CPU: 0 UID: 0 PID: 16 Comm: ktimers/0 Not tainted syzkaller #0 PREEMPT_{RT,(full)}
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
> RIP: 0010:__seqprop_assert include/linux/seqlock.h:221 [inline]
> RIP: 0010:est_timer+0x6dc/0x9f0 net/core/gen_estimator.c:93
> Call Trace:
> <TASK>
> call_timer_fn+0x17e/0x5f0 kernel/time/timer.c:1747
> expire_timers kernel/time/timer.c:1798 [inline]
> __run_timers kernel/time/timer.c:2372 [inline]
> __run_timer_base+0x648/0x970 kernel/time/timer.c:2384
> run_timer_base kernel/time/timer.c:2393 [inline]
> run_timer_softirq+0xb7/0x180 kernel/time/timer.c:2403
> handle_softirqs+0x22c/0x710 kernel/softirq.c:579
> __do_softirq kernel/softirq.c:613 [inline]
> run_ktimerd+0xcf/0x190 kernel/softirq.c:1043
> smpboot_thread_fn+0x53f/0xa60 kernel/smpboot.c:160
> kthread+0x70e/0x8a0 kernel/kthread.c:463
> ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148
> ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
> </TASK>
>
> Fixes: d2d6422f8bd1 ("x86: Allow to enable PREEMPT_RT.")
> Reported-by: syzbot+72db9ee39db57c3fecc5@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/netdev/68adf6fa.a70a0220.3cafd4.0000.GAE@google.com/T/#u
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> net/core/gen_estimator.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
> index 7d426a8e29f30b67655cf706060bfc6c478f3123..f112156db587ba54a995a68ead5a35fe0cb16230 100644
> --- a/net/core/gen_estimator.c
> +++ b/net/core/gen_estimator.c
> @@ -90,10 +90,12 @@ static void est_timer(struct timer_list *t)
> rate = (b_packets - est->last_packets) << (10 - est->intvl_log);
> rate = (rate >> est->ewma_log) - (est->avpps >> est->ewma_log);
>
> + preempt_disable_nested();
> write_seqcount_begin(&est->seq);
> est->avbps += brate;
> est->avpps += rate;
> write_seqcount_end(&est->seq);
> + preempt_enable_nested();
>
> est->last_bytes = b_bytes;
> est->last_packets = b_packets;
> --
> 2.51.0.261.g7ce5a0a67e-goog
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-26 18:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26 18:05 [PATCH net] net_sched: gen_estimator: Eric Dumazet
2025-08-26 18:06 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox