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的运行时间

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值