aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp
diff options
context:
space:
mode:
authorErez Shitrit <erezsh@mellanox.com>2013-10-16 10:37:49 -0400
committerRoland Dreier <roland@purestorage.com>2013-11-08 17:42:49 -0500
commitf47944cc2dba3c7e6f753b81e9f713f4d12bdd5a (patch)
tree4dd24c53d8041eff9f251c9debf63bd54be083d8 /drivers/infiniband/ulp
parent22252b4e09f19431f82dc26428e0edf697d19a04 (diff)
IPoIB: Fix deadlock between dev_change_flags() and __ipoib_dev_flush()
When ipoib interface is going down it takes all of its children with it, under mutex. For each child, dev_change_flags() is called. That function calls ipoib_stop() via the ndo, and causes flush of the workqueue. Sometimes in the workqueue an __ipoib_dev_flush work() is waiting and when invoked tries to get the same mutex, which leads to a deadlock, as seen below. The solution is to switch to rw-sem instead of mutex. The deadlock: [11028.165303] [<ffffffff812b0977>] ? vgacon_scroll+0x107/0x2e0 [11028.171844] [<ffffffff814eaac5>] schedule_timeout+0x215/0x2e0 [11028.178465] [<ffffffff8105a5c3>] ? perf_event_task_sched_out+0x33/0x80 [11028.185962] [<ffffffff814ea743>] wait_for_common+0x123/0x180 [11028.192491] [<ffffffff8105fa40>] ? default_wake_function+0x0/0x20 [11028.199504] [<ffffffff814ea85d>] wait_for_completion+0x1d/0x20 [11028.206224] [<ffffffff8108b4f1>] flush_cpu_workqueue+0x61/0x90 [11028.212948] [<ffffffff8108b5a0>] ? wq_barrier_func+0x0/0x20 [11028.219375] [<ffffffff8108bfc4>] flush_workqueue+0x54/0x80 [11028.225712] [<ffffffffa05a0576>] ipoib_mcast_stop_thread+0x66/0x90 [ib_ipoib] [11028.233988] [<ffffffffa059ccea>] ipoib_ib_dev_down+0x6a/0x100 [ib_ipoib] [11028.241678] [<ffffffffa059849a>] ipoib_stop+0x8a/0x140 [ib_ipoib] [11028.248692] [<ffffffff8142adf1>] dev_close+0x71/0xc0 [11028.254447] [<ffffffff8142a631>] dev_change_flags+0xa1/0x1d0 [11028.261062] [<ffffffffa059851b>] ipoib_stop+0x10b/0x140 [ib_ipoib] [11028.268172] [<ffffffff8142adf1>] dev_close+0x71/0xc0 [11028.273922] [<ffffffff8142a631>] dev_change_flags+0xa1/0x1d0 [11028.280452] [<ffffffff8148f20b>] devinet_ioctl+0x5eb/0x6a0 [11028.286786] [<ffffffff814903b8>] inet_ioctl+0x88/0xa0 [11028.292633] [<ffffffff8141591a>] sock_ioctl+0x7a/0x280 [11028.298576] [<ffffffff81189012>] vfs_ioctl+0x22/0xa0 [11028.304326] [<ffffffff81140540>] ? unmap_region+0x110/0x130 [11028.310756] [<ffffffff811891b4>] do_vfs_ioctl+0x84/0x580 [11028.316897] [<ffffffff81189731>] sys_ioctl+0x81/0xa0 and 11028.017533] [<ffffffff8105a5c3>] ? perf_event_task_sched_out+0x33/0x80 [11028.025030] [<ffffffff8100bb8e>] ? apic_timer_interrupt+0xe/0x20 [11028.031945] [<ffffffff814eb2ae>] __mutex_lock_slowpath+0x13e/0x180 [11028.039053] [<ffffffff814eb14b>] mutex_lock+0x2b/0x50 [11028.044910] [<ffffffffa059f7e7>] __ipoib_ib_dev_flush+0x37/0x210 [ib_ipoib] [11028.052894] [<ffffffffa059fa00>] ? ipoib_ib_dev_flush_light+0x0/0x20 [ib_ipoib] [11028.061363] [<ffffffffa059fa17>] ipoib_ib_dev_flush_light+0x17/0x20 [ib_ipoib] [11028.069738] [<ffffffff8108b120>] worker_thread+0x170/0x2a0 [11028.076068] [<ffffffff81090990>] ? autoremove_wake_function+0x0/0x40 [11028.083374] [<ffffffff8108afb0>] ? worker_thread+0x0/0x2a0 [11028.089709] [<ffffffff81090626>] kthread+0x96/0xa0 [11028.095266] [<ffffffff8100c0ca>] child_rip+0xa/0x20 [11028.100921] [<ffffffff81090590>] ? kthread+0x0/0xa0 [11028.106573] [<ffffffff8100c0c0>] ? child_rip+0x0/0x20 [11028.112423] INFO: task ifconfig:23640 blocked for more than 120 seconds. Signed-off-by: Erez Shitrit <erezsh@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c10
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_netlink.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c10
5 files changed, 16 insertions, 14 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index eb71aaa26a9a..ec9190eff09c 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -299,7 +299,7 @@ struct ipoib_dev_priv {
299 299
300 unsigned long flags; 300 unsigned long flags;
301 301
302 struct mutex vlan_mutex; 302 struct rw_semaphore vlan_rwsem;
303 303
304 struct rb_root path_tree; 304 struct rb_root path_tree;
305 struct list_head path_list; 305 struct list_head path_list;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index c14f949edcb7..01594de9b11d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -977,7 +977,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
977 u16 new_index; 977 u16 new_index;
978 int result; 978 int result;
979 979
980 mutex_lock(&priv->vlan_mutex); 980 down_read(&priv->vlan_rwsem);
981 981
982 /* 982 /*
983 * Flush any child interfaces too -- they might be up even if 983 * Flush any child interfaces too -- they might be up even if
@@ -986,7 +986,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
986 list_for_each_entry(cpriv, &priv->child_intfs, list) 986 list_for_each_entry(cpriv, &priv->child_intfs, list)
987 __ipoib_ib_dev_flush(cpriv, level); 987 __ipoib_ib_dev_flush(cpriv, level);
988 988
989 mutex_unlock(&priv->vlan_mutex); 989 up_read(&priv->vlan_rwsem);
990 990
991 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) { 991 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) {
992 /* for non-child devices must check/update the pkey value here */ 992 /* for non-child devices must check/update the pkey value here */
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 82cec1af902c..dcb50cef0bda 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -119,7 +119,7 @@ int ipoib_open(struct net_device *dev)
119 struct ipoib_dev_priv *cpriv; 119 struct ipoib_dev_priv *cpriv;
120 120
121 /* Bring up any child interfaces too */ 121 /* Bring up any child interfaces too */
122 mutex_lock(&priv->vlan_mutex); 122 down_read(&priv->vlan_rwsem);
123 list_for_each_entry(cpriv, &priv->child_intfs, list) { 123 list_for_each_entry(cpriv, &priv->child_intfs, list) {
124 int flags; 124 int flags;
125 125
@@ -129,7 +129,7 @@ int ipoib_open(struct net_device *dev)
129 129
130 dev_change_flags(cpriv->dev, flags | IFF_UP); 130 dev_change_flags(cpriv->dev, flags | IFF_UP);
131 } 131 }
132 mutex_unlock(&priv->vlan_mutex); 132 up_read(&priv->vlan_rwsem);
133 } 133 }
134 134
135 netif_start_queue(dev); 135 netif_start_queue(dev);
@@ -162,7 +162,7 @@ static int ipoib_stop(struct net_device *dev)
162 struct ipoib_dev_priv *cpriv; 162 struct ipoib_dev_priv *cpriv;
163 163
164 /* Bring down any child interfaces too */ 164 /* Bring down any child interfaces too */
165 mutex_lock(&priv->vlan_mutex); 165 down_read(&priv->vlan_rwsem);
166 list_for_each_entry(cpriv, &priv->child_intfs, list) { 166 list_for_each_entry(cpriv, &priv->child_intfs, list) {
167 int flags; 167 int flags;
168 168
@@ -172,7 +172,7 @@ static int ipoib_stop(struct net_device *dev)
172 172
173 dev_change_flags(cpriv->dev, flags & ~IFF_UP); 173 dev_change_flags(cpriv->dev, flags & ~IFF_UP);
174 } 174 }
175 mutex_unlock(&priv->vlan_mutex); 175 up_read(&priv->vlan_rwsem);
176 } 176 }
177 177
178 return 0; 178 return 0;
@@ -1372,7 +1372,7 @@ void ipoib_setup(struct net_device *dev)
1372 1372
1373 spin_lock_init(&priv->lock); 1373 spin_lock_init(&priv->lock);
1374 1374
1375 mutex_init(&priv->vlan_mutex); 1375 init_rwsem(&priv->vlan_rwsem);
1376 1376
1377 INIT_LIST_HEAD(&priv->path_list); 1377 INIT_LIST_HEAD(&priv->path_list);
1378 INIT_LIST_HEAD(&priv->child_intfs); 1378 INIT_LIST_HEAD(&priv->child_intfs);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
index f81abe16cf09..c29b5c838833 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
@@ -142,10 +142,10 @@ static void ipoib_unregister_child_dev(struct net_device *dev, struct list_head
142 priv = netdev_priv(dev); 142 priv = netdev_priv(dev);
143 ppriv = netdev_priv(priv->parent); 143 ppriv = netdev_priv(priv->parent);
144 144
145 mutex_lock(&ppriv->vlan_mutex); 145 down_write(&ppriv->vlan_rwsem);
146 unregister_netdevice_queue(dev, head); 146 unregister_netdevice_queue(dev, head);
147 list_del(&priv->list); 147 list_del(&priv->list);
148 mutex_unlock(&ppriv->vlan_mutex); 148 up_write(&ppriv->vlan_rwsem);
149} 149}
150 150
151static size_t ipoib_get_size(const struct net_device *dev) 151static size_t ipoib_get_size(const struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 8292554bccb5..9fad7b5ac8b9 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -140,7 +140,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
140 if (!rtnl_trylock()) 140 if (!rtnl_trylock())
141 return restart_syscall(); 141 return restart_syscall();
142 142
143 mutex_lock(&ppriv->vlan_mutex); 143 down_write(&ppriv->vlan_rwsem);
144 144
145 /* 145 /*
146 * First ensure this isn't a duplicate. We check the parent device and 146 * First ensure this isn't a duplicate. We check the parent device and
@@ -163,7 +163,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
163 result = __ipoib_vlan_add(ppriv, priv, pkey, IPOIB_LEGACY_CHILD); 163 result = __ipoib_vlan_add(ppriv, priv, pkey, IPOIB_LEGACY_CHILD);
164 164
165out: 165out:
166 mutex_unlock(&ppriv->vlan_mutex); 166 up_write(&ppriv->vlan_rwsem);
167 167
168 if (result) 168 if (result)
169 free_netdev(priv->dev); 169 free_netdev(priv->dev);
@@ -185,7 +185,8 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
185 185
186 if (!rtnl_trylock()) 186 if (!rtnl_trylock())
187 return restart_syscall(); 187 return restart_syscall();
188 mutex_lock(&ppriv->vlan_mutex); 188
189 down_write(&ppriv->vlan_rwsem);
189 list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) { 190 list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) {
190 if (priv->pkey == pkey && 191 if (priv->pkey == pkey &&
191 priv->child_type == IPOIB_LEGACY_CHILD) { 192 priv->child_type == IPOIB_LEGACY_CHILD) {
@@ -195,7 +196,8 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
195 break; 196 break;
196 } 197 }
197 } 198 }
198 mutex_unlock(&ppriv->vlan_mutex); 199 up_write(&ppriv->vlan_rwsem);
200
199 rtnl_unlock(); 201 rtnl_unlock();
200 202
201 if (dev) { 203 if (dev) {