PHP
首页 | 下载 | 博客 | 链接

区域

工具

查看代码的工具推荐用cscope,配合vim查找原型/函数/结构相当方便,如果怕麻烦,lxr也是个不错的选择,比如lxr.linux.no


xen 3.4 代码分析

xen的启动(schedule)
xen的运行(schedule)
schedule && credit
Event Channel
per cpu
上下文切换过程
数据结构
hypercall


xen 3.0 代码分析

xen启动/运行过程简介


资源链接

to be continue...


说明

文章中引用的版本是xen-3.0.4,分析的是x86_64平台. 为了保证行号的一致性,中文的注释没有插入回车/换行符.可能会显得有些紧巴巴的.
由于个人能力有限,网站内容存在许多错误和不足,希望读者批评指正. 本人联系方式:yubo@yubo.org

Linux-Xen

struct task_struct
struct thread_info
struct exec_domain
struct module
struct restart_block

Xen

struct domain
struct evtchn
struct vcpu
struct arch_vcpu
struct mapped_regs
struct shared_info
struct evtchn_op

port & bucket

大概的结构

xen/common/event_channel.c

  1.  #define bucket_from_port(d,p) \
  2.   ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET])
  3.  #define port_is_valid(d,p) \
  4.   (((p) >= 0) && ((p) < MAX_EVTCHNS(d)) && \
  5.   (bucket_from_port(d,p) != NULL))
  6.  #define evtchn_from_port(d,p) \
  7.   (&(bucket_from_port(d,p))[(p)&(EVTCHNS_PER_BUCKET-1)])

xen/include/xen/sched.h

  1.  #define EVTCHNS_PER_BUCKET 128 //每个桶里可以容纳128个event-chanel(port)
  2.  #define NR_EVTCHN_BUCKETS (NR_EVENT_CHANNELS / EVTCHNS_PER_BUCKET) //最大的桶数为(最大envent数/桶的容量)32

xen/include/public/xen.h

  1.  /*
  2.   * Event channel endpoints per domain:
  3.   * 1024 if a long is 32 bits; 4096 if a long is 64 bits.
  4.   */
  5.  #define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64)


+-------+-------+-------------------------------------+
|0...127|0...127|   ...                            127| evtchn
+-------+-------+-------------------------------------+
|   0   |    1  |   ...                             31| bucket
+-------+-------+-------------------------------------+
|0...127  ...255 256...                           4095| port
+-------+-------+-------------------------------------+

 
Done in 0.0612189769745 seconds