netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rcu: Replace rcu_dereference() with rcu_access_pointer()
@ 2014-08-16 19:34 Andreea-Cristina Bernat
  2014-08-17  1:50 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Andreea-Cristina Bernat @ 2014-08-16 19:34 UTC (permalink / raw)
  To: j.vosburgh, vfalico, andy, netdev, linux-kernel; +Cc: paulmck

This "rcu_dereference()" call is used directly in a condition.
Since its return value is never dereferenced it is recommended to use
"rcu_access_pointer()" instead of "rcu_dereference()".
Therefore, this patch makes this replacement.

The following Coccinelle semantic patch was used for solving it:
@@
@@

(
 if(
 (<+...
- rcu_dereference
+ rcu_access_pointer
  (...)
 ...+>)) {...}
|
 while(
 (<+...
- rcu_dereference
+ rcu_access_pointer
  (...)
  ...+>)) {...}
)

Signed-off-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
---
 drivers/net/bonding/bond_alb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 76c0dad..1319c5b 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1385,7 +1385,7 @@ static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
 	}
 
 	if (tx_slave && bond_slave_can_tx(tx_slave)) {
-		if (tx_slave != rcu_dereference(bond->curr_active_slave)) {
+		if (tx_slave != rcu_access_pointer(bond->curr_active_slave)) {
 			ether_addr_copy(eth_data->h_source,
 					tx_slave->dev->dev_addr);
 		}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] rcu: Replace rcu_dereference() with rcu_access_pointer()
@ 2014-08-16 20:12 Andreea-Cristina Bernat
  0 siblings, 0 replies; 4+ messages in thread
From: Andreea-Cristina Bernat @ 2014-08-16 20:12 UTC (permalink / raw)
  To: davem, mchan, eddie.wai, peterz, joe, netdev, linux-kernel; +Cc: paulmck

The "rcu_dereference()" calls are used directly in conditions.
Since their return values are never dereferenced it is recommended to use
"rcu_access_pointer()" instead of "rcu_dereference()".
Therefore, this patch makes the replacements.

The following Coccinelle semantic patch was used:
@@
@@

(
 if(
 (<+...
- rcu_dereference
+ rcu_access_pointer
  (...)
  ...+>)) {...}
|
 while(
 (<+...
- rcu_dereference
+ rcu_access_pointer
  (...)
  ...+>)) {...}
)

Signed-off-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
---
 drivers/net/ethernet/broadcom/cnic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 8244e2b..dad9cb7 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -381,7 +381,7 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,
 			break;
 
 		rcu_read_lock();
-		if (!rcu_dereference(cp->ulp_ops[CNIC_ULP_L4])) {
+		if (!rcu_access_pointer(cp->ulp_ops[CNIC_ULP_L4])) {
 			rc = -ENODEV;
 			rcu_read_unlock();
 			break;
@@ -525,7 +525,7 @@ int cnic_unregister_driver(int ulp_type)
 	list_for_each_entry(dev, &cnic_dev_list, list) {
 		struct cnic_local *cp = dev->cnic_priv;
 
-		if (rcu_dereference(cp->ulp_ops[ulp_type])) {
+		if (rcu_access_pointer(cp->ulp_ops[ulp_type])) {
 			pr_err("%s: Type %d still has devices registered\n",
 			       __func__, ulp_type);
 			read_unlock(&cnic_dev_lock);
@@ -573,7 +573,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
 		mutex_unlock(&cnic_lock);
 		return -EAGAIN;
 	}
-	if (rcu_dereference(cp->ulp_ops[ulp_type])) {
+	if (rcu_access_pointer(cp->ulp_ops[ulp_type])) {
 		pr_err("%s: Type %d has already been registered to this device\n",
 		       __func__, ulp_type);
 		mutex_unlock(&cnic_lock);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rcu: Replace rcu_dereference() with rcu_access_pointer()
  2014-08-16 19:34 Andreea-Cristina Bernat
@ 2014-08-17  1:50 ` David Miller
  2014-08-17 10:04   ` Andreea Bernat
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2014-08-17  1:50 UTC (permalink / raw)
  To: bernat.ada; +Cc: j.vosburgh, vfalico, andy, netdev, linux-kernel, paulmck


Please do not use the same exact Subject line for all of these patches.

Otherwise nobody reading the shortlog can tell what might be different
from one patch to another.

Instead, use a subsystem prefix for the place where you're making
your change.  For example, for the two networking patches you could
replace "rcu: " with "bonding: " and "cnic: ".

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rcu: Replace rcu_dereference() with rcu_access_pointer()
  2014-08-17  1:50 ` David Miller
@ 2014-08-17 10:04   ` Andreea Bernat
  0 siblings, 0 replies; 4+ messages in thread
From: Andreea Bernat @ 2014-08-17 10:04 UTC (permalink / raw)
  To: David Miller
  Cc: Jay Vosburgh, vfalico, Andy Gospodarek, netdev, linux-kernel,
	Paul McKenney

Sorry, I will send a version two of the patches with the subject line
changed.

Thank you,
Andreea

2014-08-17 4:50 GMT+03:00 David Miller <davem@davemloft.net>:
>
> Please do not use the same exact Subject line for all of these patches.
>
> Otherwise nobody reading the shortlog can tell what might be different
> from one patch to another.
>
> Instead, use a subsystem prefix for the place where you're making
> your change.  For example, for the two networking patches you could
> replace "rcu: " with "bonding: " and "cnic: ".
>
> Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-17 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-16 20:12 [PATCH] rcu: Replace rcu_dereference() with rcu_access_pointer() Andreea-Cristina Bernat
  -- strict thread matches above, loose matches on Subject: below --
2014-08-16 19:34 Andreea-Cristina Bernat
2014-08-17  1:50 ` David Miller
2014-08-17 10:04   ` Andreea Bernat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).