All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] bond: relocate rcu_read_lock and rcu_read_unlock
@ 2016-02-01  3:31 zyjzyj2000
  2016-02-01 11:01 ` Nikolay Aleksandrov
  0 siblings, 1 reply; 3+ messages in thread
From: zyjzyj2000 @ 2016-02-01  3:31 UTC (permalink / raw)
  To: j.vosburgh, vfalico, gospo, netdev, zyjzyj2000

From: Zhu Yanjun <zyjzyj2000@gmail.com>

rcu_read_lock and rcu_read_unlock are to protect the function
bond_miimon_inspect. As such, moving rcu_read_lock and rcu_read_unlock
to the function bond_miimon_inspect to make the source code compact.

CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Veaceslav Falico <vfalico@gmail.com>
CC: Andy Gospodarek <gospo@cumulusnetworks.com>
Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
---
 drivers/net/bonding/bond_main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 56b5605..4043181 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2022,6 +2022,7 @@ static int bond_miimon_inspect(struct bonding *bond)
 	struct slave *slave;
 	bool ignore_updelay;
 
+	rcu_read_lock();
 	ignore_updelay = !rcu_dereference(bond->curr_active_slave);
 
 	bond_for_each_slave_rcu(bond, slave, iter) {
@@ -2113,6 +2114,8 @@ static int bond_miimon_inspect(struct bonding *bond)
 		}
 	}
 
+	rcu_read_unlock();
+
 	return commit;
 }
 
@@ -2231,12 +2234,9 @@ static void bond_mii_monitor(struct work_struct *work)
 	if (!bond_has_slaves(bond))
 		goto re_arm;
 
-	rcu_read_lock();
-
 	should_notify_peers = bond_should_notify_peers(bond);
 
 	if (bond_miimon_inspect(bond)) {
-		rcu_read_unlock();
 
 		/* Race avoidance with bond_close cancel of workqueue */
 		if (!rtnl_trylock()) {
@@ -2248,8 +2248,7 @@ static void bond_mii_monitor(struct work_struct *work)
 		bond_miimon_commit(bond);
 
 		rtnl_unlock();	/* might sleep, hold no other locks */
-	} else
-		rcu_read_unlock();
+	}
 
 re_arm:
 	if (bond->params.miimon)
-- 
1.9.1

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

* Re: [PATCH 1/1] bond: relocate rcu_read_lock and rcu_read_unlock
  2016-02-01  3:31 [PATCH 1/1] bond: relocate rcu_read_lock and rcu_read_unlock zyjzyj2000
@ 2016-02-01 11:01 ` Nikolay Aleksandrov
  2016-02-01 11:08   ` Nikolay Aleksandrov
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Aleksandrov @ 2016-02-01 11:01 UTC (permalink / raw)
  To: zyjzyj2000, j.vosburgh, vfalico, gospo, netdev

On 02/01/2016 04:31 AM, zyjzyj2000@gmail.com wrote:
> From: Zhu Yanjun <zyjzyj2000@gmail.com>
> 
> rcu_read_lock and rcu_read_unlock are to protect the function
> bond_miimon_inspect. As such, moving rcu_read_lock and rcu_read_unlock
> to the function bond_miimon_inspect to make the source code compact.
> 
> CC: Jay Vosburgh <j.vosburgh@gmail.com>
> CC: Veaceslav Falico <vfalico@gmail.com>
> CC: Andy Gospodarek <gospo@cumulusnetworks.com>
> Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
> ---
>  drivers/net/bonding/bond_main.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 

Not true, RCU also protects the slave dereference in bond_should_notify_peers().
Even though there's already a rcu_read_lock() while doing the dereference
itself, it is there only to please RCU, IIRC. The only "simplification" you
can do is remove the rcu_read_lock/unlock() around the slave deref in
bond_should_notify_peers and use rcu_dereference_rtnl() as it can be used either
in RCU protected region or with RTNL held. Also I think net-next is still
closed (and that's where this should be targeted at).

Cheers,
 Nik

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

* Re: [PATCH 1/1] bond: relocate rcu_read_lock and rcu_read_unlock
  2016-02-01 11:01 ` Nikolay Aleksandrov
@ 2016-02-01 11:08   ` Nikolay Aleksandrov
  0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Aleksandrov @ 2016-02-01 11:08 UTC (permalink / raw)
  To: zyjzyj2000, j.vosburgh, vfalico, gospo, netdev

On 02/01/2016 12:01 PM, Nikolay Aleksandrov wrote:
> On 02/01/2016 04:31 AM, zyjzyj2000@gmail.com wrote:
>> From: Zhu Yanjun <zyjzyj2000@gmail.com>
>>
>> rcu_read_lock and rcu_read_unlock are to protect the function
>> bond_miimon_inspect. As such, moving rcu_read_lock and rcu_read_unlock
>> to the function bond_miimon_inspect to make the source code compact.
>>
>> CC: Jay Vosburgh <j.vosburgh@gmail.com>
>> CC: Veaceslav Falico <vfalico@gmail.com>
>> CC: Andy Gospodarek <gospo@cumulusnetworks.com>
>> Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
>> ---
>>  drivers/net/bonding/bond_main.c | 9 ++++-----
>>  1 file changed, 4 insertions(+), 5 deletions(-)
>>
> 
> Not true, RCU also protects the slave dereference in bond_should_notify_peers().
> Even though there's already a rcu_read_lock() while doing the dereference
> itself, it is there only to please RCU, IIRC. The only "simplification" you

Err, I meant to please lockdep when being called with RTNL.

> can do is remove the rcu_read_lock/unlock() around the slave deref in
> bond_should_notify_peers and use rcu_dereference_rtnl() as it can be used either
> in RCU protected region or with RTNL held. Also I think net-next is still
> closed (and that's where this should be targeted at).
> 
> Cheers,
>  Nik
> 
> 

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

end of thread, other threads:[~2016-02-01 11:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-01  3:31 [PATCH 1/1] bond: relocate rcu_read_lock and rcu_read_unlock zyjzyj2000
2016-02-01 11:01 ` Nikolay Aleksandrov
2016-02-01 11:08   ` Nikolay Aleksandrov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.