Skip to content

Commit bb42a6d

Browse files
dledfordrolandd
authored andcommitted
IPoIB: Make ipoib_mcast_stop_thread flush the workqueue
We used to pass a flush variable to mcast_stop_thread to indicate if we should flush the workqueue or not. This was due to some code trying to flush a workqueue that it was currently running on which is a no-no. Now that we have per-device work queues, and now that ipoib_mcast_restart_task has taken the fact that it is queued on a single thread workqueue with all of the ipoib_mcast_join_task's and therefore has no need to stop the join task while it runs, we can do away with the flush parameter and unilaterally flush always. Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
1 parent 5141861 commit bb42a6d

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

drivers/infiniband/ulp/ipoib/ipoib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb);
499499

500500
void ipoib_mcast_restart_task(struct work_struct *work);
501501
int ipoib_mcast_start_thread(struct net_device *dev);
502-
int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
502+
int ipoib_mcast_stop_thread(struct net_device *dev);
503503

504504
void ipoib_mcast_dev_down(struct net_device *dev);
505505
void ipoib_mcast_dev_flush(struct net_device *dev);

drivers/infiniband/ulp/ipoib/ipoib_ib.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ int ipoib_ib_dev_down(struct net_device *dev, int flush)
747747
clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
748748
netif_carrier_off(dev);
749749

750-
ipoib_mcast_stop_thread(dev, flush);
750+
ipoib_mcast_stop_thread(dev);
751751
ipoib_mcast_dev_flush(dev);
752752

753753
ipoib_flush_paths(dev);
@@ -1097,7 +1097,7 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
10971097
*/
10981098
ipoib_flush_paths(dev);
10991099

1100-
ipoib_mcast_stop_thread(dev, 1);
1100+
ipoib_mcast_stop_thread(dev);
11011101
ipoib_mcast_dev_flush(dev);
11021102

11031103
ipoib_transport_dev_cleanup(dev);

drivers/infiniband/ulp/ipoib/ipoib_multicast.c

+9-12
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ int ipoib_mcast_start_thread(struct net_device *dev)
648648
return 0;
649649
}
650650

651-
int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
651+
int ipoib_mcast_stop_thread(struct net_device *dev)
652652
{
653653
struct ipoib_dev_priv *priv = netdev_priv(dev);
654654

@@ -659,8 +659,7 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
659659
cancel_delayed_work(&priv->mcast_task);
660660
mutex_unlock(&mcast_mutex);
661661

662-
if (flush)
663-
flush_workqueue(priv->wq);
662+
flush_workqueue(priv->wq);
664663

665664
return 0;
666665
}
@@ -838,8 +837,6 @@ void ipoib_mcast_restart_task(struct work_struct *work)
838837

839838
ipoib_dbg_mcast(priv, "restarting multicast task\n");
840839

841-
ipoib_mcast_stop_thread(dev, 0);
842-
843840
local_irq_save(flags);
844841
netif_addr_lock(dev);
845842
spin_lock(&priv->lock);
@@ -936,13 +933,10 @@ void ipoib_mcast_restart_task(struct work_struct *work)
936933
* We have to cancel outside of the spinlock, but we have to
937934
* take the rtnl lock or else we race with the removal of
938935
* entries from the remove list in mcast_dev_flush as part
939-
* of ipoib_stop() which will call mcast_stop_thread with
940-
* flush == 1 while holding the rtnl lock, and the
941-
* flush_workqueue won't complete until this restart_mcast_task
942-
* completes. So do like the carrier on task and attempt to
943-
* take the rtnl lock, but if we can't before the ADMIN_UP flag
944-
* goes away, then just return and know that the remove list will
945-
* get flushed later by mcast_stop_thread.
936+
* of ipoib_stop(). We detect the drop of the ADMIN_UP flag
937+
* to signal that we have hit this particular race, and we
938+
* return since we know we don't need to do anything else
939+
* anyway.
946940
*/
947941
while (!rtnl_trylock()) {
948942
if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
@@ -954,6 +948,9 @@ void ipoib_mcast_restart_task(struct work_struct *work)
954948
ipoib_mcast_leave(mcast->dev, mcast);
955949
ipoib_mcast_free(mcast);
956950
}
951+
/*
952+
* Restart our join task if needed
953+
*/
957954
ipoib_mcast_start_thread(dev);
958955
rtnl_unlock();
959956
}

0 commit comments

Comments
 (0)