Oops, I've missed the "#include <math.h>" from this second version of the patch. To avoid warnings, I will resend it.

Zoli

On 07/01/13 20:27, Ben Pfaff wrote:
Ethan, do you have any thoughts about this patch?  It seems
reasonable, but I'd like another set of eyes on it before I apply it.

On Sat, Jan 05, 2013 at 09:41:19PM +0000, Zoltan Kiss wrote:
The old algorithm tries to converge to 0, despite it would mean a very
unbalanced situation. 1 is a more desirable goal.

Signed-off-by: Zoltan Kiss <zoltan.k...@citrix.com>
---
  lib/bond.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/bond.c b/lib/bond.c
index 2c59f9d..87962de 100644
--- a/lib/bond.c
+++ b/lib/bond.c
@@ -771,8 +771,9 @@ choose_entry_to_migrate(const struct bond_slave *from, 
uint64_t to_tx_bytes)
          delta = e->tx_bytes;
          old_ratio = (double)from->tx_bytes / to_tx_bytes;
          new_ratio = (double)(from->tx_bytes - delta) / (to_tx_bytes + delta);
-        if (old_ratio - new_ratio > 0.1) {
-            /* Would decrease the ratio, move it. */
+        if ( (old_ratio - new_ratio > 0.1) &&
+             (fabs(new_ratio-1) < fabs(old_ratio-1)) ) {
+            /* Ideal ratio is 1, move it if the new ratio is closer to it. */
              return e;
          }
      }

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to