OSDN Git Service

IB/qib: Replace rcu_assign_pointer() with RCU_INIT_POINTER() in qib_qp.c
authorAndreea-Cristina Bernat <bernat.ada@gmail.com>
Fri, 16 Jan 2015 15:19:53 +0000 (10:19 -0500)
committerRoland Dreier <roland@purestorage.com>
Tue, 17 Feb 2015 18:26:19 +0000 (10:26 -0800)
commit03c885913f914d17124432dd50caf2923a80847c
tree3db8e8bb201844385275b6a4e58acc9458a29552
parent0e6bbba56c54f6305f24f0ad8991f5b5d03ae2b5
IB/qib: Replace rcu_assign_pointer() with RCU_INIT_POINTER() in qib_qp.c

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]

Tested-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/qib/qib_qp.c