From: "Jan Beulich" Subject: Re: [PATCH 2/2] credit2: track residual from divisions done during accounting Date: Wed, 27 Feb 2013 09:40:47 +0000 Message-ID: <512DE2AF02000078000C15F0@nat28.tlf.novell.com> References: <1361898497-5719-1-git-send-email-george.dunlap@eu.citrix.com> <1361898497-5719-2-git-send-email-george.dunlap@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1361898497-5719-2-git-send-email-george.dunlap@eu.citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: George Dunlap Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 26.02.13 at 18:08, George Dunlap wrote: > @@ -271,16 +272,24 @@ struct csched_dom { > > /* > * Time-to-credit, credit-to-time. > + * > + * We keep track of the "residual" time to make sure that frequent short > + * schedules still get accounted for in the end. > + * > * FIXME: Do pre-calculated division? > */ > -static s_time_t t2c(struct csched_runqueue_data *rqd, s_time_t time, struct csched_vcpu *svc) > +static void t2c_update(struct csched_runqueue_data *rqd, s_time_t time, > + struct csched_vcpu *svc) > { > - return time * rqd->max_weight / svc->weight; > + uint64_t val = time * rqd->max_weight + svc->residual; > + > + svc->residual = do_div(val, svc->weight); > + svc->credit -= val; > } > > static s_time_t c2t(struct csched_runqueue_data *rqd, s_time_t credit, struct csched_vcpu *svc) > { > - return credit * svc->weight / rqd->max_weight; > + return (credit * svc->weight) / rqd->max_weight; So you dropped the subtraction of svc->residual here - why? And if indeed intended, the insertion of parentheses here could be dropped? Jan