[openib-general] [PATCH] Optimize cma_process_remove()

Krishna Kumar2 krkumar2 at in.ibm.com
Mon Sep 11 21:31:50 PDT 2006


Hi Sean,

> I don't think that this will work.  The issue is that we need to walk a 
list of 
> IDs associated with a particular device to notify the user that the 
device is 
> being removed.  While we're doing that, the user could try to destroy 
the ID, 
> which removes the ID from the device list.
> 
> The original code takes a reference on the ID before removing it from 
the from 
> cma_dev's list to ensure that the ID will be valid while we process it. 
The 
> remove list ensures that the user is only notified once of a device 
removal. 
> (We don't know where the thread calling rdma_destroy_id() is at.)

Yes, you are right - I missed the parallel rdma_destroy_id's. How about 
something
like this then (it is cleaner than dropping/re-getting locks) :

        mutex_lock(&lock);
        while (!list_empty(&cma_dev->id_list)) {
                id_priv = list_entry(cma_dev->id_list.next,
                                     struct rdma_id_private, list);

                if (cma_internal_listen(id_priv)) {
                        cma_destroy_listen(id_priv);
                } else {
                        atomic_inc(&id_priv->refcount);
                        list_del(&id_priv->list);
                        list_add_tail(&id_priv->list, &remove_list);
                }
        }
        mutex_unlock(&lock);

        list_for_each_entry_safe(id_priv, tmp, &remove_list, list) {
                ret = cma_remove_id_dev(id_priv);
                cma_deref_id(id_priv);
                if (ret)
                        rdma_destroy_id(&id_priv->id);
        }

thanks,

- KK





More information about the general mailing list