您的位置:首页 > 编程语言

Xen从启动到运行的调度相关代码分析

2010-08-19 15:03 405 查看
xen/arch/x86/boot/x86_64.S 从启动到到进入运行状态
__call __start_xen
|
|__ __start_xen
|
|__init_idle_domain
| |
| |__scheduler_init()
| |
| |__SCHED_OP(init)
| |
| |__ops.init() -> csched_init()
|
|
|__reset_stack_and_jump(init_done)
|
|__init_done
|
|__startup_cpu_idle_loop()
|
|__startup_cpu_idle_loop() 进入无限循环,至此 xen从启动状态进入运行状态

__startup_cpu_idle_loop()
|
|__continue_cpu_idle_loop 无限循环执行以下的部分
|
|
|__raise_softirq(SCHEDULE_SOFTIRQ)
|
|__do_softirq(0) 处理上面引发的中断号,并调用处理函数schedule。

________schedule
|
|_______perfc_incr 可能是关于CPU的一个perfcounters结构的定义相关的
|
|_______stop_timer
|
|_______ops.do_schedule 使用调度器的这个回调函数,默认使用credit这个调度器,调用函数为csched_schedule。
|
|_______vcpu_runstate_change
|
|_______update_vcpu_system_time
|
|_______vcpu_periodic_timer_work
|
|_______context_switch

________csched_schedule
|
|_______burn_credits 重新给需要调度的vcpu计算credit,计算方法该svc应该的开始时间到当时的时间差,按ms为单位每个ms增加10 credit
|
|_______runq_insert 将当前vcpu按照优先级降序的排列顺序插入到pcpu的运行队列中
|
|_______csched_load_balance 根据全局变量 cpu_online_map 和 csched_priv.idlers计算出workers,然后在workers中遍历。
| 如果在CPU上调用的vcpu处于over状态,则会调用loadbalance从其它的cpu队列上找一个给当前cpu调用。
|
|_______csched_runq_steal 将peer中的vcpu放到当前cpu中执行

Important mocro:
#define DECLARE_PER_CPU(type, name) extern __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name

perfc_info[] = performance conter info d:/nex-4.5.2/xen/xen/common/Perfc.c
{
{ "hypercalls", TYPE_ARRAY, NR_hypercalls,},
{ "calls to multicall", TYPE_SINGLE, 0 },
{ "calls from multicall", TYPE_SINGLE, 0 },
{ "#interrupts", TYPE_SINGLE, 0 },
{ "#IPIs", TYPE_SINGLE, 0 },
{ "sched: timer", TYPE_SINGLE, 0 },
{ "sched: runs through scheduler", TYPE_SINGLE, 0 },
{ "sched: context switches", TYPE_SINGLE, 0 },
{ "PG_need_flush tlb flushes", TYPE_SINGLE, 0 },
{ name, TYPE_SINGLE, 0 },
}

enum perfcounter { performance conter type d:/nex-4.5.2/xen/xen/include/xen/Perfc.h
PERFC_hypercalls,
PERFC_LAST_hypercalls = PERFC_hypercalls + (NR_hypercalls)) - sizeof(char[2 * !!(NR_hypercalls)) - 1]),
PERFC_calls_to_multicall,
PERFC_calls_from_multicall,
PERFC_irqs,
PERFC_ipis,
PERFC_sched_irq,
PERFC_sched_run,
PERFC_sched_ctx,
PERFC_need_flush_tlb_flush,
NUM_PERFCOUNTERS
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: