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

Shirley Ma xma at us.ibm.com
Thu Feb 24 10:32:03 PST 2005


Here is the patch against the most recent bit. Please review it. 

Signed-off-by: Shirley Ma <xma at us.ibm.com> 

diff -urpN infiniband/ulp/ipoib/ipoib_main.c 
infiniband-pathfree/ulp/ipoib/ipoib_main.c
--- infiniband/ulp/ipoib/ipoib_main.c   2005-02-24 18:06:15.000000000 
+0000
+++ infiniband-pathfree/ulp/ipoib/ipoib_main.c  2005-02-24 
18:28:58.000000000 +0000
@@ -215,15 +215,17 @@ static int __path_add(struct net_device 
        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 @@ static void __path_free(struct net_devic
                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 @@ void ipoib_flush_paths(struct net_device
                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 @@ static void unicast_arp_send(struct sk_b
                        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/20050224/69406f18/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: infiniband-pathfree.patch
Type: application/octet-stream
Size: 1900 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20050224/69406f18/attachment.obj>


More information about the general mailing list