Skip to contentSkip to conversation

idpf: disable local BH when scheduling napi for marker packets

PATCH In review Alan Brady 6 participants 10 messages Feb 8, 2024 – Mar 5, 2024

Subsystems (3)
lore
Share & tools
lore

Alan Brady

author
#0 lore raw

PATCH 1/1 idpf: disable local BH when scheduling napi for marker packets

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

The issue can be seen on ifdown:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!

Using ftrace to catch the failing scenario:
ifconfig [003] d.... 22739.830624: softirq_raise: vec=3 [action=NET_RX]
<idle>-0 [003] ..s.. 22739.831357: softirq_entry: vec=3 [action=NET_RX]

No interrupt and CPU is idle.

After the patch, with BH locks:
ifconfig [003] d.... 22993.928336: softirq_raise: vec=3 [action=NET_RX]
ifconfig [003] ..s1. 22993.928337: softirq_entry: vec=3 [action=NET_RX]

Fixes c2d548cad150 ("idpf: add TX splitq napi poll support")
---
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +2 -0
index d0cdd63b3d5b..390977a76de2 100644
@@ -2087,8 +2087,10 @@ int idpf_send_disable_queues_msg(struct idpf_vport *vport)
 		set_bit(__IDPF_Q_POLL_MODE, vport->txqs[i]->flags);
 
 	/* schedule the napi to receive all the marker packets */
+	local_bh_disable();
 	for (i = 0; i < vport->num_q_vectors; i++)
 		napi_schedule(&vport->q_vectors[i].napi);
+	local_bh_enable();
 
 	return idpf_wait_for_marker_event(vport);
 }
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Alan Brady

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

The issue can be seen on ifdown:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!

Using ftrace to catch the failing scenario:
ifconfig [003] d.... 22739.830624: softirq_raise: vec=3 [action=NET_RX]
<idle>-0 [003] ..s.. 22739.831357: softirq_entry: vec=3 [action=NET_RX]

No interrupt and CPU is idle.

After the patch, with BH locks:
ifconfig [003] d.... 22993.928336: softirq_raise: vec=3 [action=NET_RX]
ifconfig [003] ..s1. 22993.928337: softirq_entry: vec=3 [action=NET_RX]

Quoted 5 lines
Fixes c2d548cad150 ("idpf: add TX splitq napi poll support")
#2 lore raw
In reply to Alan Brady

From: Alan Brady <[email protected]>
Date: Wed, 7 Feb 2024 16:42:43 -0800

Quoted 9 lines

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

The issue can be seen on ifdown:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!

Quoted 7 lines

Using ftrace to catch the failing scenario:
ifconfig [003] d.... 22739.830624: softirq_raise: vec=3 [action=NET_RX]
<idle>-0 [003] ..s.. 22739.831357: softirq_entry: vec=3 [action=NET_RX]

No interrupt and CPU is idle.

After the patch, with BH locks:

Minor: local_bh_{en,dis}able() are not "BH locks", it's BH enabling/disabling. It doesn't lock/unlock anything.

Quoted 8 lines

ifconfig [003] d.... 22993.928336: softirq_raise: vec=3 [action=NET_RX]
ifconfig [003] ..s1. 22993.928337: softirq_entry: vec=3 [action=NET_RX]

Fixes c2d548cad150 ("idpf: add TX splitq napi poll support")

Thanks,
Olek

#3 lore raw
Quoted 16 lines · Alexander Lobakin

From: Alan Brady <[email protected]>
Date: Wed, 7 Feb 2024 16:42:43 -0800

Quoted 13 lines

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

The issue can be seen on ifdown:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!

Using ftrace to catch the failing scenario:
ifconfig [003] d.... 22739.830624: softirq_raise: vec=3 [action=NET_RX]
<idle>-0 [003] ..s.. 22739.831357: softirq_entry: vec=3 [action=NET_RX]

Quoted 6 lines
Quoted 3 lines

No interrupt and CPU is idle.

After the patch, with BH locks:

