From: Leon Romanovsky <leonro@xxxxxxxxxxxx> XArray uses internal lock for updates to XArray. This means that our external RW lock is not needed anymore and we can delete it. Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/core/nldev.c | 9 --------- drivers/infiniband/core/restrack.c | 7 ------- include/rdma/restrack.h | 5 ----- 3 files changed, 21 deletions(-) diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index 45edf2ae611e..86b3175d3080 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -1116,7 +1116,6 @@ static int res_get_common_dumpit(struct sk_buff *skb, has_cap_net_admin = netlink_capable(cb->skb, CAP_NET_ADMIN); - down_read(&device->res.rwsem); xa_for_each(&device->res.xa[res_type], res, id, ULONG_MAX, XA_PRESENT) { if (idx < start) goto next; @@ -1134,13 +1133,7 @@ static int res_get_common_dumpit(struct sk_buff *skb, filled = true; - up_read(&device->res.rwsem); ret = fe->fill_res_func(skb, has_cap_net_admin, res, port); - down_read(&device->res.rwsem); - /* - * Return resource back, but it won't be released till - * the &device->res.rwsem will be released for write. - */ rdma_restrack_put(res); if (ret == -EMSGSIZE) @@ -1154,7 +1147,6 @@ static int res_get_common_dumpit(struct sk_buff *skb, goto res_err; next: idx++; } - up_read(&device->res.rwsem); nla_nest_end(skb, table_attr); nlmsg_end(skb, nlh); @@ -1172,7 +1164,6 @@ next: idx++; res_err: nla_nest_cancel(skb, table_attr); - up_read(&device->res.rwsem); err: nlmsg_cancel(skb, nlh); diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c index d65758a3a7b6..ceaff30b6537 100644 --- a/drivers/infiniband/core/restrack.c +++ b/drivers/infiniband/core/restrack.c @@ -25,7 +25,6 @@ void rdma_restrack_init(struct rdma_restrack_root *res) for (i = 0 ; i < RDMA_RESTRACK_MAX; i++) xa_init(&res->xa[i]); - init_rwsem(&res->rwsem); res->fill_res_entry = fill_res_noop; } @@ -95,14 +94,12 @@ int rdma_restrack_count(struct rdma_restrack_root *res, unsigned long index = 0; u32 cnt = 0; - down_read(&res->rwsem); xa_for_each(&res->xa[type], e, index, ULONG_MAX, XA_PRESENT) { if (ns == &init_pid_ns || (!rdma_is_kernel_res(e) && ns == task_active_pid_ns(e->task))) cnt++; } - up_read(&res->rwsem); return cnt; } EXPORT_SYMBOL(rdma_restrack_count); @@ -212,13 +209,11 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res) init_completion(&res->comp); res->valid = true; - down_write(&dev->res.rwsem); id = res_to_id(res); ret = xa_insert(&dev->res.xa[res->type], id, res, GFP_KERNEL); WARN_ONCE(ret == -EEXIST, "Tried to add non-unique type %d entry\n", res->type); if (ret) res->valid = false; - up_write(&dev->res.rwsem); } /** @@ -293,10 +288,8 @@ void rdma_restrack_del(struct rdma_restrack_entry *res) wait_for_completion(&res->comp); id = res_to_id(res); - down_write(&dev->res.rwsem); xa_erase(&dev->res.xa[res->type], id); res->valid = false; - up_write(&dev->res.rwsem); out: if (res->task) { diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h index 6a6748a9a7b1..e4a6870b40ad 100644 --- a/include/rdma/restrack.h +++ b/include/rdma/restrack.h @@ -7,7 +7,6 @@ #define _RDMA_RESTRACK_H_ #include <linux/typecheck.h> -#include <linux/rwsem.h> #include <linux/sched.h> #include <linux/kref.h> #include <linux/completion.h> @@ -56,10 +55,6 @@ struct rdma_restrack_entry; * entity, per-device */ struct rdma_restrack_root { - /* - * @rwsem: Read/write lock to protect lists and IDR - */ - struct rw_semaphore rwsem; /** * @xa: Array of XArray structures to hold restrack entries. * We want to use array of XArrays becasue insertion is type -- 2.19.1