Commit cf5f9044934658dd3ffc628a60cd37c70f8168b1
Committed by
Jeff Garzik
1 parent
1b76b31693
Exists in
master
and in
7 other branches
bonding: Convert balance-rr transmit to new locking
Change locking in balance-rr transmit processing to use a free running counter to determine which slave to transmit on. Instead, a free-running counter is maintained, and modulo arithmetic used to select a slave for transmit. This removes lock operations from the TX path, and eliminates a deadlock introduced by the conversion to work queues. Signed-off-by: Andy Gospodarek <andy@greyhouse.net> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Showing 2 changed files with 13 additions and 13 deletions Side-by-side Diff
drivers/net/bonding/bond_main.c
... | ... | @@ -4057,8 +4057,7 @@ |
4057 | 4057 | { |
4058 | 4058 | struct bonding *bond = bond_dev->priv; |
4059 | 4059 | struct slave *slave, *start_at; |
4060 | - int i; | |
4061 | - int res = 1; | |
4060 | + int i, slave_no, res = 1; | |
4062 | 4061 | |
4063 | 4062 | read_lock(&bond->lock); |
4064 | 4063 | |
4065 | 4064 | |
4066 | 4065 | |
4067 | 4066 | |
4068 | 4067 | |
... | ... | @@ -4066,28 +4065,28 @@ |
4066 | 4065 | goto out; |
4067 | 4066 | } |
4068 | 4067 | |
4069 | - read_lock(&bond->curr_slave_lock); | |
4070 | - slave = start_at = bond->curr_active_slave; | |
4071 | - read_unlock(&bond->curr_slave_lock); | |
4068 | + /* | |
4069 | + * Concurrent TX may collide on rr_tx_counter; we accept that | |
4070 | + * as being rare enough not to justify using an atomic op here | |
4071 | + */ | |
4072 | + slave_no = bond->rr_tx_counter++ % bond->slave_cnt; | |
4072 | 4073 | |
4073 | - if (!slave) { | |
4074 | - goto out; | |
4074 | + bond_for_each_slave(bond, slave, i) { | |
4075 | + slave_no--; | |
4076 | + if (slave_no < 0) { | |
4077 | + break; | |
4078 | + } | |
4075 | 4079 | } |
4076 | 4080 | |
4081 | + start_at = slave; | |
4077 | 4082 | bond_for_each_slave_from(bond, slave, i, start_at) { |
4078 | 4083 | if (IS_UP(slave->dev) && |
4079 | 4084 | (slave->link == BOND_LINK_UP) && |
4080 | 4085 | (slave->state == BOND_STATE_ACTIVE)) { |
4081 | 4086 | res = bond_dev_queue_xmit(bond, skb, slave->dev); |
4082 | - | |
4083 | - write_lock(&bond->curr_slave_lock); | |
4084 | - bond->curr_active_slave = slave->next; | |
4085 | - write_unlock(&bond->curr_slave_lock); | |
4086 | - | |
4087 | 4087 | break; |
4088 | 4088 | } |
4089 | 4089 | } |
4090 | - | |
4091 | 4090 | |
4092 | 4091 | out: |
4093 | 4092 | if (res) { |
drivers/net/bonding/bonding.h