[ofa-general] mlx4 violating radix tree API locking rules?

Michael S. Tsirkin mst at dev.mellanox.co.il
Tue Sep 11 02:03:13 PDT 2007


Roland, could you clarify the following please:
include/linux/radix-tree.h says:

 * For API usage, in general,
 * - any function _modifying_ the tree or tags (inserting or deleting
 *   items, setting or clearing tags must exclude other modifications, and
 *   exclude any functions reading the tree.
 * - any function _reading_ the tree or tags (looking up items or tags,
 *   gang lookups) must exclude modifications to the tree, but may occur
 *   concurrently with other readers.
 *
 * The notable exceptions to this rule are the following functions:
 * radix_tree_lookup
 * radix_tree_tag_get
 * radix_tree_gang_lookup
 * radix_tree_gang_lookup_tag
 * radix_tree_tagged
 *
 * The first 4 functions are able to be called locklessly, using RCU. The
 * caller must ensure calls to these functions are made within rcu_read_lock()
 * regions. Other readers (lock-free or otherwise) and modifications may be
 * running concurrently.
 *
 * It is still required that the caller manage the synchronization and lifetimes
 * of the items. So if RCU lock-free lookups are used, typically this would mean
 * that the items have their own locks, or are amenable to lock-free access; and
 * that the items are freed by RCU (or only freed after having been deleted from
 * the radix tree *and* a synchronize_rcu() grace period).
 *
 * (Note, rcu_assign_pointer and rcu_dereference are not needed to control
 * access to data items when inserting into or looking up from the radix tree)
 *
 * radix_tree_tagged is able to be called without locking or RCU.

OTOH, a comment in drivers/infiniband/hw/mlx4/cq.c says:

               /*
                 * We do not have to take the QP table lock here,
                 * because CQs will be locked while QPs are removed
                 * from the table.
                 */

I guess CQ spinlock implies rcu_read_lock - is that right?
But I do not see any synchronize_rcu calls anywhere in mlx4.
Should destroy QP and friends call synchronize_rcu after
removing the QP from radix tree but before freeing the QP structure?

Thanks,

-- 
MST



More information about the general mailing list