net: sched: fixes after recent qdisc->running changes
Subsystems (2)
cover net: sched: fixes after recent qdisc->running changes
From: Eric Dumazet <[email protected]>
First patch fixes a plain bug in qdisc_run_begin().
Second patch removes a pair of atomic operations, increasing performance.
Eric Dumazet (2):
net: sched: fix logic error in qdisc_run_begin()
net: sched: remove one pair of atomic operations
include/net/sch_generic.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH 1/2 net: sched: fix logic error in qdisc_run_begin()
From: Eric Dumazet <[email protected]>
For non TCQ_F_NOLOCK qdisc, qdisc_run_begin() tries to set __QDISC_STATE_RUNNING and should return true if the bit was not set.
test_and_set_bit() returns old bit value, therefore we need to invert.
--- include/net/sch_generic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/sch_generic.h +1 -1
@@ -217,7 +217,7 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)*/ return spin_trylock (&qdisc->seqlock); } -return test_and_set_bit (__QDISC_STATE_RUNNING, &qdisc->state); +return !test_and_set_bit (__QDISC_STATE_RUNNING, &qdisc->state); }static inline void qdisc_run_end (struct Qdisc *qdisc)
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH net-next 1/2] net: sched: fix logic error in qdisc_run_begin()
Quoted 11 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
For non
TCQ_F_NOLOCKqdisc,qdisc_run_begin()tries to set__QDISC_STATE_RUNNINGand should return true if the bit was not set.
test_and_set_bit()returns old bit value, therefore we need to invert.Fixes 29cbcd858283 ("net: sched: Remove Qdisc::running sequence counter")Signed-off-by Eric Dumazet <[email protected]>Cc Ahmed S. Darwish <[email protected]>Cc Sebastian Andrzej Siewior <[email protected]>
Thanks!
Re: [PATCH net-next 1/2] net: sched: fix logic error in qdisc_run_begin()
In reply to Eric DumazetQuoted 11 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
For non
TCQ_F_NOLOCKqdisc,qdisc_run_begin()tries to set__QDISC_STATE_RUNNINGand should return true if the bit was not set.
test_and_set_bit()returns old bit value, therefore we need to invert.Fixes 29cbcd858283 ("net: sched: Remove Qdisc::running sequence counter")Signed-off-by Eric Dumazet <[email protected]>Cc Ahmed S. Darwish <[email protected]>Cc Sebastian Andrzej Siewior <[email protected]>
Sebastian
Re: [PATCH net-next 1/2] net: sched: fix logic error in qdisc_run_begin()
In reply to Eric DumazetQuoted 11 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
For non
TCQ_F_NOLOCKqdisc,qdisc_run_begin()tries to set__QDISC_STATE_RUNNINGand should return true if the bit was not set.
test_and_set_bit()returns old bit value, therefore we need to invert.Fixes 29cbcd858283 ("net: sched: Remove Qdisc::running sequence counter")Signed-off-by Eric Dumazet <[email protected]>Cc Ahmed S. Darwish <[email protected]>Cc Sebastian Andrzej Siewior <[email protected]>
Ah! I had just finished bisecting that lockup on qdisc install and figured I'd check the list before I started investigating further. And indeed you had beaten me to the punch with a fix - thanks! :)
Re: [PATCH net-next 1/2] net: sched: fix logic error in qdisc_run_begin()
In reply to Eric DumazetQuoted 5 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
For non
TCQ_F_NOLOCKqdisc,qdisc_run_begin()tries to set__QDISC_STATE_RUNNINGand should return true if the bit was not set.
Quoted 7 lines
test_and_set_bit()returns old bit value, therefore we need to invert.Fixes 29cbcd858283 ("net: sched: Remove Qdisc::running sequence counter")Signed-off-by Eric Dumazet <[email protected]>Cc Ahmed S. Darwish <[email protected]>Cc Sebastian Andrzej Siewior <[email protected]>---
We've got a warning[0] in today's regression that was added by commit that this patch fixes. I can't reproduce it manually and from changelog it is hard to determine whether the fix is for the issue we experiencing or something else. WDYT?
[0]:
[Wed Oct 20 09:08:06 2021] ------------[ cut here ]------------ [Wed Oct 20 09:08:06 2021] WARNING: CPU: 4 PID: 0 at net/core/gen_stats.c:157 gnet_stats_add_basic+0x1d9/0x240 [Wed Oct 20 09:08:06 2021] Modules linked in: act_vlan cls_flower act_tunnel_key sch_ingress openvswitch nsh mlx5_ib mlx5_core xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink rpcrdma rdma_ucm ib_iser libiscsi scsi_transport_iscsi rdma_cm ib_umad iw_cm ib_ipoib ib_cm xt_addrtype iptable_nat nf_nat br_netfilter ib_uverbs ib_core overlay fuse [last unloaded: mlx5_core] [Wed Oct 20 09:08:06 2021] CPU: 4 PID: 0 Comm: swapper/4 Not tainted 5.15.0-rc6_for_upstream_debug_2021_10_19_17_13 #1 [Wed Oct 20 09:08:06 2021] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [Wed Oct 20 09:08:06 2021] RIP: 0010:gnet_stats_add_basic+0x1d9/0x240 [Wed Oct 20 09:08:06 2021] Code: 25 a0 19 1e 02 0f 82 4a ff ff ff 48 8b 44 24 20 4c 01 28 44 8b 24 24 4c 01 60 08 48 83 c4 28 5b 5d 41 5c 41 5d 41 5e 41 5f c3 <0f> 0b e9 d1 fe ff ff 48 89 df e8 d8 4c 07 ff e9 62 fe ff ff 48 89 [Wed Oct 20 09:08:06 2021] RSP: 0018:ffff8882a4209b80 EFLAGS: 00010206 [Wed Oct 20 09:08:06 2021] RAX: 0000000080000102 RBX: ffff888116bda450 RCX: 0000000000000000 [Wed Oct 20 09:08:06 2021] RDX: ffff888116bda450 RSI: 0000607d5b844340 RDI: ffff8882a4209c90 [Wed Oct 20 09:08:06 2021] RBP: 0000607d5b844340 R08: 0000000000000001 R09: 0000000000000003 [Wed Oct 20 09:08:06 2021] R10: ffffed105484136e R11: 0000000000000001 R12: ffff888122b10608 [Wed Oct 20 09:08:06 2021] R13: ffff888122b10680 R14: ffff888122b10680 R15: ffff888122b10621 [Wed Oct 20 09:08:06 2021] FS: 0000000000000000(0000) GS:ffff8882a4200000(0000) knlGS:0000000000000000 [Wed Oct 20 09:08:06 2021] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [Wed Oct 20 09:08:06 2021] CR2: 0000561dba20e5b8 CR3: 0000000004026003 CR4: 0000000000370ea0 [Wed Oct 20 09:08:06 2021] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [Wed Oct 20 09:08:06 2021] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [Wed Oct 20 09:08:06 2021] Call Trace: [Wed Oct 20 09:08:06 2021] <IRQ> [Wed Oct 20 09:08:06 2021] ? rcu_core+0x642/0x1fd0 [Wed Oct 20 09:08:06 2021] est_fetch_counters+0xc8/0x150 [Wed Oct 20 09:08:06 2021] ? __do_softirq+0x282/0x94e [Wed Oct 20 09:08:06 2021] ? __irq_exit_rcu+0x11f/0x170 [Wed Oct 20 09:08:06 2021] est_timer+0x95/0x6f0 [Wed Oct 20 09:08:06 2021] ? rcu_read_lock_sched_held+0x12/0x70 [Wed Oct 20 09:08:06 2021] ? lock_acquire+0x38d/0x4c0 [Wed Oct 20 09:08:06 2021] ? rcu_read_lock_sched_held+0x12/0x70 [Wed Oct 20 09:08:06 2021] ? lockdep_hardirqs_on_prepare+0x400/0x400 [Wed Oct 20 09:08:06 2021] ? est_fetch_counters+0x150/0x150 [Wed Oct 20 09:08:06 2021] ? lock_release+0x460/0x750 [Wed Oct 20 09:08:06 2021] ? scheduler_tick+0x290/0x860 [Wed Oct 20 09:08:06 2021] ? est_fetch_counters+0x150/0x150 [Wed Oct 20 09:08:06 2021] ? call_timer_fn+0x178/0x490 [Wed Oct 20 09:08:06 2021] call_timer_fn+0x178/0x490 [Wed Oct 20 09:08:06 2021] ? lock_release+0x460/0x750 [Wed Oct 20 09:08:06 2021] ? msleep_interruptible+0x130/0x130 [Wed Oct 20 09:08:07 2021] ? lock_downgrade+0x6e0/0x6e0 [Wed Oct 20 09:08:07 2021] ? __next_timer_interrupt+0xfc/0x200 [Wed Oct 20 09:08:07 2021] ? est_fetch_counters+0x150/0x150 [Wed Oct 20 09:08:07 2021] __run_timers.part.0+0x545/0x890 [Wed Oct 20 09:08:07 2021] ? call_timer_fn+0x490/0x490 [Wed Oct 20 09:08:07 2021] ? lock_downgrade+0x6e0/0x6e0 [Wed Oct 20 09:08:07 2021] ? kvm_clock_get_cycles+0x14/0x20 [Wed Oct 20 09:08:07 2021] ? ktime_get+0xb3/0x180 [Wed Oct 20 09:08:07 2021] ? lapic_next_deadline+0x3c/0x90 [Wed Oct 20 09:08:07 2021] ? clockevents_program_event+0x1dc/0x2f0 [Wed Oct 20 09:08:07 2021] run_timer_softirq+0x6a/0x100 [Wed Oct 20 09:08:07 2021] __do_softirq+0x282/0x94e [Wed Oct 20 09:08:07 2021] __irq_exit_rcu+0x11f/0x170 [Wed Oct 20 09:08:07 2021] irq_exit_rcu+0xa/0x20 [Wed Oct 20 09:08:07 2021] sysvec_apic_timer_interrupt+0x6f/0x90 [Wed Oct 20 09:08:07 2021] </IRQ> [Wed Oct 20 09:08:07 2021] asm_sysvec_apic_timer_interrupt+0x12/0x20 [Wed Oct 20 09:08:07 2021] RIP: 0010:default_idle+0x53/0x70 [Wed Oct 20 09:08:07 2021] Code: c1 83 e0 07 48 c1 e9 03 83 c0 03 0f b6 14 11 38 d0 7c 04 84 d2 75 14 8b 05 3a 9f f4 01 85 c0 7e 07 0f 00 2d 6f a7 4c 00 fb f4 <c3> 48 c7 c7 a0 d5 2c 85 e8 c0 52 57 fe eb de 66 66 2e 0f 1f 84 00 [Wed Oct 20 09:08:07 2021] RSP: 0018:ffff888100c57df8 EFLAGS: 00000246 [Wed Oct 20 09:08:07 2021] RAX: 0000000000000000 RBX: ffff888100c42000 RCX: 1ffffffff0a59ab4 [Wed Oct 20 09:08:07 2021] RDX: 0000000000000004 RSI: 0000000000000004 RDI: ffffffff852cd5a0 [Wed Oct 20 09:08:07 2021] RBP: 0000000000000004 R08: 0000000000000000 R09: 0000000000000003 [Wed Oct 20 09:08:07 2021] R10: fffffbfff0a59ab4 R11: 0000000000000001 R12: ffffed1020188400 [Wed Oct 20 09:08:07 2021] R13: ffffffff84a65440 R14: 0000000000000000 R15: dffffc0000000000 [Wed Oct 20 09:08:07 2021] ? default_idle+0x16/0x70 [Wed Oct 20 09:08:07 2021] default_idle_call+0x8c/0xd0 [Wed Oct 20 09:08:07 2021] do_idle+0x394/0x450 [Wed Oct 20 09:08:07 2021] ? arch_cpu_idle_exit+0x40/0x40 [Wed Oct 20 09:08:07 2021] cpu_startup_entry+0x19/0x20 [Wed Oct 20 09:08:07 2021] start_secondary+0x229/0x2f0 [Wed Oct 20 09:08:07 2021] ? set_cpu_sibling_map+0x1830/0x1830 [Wed Oct 20 09:08:07 2021] secondary_startup_64_no_verify+0xb0/0xbb [Wed Oct 20 09:08:07 2021] irq event stamp: 4163175 [Wed Oct 20 09:08:07 2021] hardirqs last enabled at (4163175): [<ffffffff83383ba4>] default_idle_call+0x54/0xd0 [Wed Oct 20 09:08:07 2021] hardirqs last disabled at (4163174): [<ffffffff813dc286>] do_idle+0x126/0x450 [Wed Oct 20 09:08:07 2021] softirqs last enabled at (4163146): [<ffffffff813491bf>] __irq_exit_rcu+0x11f/0x170 [Wed Oct 20 09:08:07 2021] softirqs last disabled at (4163141): [<ffffffff813491bf>] __irq_exit_rcu+0x11f/0x170 [Wed Oct 20 09:08:07 2021] ---[ end trace 522aedc0980d5e9b ]---
Quoted 16 lines
include/net/sch_generic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/net/sch_generic.h +1
-1@@ -217,7 +217,7 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)*/ return spin_trylock (&qdisc->seqlock); } -return test_and_set_bit (__QDISC_STATE_RUNNING, &qdisc->state); +return !test_and_set_bit (__QDISC_STATE_RUNNING, &qdisc->state); }static inline void qdisc_run_end (struct Qdisc *qdisc)
Re: [PATCH net-next 1/2] net: sched: fix logic error in qdisc_run_begin()
Quoted 4 lines · Vlad Buslov
We've got a warning[0] in today's regression that was added by commit that this patch fixes. I can't reproduce it manually and from changelog it is hard to determine whether the fix is for the issue we experiencing or something else. WDYT?
The backtrace looks like it has been fixed by
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=e22db7bd552f7f7f19fe4ef60abfb7e7b364e3a8
Sorry for that.
Sebastian
Re: [PATCH net-next 1/2] net: sched: fix logic error in qdisc_run_begin()
Quoted 6 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Vlad Buslov
We've got a warning[0] in today's regression that was added by commit that this patch fixes. I can't reproduce it manually and from changelog it is hard to determine whether the fix is for the issue we experiencing or something else. WDYT?
Quoted 6 lines
The backtrace looks like it has been fixed by
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=e22db7bd552f7f7f19fe4ef60abfb7e7b364e3a8Sorry for that.
Sebastian
Thanks! I somehow missed that fix when searching in the mailing list.
PATCH 2/2 net: sched: remove one pair of atomic operations
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
__QDISC_STATE_RUNNING is only set/cleared from contexts owning qdisc lock.
Thus we can use less expensive bit operations, as we were doing
before commit f9eb8aea2a1e ("net_sched: transform qdisc running bit into a seqcount")
--- include/net/sch_generic.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
include/net/sch_generic.h +8 -4
@@ -38,10 +38,13 @@ enum qdisc_state_t { __QDISC_STATE_DEACTIVATED, __QDISC_STATE_MISSED, __QDISC_STATE_DRAINING, +}; + +enum qdisc_state2_t {/* Only for !TCQ_F_NOLOCK qdisc. Never access it directly. * Use qdisc_run_begin/end() or qdisc_is_running() instead. */ - __QDISC_STATE_RUNNING, + __QDISC_STATE2_RUNNING, };#define QDISC_STATE_MISSED BIT(__QDISC_STATE_MISSED)
@@ -114,6 +117,7 @@ struct Qdisc {struct gnet_stats_basic_sync bstats;struct gnet_stats_queue qstats;unsigned long state; +unsigned long state2;/* must be written under qdisc spinlock */ struct Qdisc *next_sched;struct sk_buff_head skb_bad_txq;
@@ -154,7 +158,7 @@ static inline bool qdisc_is_running(struct Qdisc *qdisc) {if (qdisc->flags &TCQ_F_NOLOCK )return spin_is_locked (&qdisc->seqlock); -return test_bit (__QDISC_STATE_RUNNING, &qdisc->state); +return test_bit (__QDISC_STATE2_RUNNING, &qdisc->state2); }static inline bool nolock_qdisc_is_empty (const struct Qdisc *qdisc)
@@ -217,7 +221,7 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)*/ return spin_trylock (&qdisc->seqlock); } -return !test_and_set_bit (__QDISC_STATE_RUNNING, &qdisc->state); +return !__test_and_set_bit (__QDISC_STATE2_RUNNING, &qdisc->state2); }static inline void qdisc_run_end (struct Qdisc *qdisc)
@@ -229,7 +233,7 @@ static inline void qdisc_run_end(struct Qdisc *qdisc) &qdisc->state)))__netif_schedule (qdisc); }else { -clear_bit (__QDISC_STATE_RUNNING, &qdisc->state); +__clear_bit (__QDISC_STATE2_RUNNING, &qdisc->state2); } }
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH net-next 2/2] net: sched: remove one pair of atomic operations
Quoted 11 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
__QDISC_STATE_RUNNINGis only set/cleared from contexts owning qdisc lock.Thus we can use less expensive bit operations, as we were doing
before commitf9eb8aea2a1e("net_sched: transform qdisc running bit into a seqcount")Fixes 29cbcd858283 ("net: sched: Remove Qdisc::running sequence counter")Signed-off-by Eric Dumazet <[email protected]>Cc Ahmed S. Darwish <[email protected]>Cc Sebastian Andrzej Siewior <[email protected]>
Sebastian
Re: [PATCH net-next 2/2] net: sched: remove one pair of atomic operations
In reply to Eric DumazetQuoted 11 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
__QDISC_STATE_RUNNINGis only set/cleared from contexts owning qdisc lock.Thus we can use less expensive bit operations, as we were doing
before commitf9eb8aea2a1e("net_sched: transform qdisc running bit into a seqcount")Fixes 29cbcd858283 ("net: sched: Remove Qdisc::running sequence counter")Signed-off-by Eric Dumazet <[email protected]>Cc Ahmed S. Darwish <[email protected]>Cc Sebastian Andrzej Siewior <[email protected]>
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Mon, 18 Oct 2021 17:34:00 -0700 you wrote:
From: Eric Dumazet <[email protected]>
First patch fixes a plain bug in
qdisc_run_begin().
Second patch removes a pair of atomic operations, increasing performance.Eric Dumazet (2):
net: sched: fix logic error inqdisc_run_begin()
net: sched: remove one pair of atomic operations[...]
Here is the summary with links:
- [net-next,1/2] net: sched: fix logic error in qdisc_run_begin()
https://git.kernel.org/netdev/net-next/c/4c57e2fac41c - [net-next,2/2] net: sched: remove one pair of atomic operations https://git.kernel.org/netdev/net-next/c/97604c65bcda
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html