`
bulote
  • 浏览: 1311069 次
文章分类
社区版块
存档分类
最新评论

Xen's Credit Scheduler

 
阅读更多

依然是follow source code (Xen-3.4.2)

概念:Credit, Weight, Cap

想彻底搞清楚这三个词的概念,我想最重要的是把这个函数读懂:sched_credit.c/csched_acct()

Credit: 这是针对Scheduler而言的,而不是针对Domain.

csched_priv.credit = CSCHED_CREDITS_PER_ACCT * #_of_PCPU. (for example: 300 * 4 = 1200)

Weight: 这个是针对Domain而言的,Scheduler根据各个domain的Weight,来分配credit。是一个“相对”的概念

比如说:256:256和512:512是一样的,彼此各占一半。但有什么区别呢?

512:512相对于256:256,控制的精度更高。

/*

* A domain's fair share is computed using its weight in competition

* with that of all other active domains.

*

* At most, a domain can use credits to run all its active VCPUs

* for one full accounting period. We allow a domain to earn more

* only when the system-wide credit balance is negative.

*/

Cap: 这个也是针对Domain而言的,是一个“绝对”的概念。100代表一整颗PCPU的Cycles。50代表,最多可以运行半个PCPU的Cycles.

在csched_acct这个函数中:

(1) 根据各个domain的weight情况,把total_credit分配到各个domain中

credit_fair = ( ( credit_total * sdom->weight) + (weight_total - 1)

) / weight_total;

(2) 再把domain的Credit平均分配到domain的各个VCPU中

credit_fair = ( credit_fair + ( sdom->active_vcpu_count - 1 )

) / sdom->active_vcpu_count;

补充:在Xen-4.1.0中,weight已经成了Per-VCPU的概念,而不是Per-Domain。也就是说,当一个2-VCPU的VM和1-VCPU的VM拥有相同的Weight时,2-VCPU VM会获得2倍于1-VCPU VM的运行时间

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics