From mboxrd@z Thu Jan 1 00:00:00 1970 From: NISHIGUCHI Naoki Subject: [RFC][PATCH 3/4] sched: balance credits of each vcpu of a domain Date: Fri, 05 Dec 2008 19:07:00 +0900 Message-ID: <4938FD44.3000409@jp.fujitsu.com> References: <4938FC06.9080008@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090400010603050908030800" Return-path: In-Reply-To: <4938FC06.9080008@jp.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: George Dunlap , xen-devel@lists.xensource.com Cc: Ian.Pratt@eu.citrix.com, disheng.su@intel.com, keir.fraser@eu.citrix.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------090400010603050908030800 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit By applying this patch, the credit scheduler balances credits of each active vcpu of a domain. Best regards, Naoki Nishiguchi --------------090400010603050908030800 Content-Type: text/x-patch; name="credit_balance.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="credit_balance.patch" diff -r a00eb6595d3c xen/common/sched_credit.c --- a/xen/common/sched_credit.c Sat Nov 29 09:07:52 2008 +0000 +++ b/xen/common/sched_credit.c Fri Dec 05 18:16:34 2008 +0900 @@ -835,7 +835,8 @@ csched_acct(void) int credit_balance; int credit_xtra; int credit; - + int64_t credit_sum; + int credit_average; spin_lock_irqsave(&csched_priv.lock, flags); @@ -872,6 +873,18 @@ csched_acct(void) BUG_ON( sdom->active_vcpu_count == 0 ); BUG_ON( sdom->weight == 0 ); BUG_ON( sdom->weight > weight_left ); + + /* Compute the average of active VCPUs. */ + credit_sum = 0; + list_for_each_safe( iter_vcpu, next_vcpu, &sdom->active_vcpu ) + { + svc = list_entry(iter_vcpu, struct csched_vcpu, active_vcpu_elem); + BUG_ON( sdom != svc->sdom ); + + credit_sum += atomic_read(&svc->credit); + } + credit_average = ( credit_sum + (sdom->active_vcpu_count - 1) + ) / sdom->active_vcpu_count; weight_left -= sdom->weight; @@ -944,8 +957,9 @@ csched_acct(void) svc = list_entry(iter_vcpu, struct csched_vcpu, active_vcpu_elem); BUG_ON( sdom != svc->sdom ); - /* Increment credit */ - atomic_add(credit_fair, &svc->credit); + /* Balance and increment credit */ + credit = atomic_read(&svc->credit); + atomic_add(credit_average - credit + credit_fair, &svc->credit); credit = atomic_read(&svc->credit); /* --------------090400010603050908030800 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------090400010603050908030800--