diff -r 64618a20b9de xen/common/sched_credit.c --- a/xen/common/sched_credit.c Thu Jan 22 13:22:54 2009 +0900 +++ b/xen/common/sched_credit.c Thu Jan 22 13:42:04 2009 +0900 @@ -202,6 +202,7 @@ struct csched_vcpu { struct csched_dom *sdom; struct vcpu *vcpu; atomic_t credit; + atomic_t boost_credit; int prev_credit; uint16_t flags; int16_t pri; @@ -549,14 +550,6 @@ csched_vcpu_acct(unsigned int cpu) ASSERT( svc->sdom != NULL ); /* - * If this VCPU's priority was boosted when it last awoke, reset it. - * If the VCPU is found here, then it's consuming a non-negligeable - * amount of CPU resources and should no longer be boosted. - */ - if ( svc->pri == CSCHED_PRI_TS_BOOST ) - svc->pri = CSCHED_PRI_TS_UNDER; - - /* * If it's been active a while, check if we'd be better off * migrating it to run elsewhere (see multi-core and multi-thread * support in csched_cpu_pick()). @@ -591,6 +584,7 @@ csched_vcpu_init(struct vcpu *vc) svc->sdom = sdom; svc->vcpu = vc; atomic_set(&svc->credit, 0); + atomic_set(&svc->boost_credit, 0); svc->prev_credit = 0; svc->flags = 0U; svc->pri = is_idle_domain(dom) ? CSCHED_PRI_IDLE : CSCHED_PRI_TS_UNDER; @@ -706,6 +700,8 @@ csched_vcpu_wake(struct vcpu *vc) !(svc->flags & CSCHED_FLAG_VCPU_PARKED) ) { svc->pri = CSCHED_PRI_TS_BOOST; + atomic_add(CSCHED_CREDITS_PER_TICK, &svc->boost_credit); + atomic_sub(CSCHED_CREDITS_PER_TICK, &svc->credit); } /* Put the VCPU on the runq and tickle CPUs */ @@ -954,11 +950,14 @@ csched_acct(void) credit_sum = 0; list_for_each_safe( iter_vcpu, next_vcpu, &sdom->active_vcpu ) { - int adjust; + int adjust, boost_credit; svc = list_entry(iter_vcpu, struct csched_vcpu, active_vcpu_elem); BUG_ON( sdom != svc->sdom ); + boost_credit = atomic_read(&svc->boost_credit); + atomic_set(&svc->boost_credit, 0); + atomic_add(boost_credit, &svc->credit); credit = atomic_read(&svc->credit); adjust = svc->prev_credit - credit - CSCHED_CREDITS_PER_TSLICE; if ( adjust > 0 ) @@ -1290,6 +1289,22 @@ csched_schedule(s_time_t now) ) / ( MILLISECS(CSCHED_MSECS_PER_TSLICE) / CSCHED_CREDITS_PER_TSLICE ); + if ( scurr->pri == CSCHED_PRI_TS_BOOST ) + { + int boost_credit = atomic_read(&scurr->boost_credit); + + if ( boost_credit > consumed ) + { + atomic_sub(consumed, &scurr->boost_credit); + consumed = 0; + } + else + { + atomic_sub(boost_credit, &scurr->boost_credit); + consumed -= boost_credit; + scurr->pri = CSCHED_PRI_TS_UNDER; + } + } if ( consumed > 0 && !is_idle_vcpu(current) ) atomic_sub(consumed, &scurr->credit); @@ -1366,8 +1381,9 @@ csched_dump_vcpu(struct csched_vcpu *svc if ( sdom ) { - printk(" credit=%i [w=%u,p=%u]", + printk(" credit=%i bc=%i [w=%u,p=%u]", atomic_read(&svc->credit), + atomic_read(&svc->boost_credit), sdom->weight, sdom->percent); #ifdef CSCHED_STATS