net: hns: Ensure that interface teardown cannot race with TX interrupt
Subsystems (3)
PATCH 1/1 net: hns: Ensure that interface teardown cannot race with TX interrupt
On a lockdep-enabled kernel, bringing down a HNS interface results in a loud splat. It turns out that the per-ring spinlock is taken both in the TX interrupt path, and when bringing down the interface.
Lockdep sums it up with:
[32099.424453] CPU0 [32099.426885] ---- [32099.429318] lock(&(&ring->lock)->rlock); [32099.433402] <Interrupt> [32099.436008] lock(&(&ring->lock)->rlock); [32099.440264] [32099.440264] *** DEADLOCK ***
To solve this, turn the NETIF_TX_{LOCK,UNLOCK} macros from standard spin_[un]lock to their irqsave/irqrestore version.
--- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/net/ethernet/hisilicon/hns/hns_enet.c +12 -10
@@ -945,11 +945,11 @@ static int is_valid_clean_head(struct hnae_ring *ring, int h)/* netif_tx_lock will turn down the performance, set only when necessary */ #ifdef CONFIG_NET_POLL_CONTROLLER -#define NETIF_TX_LOCK (ring) spin_lock(&(ring)->lock) -#define NETIF_TX_UNLOCK (ring) spin_unlock(&(ring)->lock) +#define NETIF_TX_LOCK (ring, flags) spin_lock_irqsave(&(ring)->lock, flags) +#define NETIF_TX_UNLOCK (ring, flags) spin_unlock_irqrestore(&(ring)->lock, flags)#else -#define NETIF_TX_LOCK (ring) -#define NETIF_TX_UNLOCK (ring) +#define NETIF_TX_LOCK (ring, flags) +#define NETIF_TX_UNLOCK (ring, flags)#endif /* reclaim all desc in one budget
@@ -962,16 +962,17 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,struct net_device *ndev = ring_data->napi.dev;struct netdev_queue *dev_queue;struct hns_nic_priv *priv =netdev_priv (ndev); +unsigned long flags;int head;int bytes, pkts; -NETIF_TX_LOCK (ring); +NETIF_TX_LOCK (ring, flags); head =readl_relaxed (ring->io_base +RCB_REG_HEAD );rmb ();/* make sure head is ready before touch any data */ if (is_ring_empty (ring) || head == ring->next_to_clean) { -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags);return 0 ;/* no data to poll */ }
@@ -979,7 +980,7 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,netdev_err (ndev,"wrong head (%d, %d-%d)\n" , head, ring->next_to_use, ring->next_to_clean); ring->stats.io_err_cnt++; -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags);return -EIO ; }
@@ -994,7 +995,7 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, ring->stats.tx_pkts += pkts; ring->stats.tx_bytes += bytes; -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags); dev_queue =netdev_get_tx_queue (ndev, ring_data->queue_index);netdev_tx_completed_queue (dev_queue, pkts, bytes);
@@ -1052,10 +1053,11 @@ static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data)struct hnae_ring *ring = ring_data->ring;struct net_device *ndev = ring_data->napi.dev;struct netdev_queue *dev_queue; +unsigned long flags;int head;int bytes, pkts; -NETIF_TX_LOCK (ring); +NETIF_TX_LOCK (ring, flags); head = ring->next_to_use;/* ntu :soft setted ring position*/ bytes =0 ;
@@ -1063,7 +1065,7 @@ static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data)while (head != ring->next_to_clean)hns_nic_reclaim_one_desc (ring, &bytes, &pkts); -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags); dev_queue =netdev_get_tx_queue (ndev, ring_data->queue_index);netdev_tx_reset_queue (dev_queue);
Signature · 1 line
2.20.1
Hi Marc,
Thanks for the catch & the patch. As such Looks good to me. For the sanity check, I will try to reproduce the problem again and test it once with your patch.
Best Regards
Salil
Quoted 126 lines
From: Marc Zyngier [mailto:[email protected]]
Sent: Monday, November 4, 2019 7:56 PM
To: [email protected]
Cc: lipeng (Y) <[email protected]>; Zhuangyuzeng (Yisen) <[email protected]>; Salil Mehta <[email protected]>; David S . Miller <[email protected]>
Subject: [PATCH] net: hns: Ensure that interface teardown cannot race with TX interruptOn a lockdep-enabled kernel, bringing down a HNS interface results in a loud splat. It turns out that the per-ring spinlock is taken both in the TX interrupt path, and when bringing down the interface.
Lockdep sums it up with:
[32099.424453] CPU0 [32099.426885] ---- [32099.429318] lock(&(&ring->lock)->rlock); [32099.433402] <Interrupt> [32099.436008] lock(&(&ring->lock)->rlock); [32099.440264] [32099.440264] *** DEADLOCK ***To solve this, turn the NETIF_TX_{LOCK,UNLOCK} macros from standard spin_[un]lock to their irqsave/irqrestore version.
Fixes f2aaed557ecff ("net: hns: Replace netif_tx_lock to ring spin lock")Cc lipeng <[email protected]>Cc Yisen Zhuang <[email protected]>Cc Salil Mehta <[email protected]>Cc David S. Miller <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-)drivers/net/ethernet/hisilicon/hns/hns_enet.c +4
-4@@ -945,11 +945,11 @@ static int is_valid_clean_head(struct hnae_ring *ring, int h)/* netif_tx_lock will turn down the performance, set only when necessary */ #ifdef CONFIG_NET_POLL_CONTROLLER -#define NETIF_TX_LOCK (ring) spin_lock(&(ring)->lock) -#define NETIF_TX_UNLOCK (ring) spin_unlock(&(ring)->lock) +#define NETIF_TX_LOCK (ring, flags) spin_lock_irqsave(&(ring)->lock, flags) +#define NETIF_TX_UNLOCK (ring, flags) spin_unlock_irqrestore(&(ring)->lock, flags)#else -#define NETIF_TX_LOCK (ring) -#define NETIF_TX_UNLOCK (ring) +#define NETIF_TX_LOCK (ring, flags) +#define NETIF_TX_UNLOCK (ring, flags)#endif /* reclaim all desc in one budget
drivers/net/ethernet/hisilicon/hns/hns_enet.c +5
-4@@ -962,16 +962,17 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, struct net_device *ndev = ring_data->napi.dev;struct netdev_queue *dev_queue;struct hns_nic_priv *priv =netdev_priv (ndev); +unsigned long flags;int head;int bytes, pkts; -NETIF_TX_LOCK (ring); +NETIF_TX_LOCK (ring, flags); head =readl_relaxed (ring->io_base +RCB_REG_HEAD );rmb ();/* make sure head is ready before touch any data */ if (is_ring_empty (ring) || head == ring->next_to_clean) { -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags);return 0 ;/* no data to poll */ }@@ -979,7 +980,7 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,netdev_err (ndev,"wrong head (%d, %d-%d)\n" , head, ring->next_to_use, ring->next_to_clean); ring->stats.io_err_cnt++; -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags);return -EIO ; }@@ -994,7 +995,7 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, ring->stats.tx_pkts += pkts; ring->stats.tx_bytes += bytes; -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags); dev_queue =netdev_get_tx_queue (ndev, ring_data->queue_index);drivers/net/ethernet/hisilicon/hns/hns_enet.c +2
-1netdev_tx_completed_queue (dev_queue, pkts, bytes);@@ -1052,10 +1053,11 @@ static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data)struct hnae_ring *ring = ring_data->ring;struct net_device *ndev = ring_data->napi.dev;struct netdev_queue *dev_queue; +unsigned long flags;int head;int bytes, pkts; -NETIF_TX_LOCK (ring); +NETIF_TX_LOCK (ring, flags); head = ring->next_to_use;/* ntu :soft setted ring position*/ drivers/net/ethernet/hisilicon/hns/hns_enet.c +1
-1bytes =0 ;@@ -1063,7 +1065,7 @@ static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data)while (head != ring->next_to_clean)hns_nic_reclaim_one_desc (ring, &bytes, &pkts); -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags); dev_queue =netdev_get_tx_queue (ndev, ring_data->queue_index);
netdev_tx_reset_queue(dev_queue);
--
2.20.1
Hi Marc,
I tested with the patch on D05 with the lockdep enabled kernel with below options and I could not reproduce the deadlock. I do not argue the issue being mentioned as this looks to be a clear bug which should hit while TX data-path is running and we try to disable the interface.
Could you please help me know the exact set of steps you used to get into this problem. Also, are you able to re-create it easily/frequently?
# Kernel Config options:CONFIG_LOCKDEP_SUPPORT=yCONFIG_LOCKDEP=y
Thanks
Salil.
Quoted 143 lines
From: Salil Mehta
Sent: Tuesday, November 5, 2019 9:15 AM
To: 'Marc Zyngier' <[email protected]>; [email protected]
Cc: lipeng (Y) <[email protected]>; Zhuangyuzeng (Yisen) <[email protected]>; David S . Miller <[email protected]>
Subject: RE: [PATCH] net: hns: Ensure that interface teardown cannot race with TX interruptHi Marc,
Thanks for the catch & the patch. As such Looks good to me. For the sanity check, I will try to reproduce the problem again and test it once with your patch.Best Regards
SalilQuoted 126 lines
From: Marc Zyngier [mailto:[email protected]]
Sent: Monday, November 4, 2019 7:56 PM
To: [email protected]
Cc: lipeng (Y) <[email protected]>; Zhuangyuzeng (Yisen) <[email protected]>; Salil Mehta <[email protected]>; David S . Miller <[email protected]>
Subject: [PATCH] net: hns: Ensure that interface teardown cannot race with> TX interruptOn a lockdep-enabled kernel, bringing down a HNS interface results in a loud splat. It turns out that the per-ring spinlock is taken both in the TX interrupt path, and when bringing down the interface.
Lockdep sums it up with:
[32099.424453] CPU0 [32099.426885] ---- [32099.429318] lock(&(&ring->lock)->rlock); [32099.433402] <Interrupt> [32099.436008] lock(&(&ring->lock)->rlock); [32099.440264] [32099.440264] *** DEADLOCK ***To solve this, turn the NETIF_TX_{LOCK,UNLOCK} macros from standard spin_[un]lock to their irqsave/irqrestore version.
Fixes f2aaed557ecff ("net: hns: Replace netif_tx_lock to ring spin lock")Cc lipeng <[email protected]>Cc Yisen Zhuang <[email protected]>Cc Salil Mehta <[email protected]>Cc David S. Miller <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-)drivers/net/ethernet/hisilicon/hns/hns_enet.c +4
-4@@ -945,11 +945,11 @@ static int is_valid_clean_head(struct hnae_ring *ring, int h)/* netif_tx_lock will turn down the performance, set only when necessary */ #ifdef CONFIG_NET_POLL_CONTROLLER -#define NETIF_TX_LOCK (ring) spin_lock(&(ring)->lock) -#define NETIF_TX_UNLOCK (ring) spin_unlock(&(ring)->lock) +#define NETIF_TX_LOCK (ring, flags) spin_lock_irqsave(&(ring)->lock, flags) +#define NETIF_TX_UNLOCK (ring, flags) spin_unlock_irqrestore(&(ring)->lock, flags)#else -#define NETIF_TX_LOCK (ring) -#define NETIF_TX_UNLOCK (ring) +#define NETIF_TX_LOCK (ring, flags) +#define NETIF_TX_UNLOCK (ring, flags)#endif /* reclaim all desc in one budget
drivers/net/ethernet/hisilicon/hns/hns_enet.c +5
-4@@ -962,16 +962,17 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, struct net_device *ndev = ring_data->napi.dev;struct netdev_queue *dev_queue;struct hns_nic_priv *priv =netdev_priv (ndev); +unsigned long flags;int head;int bytes, pkts; -NETIF_TX_LOCK (ring); +NETIF_TX_LOCK (ring, flags); head =readl_relaxed (ring->io_base +RCB_REG_HEAD );rmb ();/* make sure head is ready before touch any data */ if (is_ring_empty (ring) || head == ring->next_to_clean) { -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags);return 0 ;/* no data to poll */ }@@ -979,7 +980,7 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,netdev_err (ndev,"wrong head (%d, %d-%d)\n" , head, ring->next_to_use, ring->next_to_clean); ring->stats.io_err_cnt++; -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags);return -EIO ; }@@ -994,7 +995,7 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, ring->stats.tx_pkts += pkts; ring->stats.tx_bytes += bytes; -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags); dev_queue =netdev_get_tx_queue (ndev, ring_data->queue_index);drivers/net/ethernet/hisilicon/hns/hns_enet.c +2
-1netdev_tx_completed_queue (dev_queue, pkts, bytes);@@ -1052,10 +1053,11 @@ static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data)struct hnae_ring *ring = ring_data->ring;struct net_device *ndev = ring_data->napi.dev;struct netdev_queue *dev_queue; +unsigned long flags;int head;int bytes, pkts; -NETIF_TX_LOCK (ring); +NETIF_TX_LOCK (ring, flags); head = ring->next_to_use;/* ntu :soft setted ring position*/ drivers/net/ethernet/hisilicon/hns/hns_enet.c +1
-1bytes =0 ;@@ -1063,7 +1065,7 @@ static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data)while (head != ring->next_to_clean)hns_nic_reclaim_one_desc (ring, &bytes, &pkts); -NETIF_TX_UNLOCK (ring); +NETIF_TX_UNLOCK (ring, flags); dev_queue =netdev_get_tx_queue (ndev, ring_data->queue_index);
netdev_tx_reset_queue(dev_queue);
--
2.20.1
On Tue, 5 Nov 2019 18:41:11 +0000
Salil Mehta <[email protected]> wrote:
Hi Salil,
Quoted 5 lines
Hi Marc,
I tested with the patch on D05 with the lockdep enabled kernel with below options and I could not reproduce the deadlock. I do not argue the issue being mentioned as this looks to be a clear bug which should hit while TX data-path is running and we try to disable the interface.
Lockdep screaming at you doesn't mean the deadly scenario happens in practice, and I've never seen the machine hanging in these conditions. But I've also never tried to trigger it in anger.
Quoted 2 lines
Could you please help me know the exact set of steps you used to get into this problem. Also, are you able to re-create it easily/frequently?
I just need to issue "reboot" (which calls "ip link ... down") for this to trigger. Here's a full splat[1], as well as my full config[2]. It is 100% repeatable.
Quoted 3 lines
# Kernel Config options:
CONFIG_LOCKDEP_SUPPORT=yCONFIG_LOCKDEP=y
You'll need at least
CONFIG_PROVE_LOCKING=yCONFIG_NET_POLL_CONTROLLER=y
in order to hit it.
Thanks,
M.
[1] https://paste.debian.net/1114451/
[2] https://paste.debian.net/1114472/
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 3 lines
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, November 6, 2019 8:18 AM
To: Salil Mehta <[email protected]>
Hi Marc,
Quoted 22 lines
On Tue, 5 Nov 2019 18:41:11 +0000
Salil Mehta <[email protected]> wrote:Hi Salil,
Quoted 5 lines
Hi Marc,
I tested with the patch on D05 with the lockdep enabled kernel with below options and I could not reproduce the deadlock. I do not argue the issue being mentioned as this looks to be a clear bug which should hit while TX data-path is running and we try to disable the interface.Lockdep screaming at you doesn't mean the deadly scenario happens in practice, and I've never seen the machine hanging in these conditions. But I've also never tried to trigger it in anger.
Quoted 2 lines
Could you please help me know the exact set of steps you used to get into this problem. Also, are you able to re-create it easily/frequently?
I just need to issue "reboot" (which calls "ip link ... down") for this to trigger. Here's a full splat[1], as well as my full config[2]. It is 100% repeatable.
Quoted 8 lines
Quoted 3 lines
# Kernel Config options:
CONFIG_LOCKDEP_SUPPORT=yCONFIG_LOCKDEP=yYou'll need at least
CONFIG_PROVE_LOCKING=yCONFIG_NET_POLL_CONTROLLER=y
Few points:
1. To me netpoll causing spinlock deadlock with IRQ leg of TX and ip util is highly unlikely since netpoll runs with both RX/TX interrupts disabled. It runs in polling mode to facilitate parallel path to features like Netconsole, netdump etc. hence, deadlock because of the netpoll should be highly unlikely. Therefore, smells of some other problem here...
2. Also, I remember patch[s1][s2] from Eric Dumazet to disable netpoll on many NICs way back in 4.19 kernel on the basis of Song Liu's findings.
Problem:
Aah, I see the problem now, it is because of the stray code related to the NET_POLL_CONTROLLER in hns driver which actually should have got remove within the patch[s1], and that also explains why it does not get hit while NET POLL is disabled.
/* netif_tx_lock will turn down the performance, set only when necessary */ #ifdef CONFIG_NET_POLL_CONTROLLER
#define NETIF_TX_LOCK(ring) spin_lock(&(ring)->lock)
#define NETIF_TX_UNLOCK(ring) spin_unlock(&(ring)->lock)
#else
#define NETIF_TX_LOCK(ring)
#define NETIF_TX_UNLOCK(ring)
#endif
Once you define CONFIG_NET_POLL_CONTROLLER in the latest code these macros Kick-in even for the normal NAPI path. Which can cause deadlock and that perhaps is what you are seeing?
Now, the question is do we require these locks in normal NAPI poll? I do not see that we need them anymore as Tasklets are serialized to themselves and configuration path like "ip <intf> down" cannot conflict with NAPI poll path as the later is always disabled prior performing interface down operation. Hence, no conflict there.
As a side analysis, I could figure out some contentions in the configuration path not related to this though. :)
Suggested Solution:
Since we do not have support of NET_POLL_CONTROLLER macros NETIF_TX_[UN]LOCK We should remove these NET_POLL_CONTROLLER macros altogether for now.
Though, I still have not looked comprehensively how other are able to use Debugging utils like netconsole etc without having NET_POLL_CONTROLLER. Maybe @Eric Dumazet might give us some insight on this?
If you agree with this then I can send a patch to remove these from hns driver. This should solve your problem as well?
[S1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4bd2c03be7
[S2] https://lkml.org/lkml/2018/10/4/32
Quoted 11 lines
in order to hit it.
Thanks,
M.[1] https://paste.debian.net/1114451/
[2] https://paste.debian.net/1114472/
--
Jazz is not dead. It just smells funny...
Quoted 70 lines · Salil Mehta
Hi Marc,
Quoted 26 lines
On Tue, 5 Nov 2019 18:41:11 +0000
Salil Mehta <[email protected]> wrote:Hi Salil,
Quoted 2 lines
Hi Marc,
I tested with the patch on D05 with the lockdep enabled kernelwith below options
Quoted 1 line
and I could not reproduce the deadlock. I do not argue the issue
being mentioned
Quoted 1 line
as this looks to be a clear bug which should hit while TX
data-path is running
Quoted 1 line
and we try to disable the interface.
Lockdep screaming at you doesn't mean the deadly scenario happens in practice, and I've never seen the machine hanging in these conditions. But I've also never tried to trigger it in anger.
Quoted 1 line
Could you please help me know the exact set of steps you used to
get into this
Quoted 1 line
problem. Also, are you able to re-create it easily/frequently?
I just need to issue "reboot" (which calls "ip link ... down") for this to trigger. Here's a full splat[1], as well as my full config[2]. It is 100% repeatable.
Quoted 8 lines
Quoted 3 lines
# Kernel Config options:
CONFIG_LOCKDEP_SUPPORT=yCONFIG_LOCKDEP=yYou'll need at least
CONFIG_PROVE_LOCKING=yCONFIG_NET_POLL_CONTROLLER=yFew points:
1. To me netpoll causing spinlock deadlock with IRQ leg of TX and ip util is highly unlikely since netpoll runs with both RX/TX interrupts
disabled.
It runs in polling mode to facilitate parallel path to features
like
Netconsole, netdump etc. hence, deadlock because of the netpoll
should
be highly unlikely. Therefore, smells of some other problem
here...
2. Also, I remember patch[s1][s2] from Eric Dumazet to disable netpoll on many
NICs way back in 4.19 kernel on the basis of Song Liu's findings.Problem:
Aah, I see the problem now, it is because of the stray code related to theNET_POLL_CONTROLLERin hns driver which actually should have got remove within
the patch[s1], and that also explains why it does not get hit while NET POLL is disabled./*
netif_tx_lockwill turn down the performance, set only when necessary */ #ifdefCONFIG_NET_POLL_CONTROLLER
#defineNETIF_TX_LOCK(ring)spin_lock(&(ring)->lock)
#defineNETIF_TX_UNLOCK(ring)spin_unlock(&(ring)->lock)
#else
#defineNETIF_TX_LOCK(ring)
#defineNETIF_TX_UNLOCK(ring)
#endif
Quoted 4 lines
Once you define
CONFIG_NET_POLL_CONTROLLERin the latest code these macros Kick-in even for the normal NAPI path. Which can cause deadlock and that perhaps
is what you are seeing?
Yes, that's the problem.
Quoted 5 lines
Now, the question is do we require these locks in normal NAPI poll? I do not see that we need them anymore as Tasklets are serialized to themselves and configuration path like "ip <intf> down" cannot conflict with NAPI poll path as the later is always disabled prior performing interface down operation. Hence, no conflict there.
My preference would indeed be to drop these per-queue locks if they aren't required. I couldn't figure out from a cursory look at the code whether two CPUs could serve the same TX queue. If that cannot happen by construction, then these locks are perfectly useless and should be removed.
Quoted 9 lines
As a side analysis, I could figure out some contentions in the configuration path not related to this though. :)
Suggested Solution:
Since we do not have support ofNET_POLL_CONTROLLERmacros NETIF_TX_[UN]LOCK We should remove theseNET_POLL_CONTROLLERmacros altogether for now.
Quoted 7 lines
Though, I still have not looked comprehensively how other are able to use Debugging utils like netconsole etc without having
NET_POLL_CONTROLLER. Maybe @Eric Dumazet might give us some insight on this?If you agree with this then I can send a patch to remove these from hns driver. This should solve your problem as well?
Sure, as long as you can guarantee that these locks are never used for anything useful.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 82 lines
From: Marc Zyngier [mailto:[email protected]]
Sent: Wednesday, November 6, 2019 12:17 PM
To: Salil Mehta <[email protected]>Quoted 77 lines · Salil Mehta
Hi Marc,
Quoted 29 lines
On Tue, 5 Nov 2019 18:41:11 +0000
Salil Mehta <[email protected]> wrote:Hi Salil,
Quoted 2 lines
Hi Marc,
I tested with the patch on D05 with the lockdep enabled kernelwith below options
Quoted 1 line
and I could not reproduce the deadlock. I do not argue the issue
being mentioned
Quoted 1 line
as this looks to be a clear bug which should hit while TX
data-path is running
Quoted 1 line
and we try to disable the interface.
Lockdep screaming at you doesn't mean the deadly scenario happens in practice, and I've never seen the machine hanging in these conditions.
But I've also never tried to trigger it in anger.Quoted 1 line
Could you please help me know the exact set of steps you used to
get into this
Quoted 1 line
problem. Also, are you able to re-create it easily/frequently?
I just need to issue "reboot" (which calls "ip link ... down") for this
to trigger. Here's a full splat[1], as well as my full config[2]. It is
100% repeatable.Quoted 8 lines
Quoted 3 lines
# Kernel Config options:
CONFIG_LOCKDEP_SUPPORT=yCONFIG_LOCKDEP=yYou'll need at least
CONFIG_PROVE_LOCKING=yCONFIG_NET_POLL_CONTROLLER=yFew points:
1. To me netpoll causing spinlock deadlock with IRQ leg of TX and ip util is
highly unlikely since netpoll runs with both RX/TX interrupts
disabled.
It runs in polling mode to facilitate parallel path to features
like
Netconsole, netdump etc. hence, deadlock because of the netpoll
should
be highly unlikely. Therefore, smells of some other problem
here...
2. Also, I remember patch[s1][s2] from Eric Dumazet to disable netpoll on many
NICs way back in 4.19 kernel on the basis of Song Liu's findings.Problem:
Aah, I see the problem now, it is because of the stray code related to theNET_POLL_CONTROLLERin hns driver which actually should have got remove within
the patch[s1], and that also explains why it does not get hit while NET POLL
is disabled./*
netif_tx_lockwill turn down the performance, set only when necessary */
#ifdefCONFIG_NET_POLL_CONTROLLER
#defineNETIF_TX_LOCK(ring)spin_lock(&(ring)->lock) #defineNETIF_TX_UNLOCK(ring)spin_unlock(&(ring)->lock) #else
#defineNETIF_TX_LOCK(ring)
#defineNETIF_TX_UNLOCK(ring)
#endif
Quoted 7 lines
Quoted 5 lines
Once you define
CONFIG_NET_POLL_CONTROLLERin the latest code these macros
Kick-in even for the normal NAPI path. Which can cause deadlock and that perhaps
is what you are seeing?Yes, that's the problem.
Sure, thanks.
Quoted 10 lines
Quoted 9 lines
Now, the question is do we require these locks in normal NAPI poll? I do not
see that we need them anymore as Tasklets are serialized to themselves and
configuration path like "ip <intf> down" cannot conflict with NAPI poll path
as the later is always disabled prior performing interface down operation.
Hence, no conflict there.
Quoted 6 lines
My preference would indeed be to drop these per-queue locks if they aren't
required. I couldn't figure out from a cursory look at the code whether two CPUs could serve the same TX queue. If that cannot happen by construction,
then these locks are perfectly useless and should be removed.
Sure.
Quoted 17 lines
Quoted 17 lines
As a side analysis, I could figure out some contentions in the configuration
path not related to this though. :)Suggested Solution:
Since we do not have support ofNET_POLL_CONTROLLERmacros NETIF_TX_[UN]LOCK
We should remove theseNET_POLL_CONTROLLERmacros altogether for now.Though, I still have not looked comprehensively how other are able to use
Debugging utils like netconsole etc without havingNET_POLL_CONTROLLER.
Maybe @Eric Dumazet might give us some insight on this?
Quoted 7 lines
Quoted 3 lines
If you agree with this then I can send a patch to remove these from hns
driver. This should solve your problem as well?Sure, as long as you can guarantee that these locks are never used for anything
useful.
Hi Marc,
I have floated the patch. Could you please confirm if this solves your issue and if possible provide your Tested-by? :)
[PATCH net] net: hns: Fix the stray netpoll locks causing deadlock in NAPI path
Thanks
Salil