Commit 733ab639 authored by dingtianhong's avatar dingtianhong Committed by David S. Miller

bonding: rebuild the lock use for bond_alb_monitor()

The bond_alb_monitor use bond lock to protect the bond slave list,
it is no effect here, we need to use RTNL or RCU to replace bond lock,
the bond_alb_monitor will called 10 times one second, RTNL may loss
performance here, so I replace bond lock with RCU to protect the
bond slave list, also the RTNL is preserved, the logic of the monitor
did not changed.
Suggested-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Suggested-by: default avatarJay Vosburgh <fubar@us.ibm.com>
Suggested-by: default avatarVeaceslav Falico <vfalico@redhat.com>
Signed-off-by: default avatarDing Tianhong <dingtianhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4cb4f97b
...@@ -815,7 +815,7 @@ static void rlb_rebalance(struct bonding *bond) ...@@ -815,7 +815,7 @@ static void rlb_rebalance(struct bonding *bond)
for (; hash_index != RLB_NULL_INDEX; for (; hash_index != RLB_NULL_INDEX;
hash_index = client_info->used_next) { hash_index = client_info->used_next) {
client_info = &(bond_info->rx_hashtbl[hash_index]); client_info = &(bond_info->rx_hashtbl[hash_index]);
assigned_slave = rlb_next_rx_slave(bond); assigned_slave = __rlb_next_rx_slave(bond);
if (assigned_slave && (client_info->slave != assigned_slave)) { if (assigned_slave && (client_info->slave != assigned_slave)) {
client_info->slave = assigned_slave; client_info->slave = assigned_slave;
client_info->ntt = 1; client_info->ntt = 1;
...@@ -1494,14 +1494,14 @@ void bond_alb_monitor(struct work_struct *work) ...@@ -1494,14 +1494,14 @@ void bond_alb_monitor(struct work_struct *work)
struct list_head *iter; struct list_head *iter;
struct slave *slave; struct slave *slave;
read_lock(&bond->lock);
if (!bond_has_slaves(bond)) { if (!bond_has_slaves(bond)) {
bond_info->tx_rebalance_counter = 0; bond_info->tx_rebalance_counter = 0;
bond_info->lp_counter = 0; bond_info->lp_counter = 0;
goto re_arm; goto re_arm;
} }
rcu_read_lock();
bond_info->tx_rebalance_counter++; bond_info->tx_rebalance_counter++;
bond_info->lp_counter++; bond_info->lp_counter++;
...@@ -1514,7 +1514,7 @@ void bond_alb_monitor(struct work_struct *work) ...@@ -1514,7 +1514,7 @@ void bond_alb_monitor(struct work_struct *work)
*/ */
read_lock(&bond->curr_slave_lock); read_lock(&bond->curr_slave_lock);
bond_for_each_slave(bond, slave, iter) bond_for_each_slave_rcu(bond, slave, iter)
alb_send_learning_packets(slave, slave->dev->dev_addr); alb_send_learning_packets(slave, slave->dev->dev_addr);
read_unlock(&bond->curr_slave_lock); read_unlock(&bond->curr_slave_lock);
...@@ -1527,7 +1527,7 @@ void bond_alb_monitor(struct work_struct *work) ...@@ -1527,7 +1527,7 @@ void bond_alb_monitor(struct work_struct *work)
read_lock(&bond->curr_slave_lock); read_lock(&bond->curr_slave_lock);
bond_for_each_slave(bond, slave, iter) { bond_for_each_slave_rcu(bond, slave, iter) {
tlb_clear_slave(bond, slave, 1); tlb_clear_slave(bond, slave, 1);
if (slave == bond->curr_active_slave) { if (slave == bond->curr_active_slave) {
SLAVE_TLB_INFO(slave).load = SLAVE_TLB_INFO(slave).load =
...@@ -1551,11 +1551,9 @@ void bond_alb_monitor(struct work_struct *work) ...@@ -1551,11 +1551,9 @@ void bond_alb_monitor(struct work_struct *work)
* dev_set_promiscuity requires rtnl and * dev_set_promiscuity requires rtnl and
* nothing else. Avoid race with bond_close. * nothing else. Avoid race with bond_close.
*/ */
read_unlock(&bond->lock); rcu_read_unlock();
if (!rtnl_trylock()) { if (!rtnl_trylock())
read_lock(&bond->lock);
goto re_arm; goto re_arm;
}
bond_info->rlb_promisc_timeout_counter = 0; bond_info->rlb_promisc_timeout_counter = 0;
...@@ -1567,7 +1565,7 @@ void bond_alb_monitor(struct work_struct *work) ...@@ -1567,7 +1565,7 @@ void bond_alb_monitor(struct work_struct *work)
bond_info->primary_is_promisc = 0; bond_info->primary_is_promisc = 0;
rtnl_unlock(); rtnl_unlock();
read_lock(&bond->lock); rcu_read_lock();
} }
if (bond_info->rlb_rebalance) { if (bond_info->rlb_rebalance) {
...@@ -1589,11 +1587,9 @@ void bond_alb_monitor(struct work_struct *work) ...@@ -1589,11 +1587,9 @@ void bond_alb_monitor(struct work_struct *work)
} }
} }
} }
rcu_read_unlock();
re_arm: re_arm:
queue_delayed_work(bond->wq, &bond->alb_work, alb_delta_in_ticks); queue_delayed_work(bond->wq, &bond->alb_work, alb_delta_in_ticks);
read_unlock(&bond->lock);
} }
/* assumption: called before the slave is attached to the bond /* assumption: called before the slave is attached to the bond
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment