IB/qib: Replace rcu_assign_pointer() with RCU_INIT_POINTER() in qib_qp.c
PATCH 1/2 IB/qib: Replace rcu_assign_pointer() with RCU_INIT_POINTER() in qib_qp.c
From: Andreea-Cristina Bernat <[email protected]>
According to RCU_INIT_POINTER()'s block comment 3.a, it can be used if
"1. This use of RCU_INIT_POINTER() is NULLing out the pointer"
it is better to use it instead of rcu_assign_pointer() because it has a smaller overhead.
"3. The referenced data structure has already been exposed to readers either
at compile time or via rcu_assign_pointer() -and-
a. You have not made -any- reader-visible changes to this structure since
then".
These cases fulfill the conditions above because between the rcu_dereference_protected() call and the rcu_assign_pointer() call there is no update of that value.
Therefore, this patch makes the replacement.
The following Coccinelle semantic patch was used:
@@
@@
- rcu_assign_pointer
+ RCU_INIT_POINTER
(...,
(
rtnl_dereference(...)
|
rcu_dereference_protected(...)
) )
[consolidated from http://marc.info/?l=linux-rdma&m=140836578119485&w=2 and
http://marc.info/?l=linux-rdma&m=140906361403047&w=2]
--- drivers/infiniband/hw/qib/qib_qp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/hw/qib/qib_qp.c +4 -4
@@ -255,10 +255,10 @@ static void remove_qp(struct qib_ibdev *dev, struct qib_qp *qp)if (rcu_dereference_protected (ibp->qp0,lockdep_is_held (&dev->qpt_lock)) == qp) { -rcu_assign_pointer (ibp->qp0,NULL ); +RCU_INIT_POINTER (ibp->qp0,NULL ); }else if (rcu_dereference_protected (ibp->qp1,lockdep_is_held (&dev->qpt_lock)) == qp) { -rcu_assign_pointer (ibp->qp1,NULL ); +RCU_INIT_POINTER (ibp->qp1,NULL ); }else {struct qib_qp *q;struct qib_qp __rcu **qpp;
@@ -269,7 +269,7 @@ static void remove_qp(struct qib_ibdev *dev, struct qib_qp *qp) lockdep_is_held(&dev->qpt_lock))) != NULL; qpp = &q->next)if (q == qp) { -rcu_assign_pointer (*qpp, +RCU_INIT_POINTER (*qpp,rcu_dereference_protected (qp->next,lockdep_is_held (&dev->qpt_lock))); removed =1 ;
@@ -315,7 +315,7 @@ unsigned qib_free_all_qps(struct qib_devdata *dd)for (n =0 ; n < dev->qp_table_size; n++) { qp =rcu_dereference_protected (dev->qp_table[n],lockdep_is_held (&dev->qpt_lock)); -rcu_assign_pointer (dev->qp_table[n],NULL ); +RCU_INIT_POINTER (dev->qp_table[n],NULL );for (; qp; qp =rcu_dereference_protected (qp->next,lockdep_is_held (&dev->qpt_lock)))
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20150116151953.1431.97213.stgit-K+u1se/DcYrLESAwzcoQNrvm/[email protected]
PATCH 2/2 IB/qib: Replace rcu_assign_pointer() with RCU_INIT_POINTER() in qib_keys.c
From: Andreea-Cristina Bernat <[email protected]>
The uses of "rcu_assign_pointer()" are NULLing out the pointers. According to RCU_INIT_POINTER()'s block comment:
"1. This use of RCU_INIT_POINTER() is NULLing out the pointer"
it is better to use it instead of rcu_assign_pointer() because it has a smaller overhead.
The following Coccinelle semantic patch was used:
@@
@@
- rcu_assign_pointer
+ RCU_INIT_POINTER
(..., NULL)
[Derived from http://marc.info/?l=linux-rdma&m=140836519219236&w=2]
--- drivers/infiniband/hw/qib/qib_keys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/qib/qib_keys.c +2 -2
@@ -122,10 +122,10 @@ void qib_free_lkey(struct qib_mregion *mr)if (!mr->lkey_published) goto out;if (lkey ==0 ) -rcu_assign_pointer (dev->dma_mr,NULL ); +RCU_INIT_POINTER (dev->dma_mr,NULL );else { r = lkey >> (32 - ib_qib_lkey_table_size); -rcu_assign_pointer (rkt->table[r],NULL ); +RCU_INIT_POINTER (rkt->table[r],NULL ); }qib_put_mr (mr); mr->lkey_published =0 ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html