diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2018-07-11 05:55:18 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-07-25 23:21:22 +0300 |
commit | 87064277c4d3b0ddb251a91324f2525048027ee2 (patch) | |
tree | ddb90f53572eddb44b6c0ba2bf72aa271841b66e /drivers/infiniband/core/uverbs.h | |
parent | e6d5d5ddd0869cf44a554289cd213007ccc0afde (diff) | |
download | linux-87064277c4d3b0ddb251a91324f2525048027ee2.tar.xz |
IB/uverbs: Revise and clarify the rwsem and uobjects_lock
Rename 'cleanup_rwsem' to 'hw_destroy_rwsem' which is held across any call
to the type destroy function (aka 'hw' destroy). The main purpose of this
lock is to prevent normal add and destroy from running concurrently with
uverbs_cleanup_ufile()
Since the uobjects list is always manipulated under the 'hw_destroy_rwsem'
we can eliminate the uobjects_lock in the cleanup function. This allows
converting that lock to a very simple spinlock with a narrow critical
section.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs.h')
-rw-r--r-- | drivers/infiniband/core/uverbs.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index d0a1a54275e5..58b16e840e56 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -145,12 +145,16 @@ struct ib_uverbs_file { struct list_head list; int is_closed; - /* locking the uobjects_list */ - struct mutex uobjects_lock; + /* + * To access the uobjects list hw_destroy_rwsem must be held for write + * OR hw_destroy_rwsem held for read AND uobjects_lock held. + * hw_destroy_rwsem should be called across any destruction of the HW + * object of an associated uobject. + */ + struct rw_semaphore hw_destroy_rwsem; + spinlock_t uobjects_lock; struct list_head uobjects; - /* protects cleanup process from other actions */ - struct rw_semaphore cleanup_rwsem; enum rdma_remove_reason cleanup_reason; struct idr idr; |