* [PATCHv2 net] net: thunderx: use spin_lock_bh in nicvf_set_rx_mode_task()
@ 2020-08-04 7:02 Xin Long
2020-08-04 20:04 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Xin Long @ 2020-08-04 7:02 UTC (permalink / raw)
To: network dev
Cc: Sunil Goutham, Robert Richter, dnelson, Paolo Abeni, davem,
linux-arm-kernel
A dead lock was triggered on thunderx driver:
CPU0 CPU1
---- ----
[01] lock(&(&nic->rx_mode_wq_lock)->rlock);
[11] lock(&(&mc->mca_lock)->rlock);
[12] lock(&(&nic->rx_mode_wq_lock)->rlock);
[02] <Interrupt> lock(&(&mc->mca_lock)->rlock);
The path for each is:
[01] worker_thread() -> process_one_work() -> nicvf_set_rx_mode_task()
[02] mld_ifc_timer_expire()
[11] ipv6_add_dev() -> ipv6_dev_mc_inc() -> igmp6_group_added() ->
[12] dev_mc_add() -> __dev_set_rx_mode() -> nicvf_set_rx_mode()
To fix it, it needs to disable bh on [1], so that the timer on [2]
wouldn't be triggered until rx_mode_wq_lock is released. So change
to use spin_lock_bh() instead of spin_lock().
Thanks to Paolo for helping with this.
v1->v2:
- post to netdev.
Reported-by: Rafael P. <rparrazo@redhat.com>
Tested-by: Dean Nelson <dnelson@redhat.com>
Fixes: 469998c861fa ("net: thunderx: prevent concurrent data re-writing by nicvf_set_rx_mode")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 2ba0ce1..a82c708 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -2042,11 +2042,11 @@ static void nicvf_set_rx_mode_task(struct work_struct *work_arg)
/* Save message data locally to prevent them from
* being overwritten by next ndo_set_rx_mode call().
*/
- spin_lock(&nic->rx_mode_wq_lock);
+ spin_lock_bh(&nic->rx_mode_wq_lock);
mode = vf_work->mode;
mc = vf_work->mc;
vf_work->mc = NULL;
- spin_unlock(&nic->rx_mode_wq_lock);
+ spin_unlock_bh(&nic->rx_mode_wq_lock);
__nicvf_set_rx_mode_task(mode, mc, nic);
}
--
2.1.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2 net] net: thunderx: use spin_lock_bh in nicvf_set_rx_mode_task()
2020-08-04 7:02 [PATCHv2 net] net: thunderx: use spin_lock_bh in nicvf_set_rx_mode_task() Xin Long
@ 2020-08-04 20:04 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-08-04 20:04 UTC (permalink / raw)
To: lucien.xin; +Cc: sgoutham, rric, netdev, dnelson, pabeni, linux-arm-kernel
From: Xin Long <lucien.xin@gmail.com>
Date: Tue, 4 Aug 2020 15:02:30 +0800
> A dead lock was triggered on thunderx driver:
>
> CPU0 CPU1
> ---- ----
> [01] lock(&(&nic->rx_mode_wq_lock)->rlock);
> [11] lock(&(&mc->mca_lock)->rlock);
> [12] lock(&(&nic->rx_mode_wq_lock)->rlock);
> [02] <Interrupt> lock(&(&mc->mca_lock)->rlock);
>
> The path for each is:
>
> [01] worker_thread() -> process_one_work() -> nicvf_set_rx_mode_task()
> [02] mld_ifc_timer_expire()
> [11] ipv6_add_dev() -> ipv6_dev_mc_inc() -> igmp6_group_added() ->
> [12] dev_mc_add() -> __dev_set_rx_mode() -> nicvf_set_rx_mode()
>
> To fix it, it needs to disable bh on [1], so that the timer on [2]
> wouldn't be triggered until rx_mode_wq_lock is released. So change
> to use spin_lock_bh() instead of spin_lock().
>
> Thanks to Paolo for helping with this.
>
> v1->v2:
> - post to netdev.
>
> Reported-by: Rafael P. <rparrazo@redhat.com>
> Tested-by: Dean Nelson <dnelson@redhat.com>
> Fixes: 469998c861fa ("net: thunderx: prevent concurrent data re-writing by nicvf_set_rx_mode")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Applied and queued up for -stable, thank you.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-04 20:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 7:02 [PATCHv2 net] net: thunderx: use spin_lock_bh in nicvf_set_rx_mode_task() Xin Long
2020-08-04 20:04 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).