Minor: local_bh_{en,dis}able() are not "BH locks", it's BH enabling/disabling. It doesn't lock/unlock anything.

Good catch, we can change it to:
"After the patch when disabling local BH before calling napi_schedule:"

Quoted 4 lines
Quoted 4 lines

ifconfig [003] d.... 22993.928336: softirq_raise: vec=3 [action=NET_RX]
ifconfig [003] ..s1. 22993.928337: softirq_entry: vec=3 [action=NET_RX]

Quoted 8 lines
Quoted 5 lines
Fixes c2d548cad150 ("idpf: add TX splitq napi poll support")

Thanks,
Olek

Thanks,
Emil

#4 lore raw
In reply to Alan Brady

From: Alan Brady <[email protected]>
Date: Wed, 7 Feb 2024 16:42:43 -0800

Quoted 5 lines

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

BTW, how exactly does this help?

__napi_schedule() already disables interrupts (local_irq_save()). napi_schedule_prep() only has READ_ONCE() and other atomic read/write helpers.

It's always been safe to call napi_schedule() with enabled BH, so I don't really understand how this works.

Quoted 28 lines

The issue can be seen on ifdown:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!

Using ftrace to catch the failing scenario:
ifconfig [003] d.... 22739.830624: softirq_raise: vec=3 [action=NET_RX]
<idle>-0 [003] ..s.. 22739.831357: softirq_entry: vec=3 [action=NET_RX]

No interrupt and CPU is idle.

After the patch, with BH locks:
ifconfig [003] d.... 22993.928336: softirq_raise: vec=3 [action=NET_RX]
ifconfig [003] ..s1. 22993.928337: softirq_entry: vec=3 [action=NET_RX]

Fixes c2d548cad150 ("idpf: add TX splitq napi poll support")
---
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0 -0
index d0cdd63b3d5b..390977a76de2 100644

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c int idpf_send_disable_queues_msg(struct idpf_vport *vport) · line 2096

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +2 -0
@@ -2087,8 +2087,10 @@ int idpf_send_disable_queues_msg(struct idpf_vport *vport)
 		set_bit(__IDPF_Q_POLL_MODE, vport->txqs[i]->flags);
 
 	/* schedule the napi to receive all the marker packets */
+	local_bh_disable();
 	for (i = 0; i < vport->num_q_vectors; i++)
 		napi_schedule(&vport->q_vectors[i].napi);
+	local_bh_enable();
 
 	return idpf_wait_for_marker_event(vport);
 }

Thanks,
Olek

#5 lore raw

From: Alexander Lobakin <[email protected]>
Date: Tue, 13 Feb 2024 14:16:47 +0100

Quoted 9 lines

From: Alan Brady <[email protected]>
Date: Wed, 7 Feb 2024 16:42:43 -0800

Quoted 5 lines

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

Quoted 8 lines

BTW, how exactly does this help?

__napi_schedule() already disables interrupts (local_irq_save()). napi_schedule_prep() only has READ_ONCE() and other atomic read/write helpers.

It's always been safe to call napi_schedule() with enabled BH, so I don't really understand how this works.

This also needs to be dropped from the fixes queue until investigated. For now, it looks like a cheap hack (without the explanation how exactly it does help), not a proper fix.

Thanks,
Olek

#6 lore raw
Quoted 20 lines · Alexander Lobakin

From: Alexander Lobakin <[email protected]>
Date: Tue, 13 Feb 2024 14:16:47 +0100

Quoted 17 lines

From: Alan Brady <[email protected]>
Date: Wed, 7 Feb 2024 16:42:43 -0800

Quoted 5 lines

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

BTW, how exactly does this help?

__napi_schedule() already disables interrupts (local_irq_save()). napi_schedule_prep() only has READ_ONCE() and other atomic read/write helpers.

It's always been safe to call napi_schedule() with enabled BH, so I don't really understand how this works.

It's been a while since I debugged this, I'll have to take a look again, but its not so much about being safe as it is about making sure the marker packets are received in those cases - like ifdown in the trace.

Quoted 3 lines

