[openib-general] [PATCH]IPOIB: adding spin_lock in path_free()

Shirley Ma xma at us.ibm.com
Thu Feb 17 17:40:34 PST 2005


Please review this patch.

diff -urN infiniband/ulp/ipoib/ipoib_main.c 
infiniband-path/ulp/ipoib/ipoib_main.c
--- infiniband/ulp/ipoib/ipoib_main.c   2005-02-17 17:24:56.000000000 
+0000
+++ infiniband-path/ulp/ipoib/ipoib_main.c      2005-02-18 
01:29:52.000000000 +0000
@@ -215,15 +215,17 @@
        return 0;
 }
 
-static void __path_free(struct net_device *dev, struct ipoib_path *path)
+static void path_free(struct net_device *dev, struct ipoib_path *path)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
        struct ipoib_neigh *neigh, *tn;
        struct sk_buff *skb;
+       unsigned long flags;
 
        while ((skb = __skb_dequeue(&path->queue)))
                dev_kfree_skb_irq(skb);
 
+       spin_lock_irqsave(&priv->lock, flags);
        list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) {
                if (neigh->ah)
                        ipoib_put_ah(neigh->ah);
@@ -231,13 +233,16 @@
                neigh->neighbour->ops->destructor = NULL;
                kfree(neigh);
        }
+       spin_unlock_irqrestore(&priv->lock, flags);
 
        if (path->ah)
                ipoib_put_ah(path->ah);
 
+       spin_lock_irqsave(&priv->lock, flags);
        rb_erase(&path->rb_node, &priv->path_tree);
        list_del(&path->list);
        kfree(path);
+       spin_unlock_irqrestore(&priv->lock, flags);
 }
 
 void ipoib_flush_paths(struct net_device *dev)
@@ -256,7 +261,7 @@
                if (path->query)
                        ib_sa_cancel_query(path->query_id, path->query);
                wait_for_completion(&path->done);
-               __path_free(dev, path);
+               path_free(dev, path);
        }
 }
 
@@ -496,8 +501,11 @@
                        skb_push(skb, sizeof *phdr);
                        __skb_queue_tail(&path->queue, skb);
 
-                       if (path_rec_start(dev, path))
-                               __path_free(dev, path);
+                       if (path_rec_start(dev, path)) {
+                               spin_unlock(&priv->lock);
+                               path_free(dev, path);
+                               return;
+                       }
                } else {
                        ++priv->stats.tx_dropped;
                        dev_kfree_skb_any(skb);




Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone(Fax): (503) 578-7638

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20050217/3e5825fd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: infiniband-path-free.patch
Type: application/octet-stream
Size: 1727 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20050217/3e5825fd/attachment.obj>


More information about the general mailing list