[Devel] [PATCH RHEL7 COMMIT] vziolimit: port diff-vziolimit-fix-rounding-error-in-throttler

Konstantin Khorenko khorenko at odin.com
Tue May 5 02:44:41 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.4.9
------>
commit f3167fce64f7ae1d406fab9ea2845aafd8fc474d
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date:   Tue May 5 13:44:41 2015 +0400

    vziolimit: port diff-vziolimit-fix-rounding-error-in-throttler
    
    vziolimit: fix rounding error in throttler
    
    In some cases this error can lead to doubling of IO bandwidth,
    especially if the speed is small and not a divisor of 1000.
    
    https://jira.sw.ru/browse/PSBM-13302
    
    Signed-off-by: Konstantin Khlebnikov <khlebnikov at openvz.org>
    
    ====================================
    https://jira.sw.ru/browse/PSBM-20104
    
    Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 kernel/ve/vziolimit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/ve/vziolimit.c b/kernel/ve/vziolimit.c
index 890d7e8..473e2b7 100644
--- a/kernel/ve/vziolimit.c
+++ b/kernel/ve/vziolimit.c
@@ -18,6 +18,7 @@ struct throttle {
        unsigned speed;		/* maximum speed, units per second */
        unsigned burst;		/* maximum bust, units */
        unsigned latency;	/* maximum wait delay, jiffies */
+       unsigned remain;		/* units/HZ */
        unsigned long time;	/* wall time in jiffies */
        long long state;		/* current state in units */
 };
@@ -70,8 +71,8 @@ static void throttle_charge(struct throttle *th, long long charge)
 			time = now + th->latency;
 		th->time = time;
 		step *= th->speed;
-		if (do_div(step, HZ))
-			step++;
+		step += th->remain;
+		th->remain = do_div(step, HZ);
 		th->state += step;
 	}
 }



More information about the Devel mailing list