This also needs to be dropped from the fixes queue until investigated. For now, it looks like a cheap hack (without the explanation how exactly it does help), not a proper fix.

It does fix the issue at hand. Looking at the kernel code I see multiple examples of napi_schedule() being wrapped with local_bh_disable/enable, so this appears to be a common (not uncommon?) technique.

Thanks,
Emil

Quoted 3 lines

Thanks,
Olek

#7 lore raw

From: Tantilov, Emil S <[email protected]>
Date: Wed, 14 Feb 2024 07:39:53 -0800

Quoted 28 lines · Alexander Lobakin
Quoted 20 lines

From: Alexander Lobakin <[email protected]>
Date: Tue, 13 Feb 2024 14:16:47 +0100

Quoted 17 lines

From: Alan Brady <[email protected]>
Date: Wed,  7 Feb 2024 16:42:43 -0800

Quoted 5 lines

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

BTW, how exactly does this help?

__napi_schedule() already disables interrupts (local_irq_save()). napi_schedule_prep() only has READ_ONCE() and other atomic read/write helpers.

It's always been safe to call napi_schedule() with enabled BH, so I don't really understand how this works.

It's been a while since I debugged this, I'll have to take a look again, but its not so much about being safe as it is about making sure the marker packets are received in those cases - like ifdown in the trace.

Quoted 5 lines
Quoted 3 lines

This also needs to be dropped from the fixes queue until investigated. For now, it looks like a cheap hack (without the explanation how exactly it does help), not a proper fix.

It does fix the issue at hand. Looking at the kernel code I see multiple

Sometimes adding debug prints fixes bugs, fixing something doesn't mean it's the correct way.

Quoted 1 line

examples of napi_schedule() being wrapped with local_bh_disable/enable,

"Everybody do that" doesn't prove anything until explained how exactly this helps.

Quoted 8 lines

so this appears to be a common (not uncommon?) technique.

Thanks,
Emil

Quoted 3 lines

Thanks,
Olek

Thanks,
Olek

maintainer
#8 lore raw
In reply to Alexander Lobakin
Quoted 4 lines · On Tue, 13 Feb 2024 14:16:47 +0100 Alexander Lobakin wrote:
Quoted 3 lines

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

Quoted 8 lines

BTW, how exactly does this help?

__napi_schedule() already disables interrupts (local_irq_save()). napi_schedule_prep() only has READ_ONCE() and other atomic read/write helpers.

It's always been safe to call napi_schedule() with enabled BH, so I don't really understand how this works.

Sorry for late reply. IIRC the problem isn't a race but the fact that local_irq_restore() does not have a hook for BH. IOW we may just set the bit that the BH is pending but never call into softirq.c to run it.

Tested-by on v1 1/1
#9 lore raw
In reply to Alan Brady

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Quoted 43 lines

-----Original Message-----
From: Alan Brady <[email protected]>
Sent: Wednesday, February 7, 2024 4:43 PM
To: [email protected]
Cc: [email protected]; Tantilov, Emil S <[email protected]>; Brandeburg, Jesse <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Brady, Alan <[email protected]>
Subject: [PATCH 1/1 iwl-net] idpf: disable local BH when scheduling napi for marker packets

From: Emil Tantilov <[email protected]>

Fix softirq's not being handled during napi_schedule() call when receiving marker packets for queue disable by disabling local bottom half.

The issue can be seen on ifdown:
NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!

Using ftrace to catch the failing scenario:
ifconfig [003] d.... 22739.830624: softirq_raise: vec=3 [action=NET_RX]
<idle>-0 [003] ..s.. 22739.831357: softirq_entry: vec=3 [action=NET_RX]

No interrupt and CPU is idle.

After the patch, with BH locks:
ifconfig [003] d.... 22993.928336: softirq_raise: vec=3 [action=NET_RX]
ifconfig [003] ..s1. 22993.928337: softirq_entry: vec=3 [action=NET_RX]

Fixes c2d548cad150 ("idpf: add TX splitq napi poll support")
---
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0 -0
index d0cdd63b3d5b..390977a76de2 100644