分类: 虚拟化
2014-04-04 23:55:43
CPUTIME_USER,};
CPUTIME_NICE,
CPUTIME_SYSTEM,
CPUTIME_SOFTIRQ,
CPUTIME_IRQ,
CPUTIME_IDLE,
CPUTIME_IOWAIT,
CPUTIME_STEAL,
CPUTIME_GUEST,
CPUTIME_GUEST_NICE,
NR_STATS,
u64 cpustat[NR_STATS];};
参考资料(金步国 Linux-3.10-x86_64 内核配置选项简介
) :
Cputime accounting
CPU时间统计方式
Simple tick based cputime accounting
CONFIG_TICK_CPU_ACCOUNTING 简单的基于滴答的统计,适用于大多数场合 Deterministic task and CPU time accounting CONFIG_VIRT_CPU_ACCOUNTING_NATIVE 通过读取CPU计数器进行统计,可以提供更精确的统计,但是对性能有一些不利影响. Full dynticks CPU time accounting CONFIG_VIRT_CPU_ACCOUNTING_GEN 利用上下文跟踪子系统,通过观察每一个内核与用户空间的边界进行统计.该选项对性能有显著的不良影响,目前仅用于完全无滴答子系统(CONFIG_NO_HZ_FULL)的调试 Fine granularity task level IRQ time accounting CONFIG_IRQ_TIME_ACCOUNTING 通过读取TSC时间戳进行统计,这是统计进程IRQ时间的更细粒度的统计方式,但对性能有些不良影响(特别是在RDTSC指令速度较慢的CPU上). |
int index;
if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
account_guest_time(p, cputime, cputime_scaled);return;
}}
............
/*}
* This is running in ioctl context so we can avoid
* the call to vtime_account() with its unnecessary idle check.
*/
vtime_account_system(current);
current->flags |= PF_VCPU;
/*}
* This is running in ioctl context so we can avoid
* the call to vtime_account() with its unnecessary idle check.
*/
vtime_account_system(current);
current->flags &= ~PF_VCPU;
......
preempt_disable();
......
local_irq_disable();
......
kvm_guest_enter();
......
kvm_x86_ops->run(vcpu); //vmx.c vmx_vcpu_run(vcpu)
......
local_irq_enable();
......
kvm_guest_exit();
preempt_enable();
......}
r = kvm_x86_ops->handle_exit(vcpu);
return r;
......
/* Enter guest mode */}
"jne 1f \n\t"
__ex(ASM_VMX_VMLAUNCH) "\n\t"
"jmp 2f \n\t"
"1: " __ex(ASM_VMX_VMRESUME) "\n\t"
"2: "
......
vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
......