From: Jay Vosburgh <fubar@us.ibm.com>
To: "Weiping Pan(潘卫平)" <panweiping3@gmail.com>
Cc: Andy Gospodarek (supporter:BONDING DRIVER) <andy@greyhouse.net>,
netdev@vger.kernel.org (open list:BONDING DRIVER),
linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH] bonding-tlb: better balance when choosing slaves
Date: Sat, 02 Apr 2011 11:25:03 -0700 [thread overview]
Message-ID: <20427.1301768703@death> (raw)
In-Reply-To: <1301753395-1205-1-git-send-email-panweiping3@gmail.com>
>tlb_get_least_loaded_slave() always chooses slave from
>bonding->first_slave, that gives the beginnig slaves more chances to be used.
>
>Let tlb_get_least_loaded_slave() chooses slave from a random positon in the
>slave list, make all slaves transmit packets more balanced.
If outgoing traffic is not being starved (i.e., connections are
being balanced such that they are stacking up on one slave but
under-utilizing another), then I don't understand what benefit this has.
There is already some degree of randomness, as peers will be
assigned in the order that packets are transmitted to them after each
rebalance. The busiest peers will tend to be on the earlier slaves, and
vice versa, but I'm not sure this is a bad thing.
Does this have any real gain other than making the rx/tx
statistics for the slaves more equal over time?
I haven't measured it, but I would expect that for small numbers
of peers, having them tend to stay on the same slaves over time is
probably a good thing.
-J
>Signed-off-by: Weiping Pan(潘卫平) <panweiping3@gmail.com>
>---
> drivers/net/bonding/bond_alb.c | 17 +++++++++++++++--
> 1 files changed, 15 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
>index 9bc5de3..9fa64b0 100644
>--- a/drivers/net/bonding/bond_alb.c
>+++ b/drivers/net/bonding/bond_alb.c
>@@ -36,6 +36,7 @@
> #include <linux/if_bonding.h>
> #include <linux/if_vlan.h>
> #include <linux/in.h>
>+#include <linux/random.h>
> #include <net/ipx.h>
> #include <net/arp.h>
> #include <net/ipv6.h>
>@@ -206,15 +207,27 @@ static long long compute_gap(struct slave *slave)
> /* Caller must hold bond lock for read */
> static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
> {
>- struct slave *slave, *least_loaded;
>+ struct slave *slave, *least_loaded, *start_slave;
> long long max_gap;
> int i;
>+ u8 n;
>
> least_loaded = NULL;
>+ start_slave = bond->first_slave;
> max_gap = LLONG_MIN;
>+
>+ get_random_bytes(&n, 1);
>+
>+ if (bond->slave_cnt == 0)
>+ return NULL;
>+ n = n % bond->slave_cnt;
>+
>+ for (i=0; i<n; ++i) {
>+ start_slave = start_slave->next;
>+ }
>
> /* Find the slave with the largest gap */
>- bond_for_each_slave(bond, slave, i) {
>+ bond_for_each_slave_from(bond, slave, i, start_slave) {
> if (SLAVE_IS_OK(slave)) {
> long long gap = compute_gap(slave);
>
>--
>1.7.4
>
---
-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
next prev parent reply other threads:[~2011-04-02 18:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-02 14:09 [PATCH] bonding-tlb: better balance when choosing slaves Weiping Pan(潘卫平)
2011-04-02 18:25 ` Jay Vosburgh [this message]
[not found] ` <4D9BD1A9.1040402@gmail.com>
2011-04-06 4:46 ` Jay Vosburgh
2011-04-06 5:31 ` Weiping Pan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20427.1301768703@death \
--to=fubar@us.ibm.com \
--cc=andy@greyhouse.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=panweiping3@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).