[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC][PATCH 3/4] sched: balance credits of each vcpu of a domain
By applying this patch, the credit scheduler balances credits of each active vcpu of a domain. Best regards, Naoki Nishiguchi 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); /* _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |