Avi Kivity wrote: > Laurent Vivier wrote: >> The aim of these two patches is to measure the CPU time used by a virtual >> machine. All comments are welcome... I'm not sure it's the good way to >> do that. >> >> [PATCH 1/2] introduce a new field, "guest", in cpustat to store the >> time used by >> the CPU to run virtual CPU. Modify /proc/stat to display this new field. >> >> [PATCH 2/2] modify account_system_time() to add cputime to >> cpustat->guest if we >> are running a VCPU. We add this cputime to cpustat->user instead of >> cpustat->system because this part of KVM code is in fact user code >> although it >> is executed in the kernel. We duplicate VCPU time between guest and >> user to >> allow an unmodified "top(1)" to display correct value. A modified >> "top(1)" is >> able to display good cpu user time and cpu guest time by subtracting >> cpu guest >> time from cpu user time. >> > > [copying Ingo and Rusty] > > The patches look good. A couple of comments: > > - perhaps the new fields should be guarded by a #ifdef CONFIG_HYPERVISOR > (selected by CONFIG_KVM)? that way the (minor) additional overhead is > only incurred if it can possibly be used. I imagine that our canine > cousin will want to use this as well. There is also a CONFIG_VIRTUALIZATION and a CONFIG_VIRT_CPU_ACCOUNTING (from s390 and powerpc) Which one to use ? I'm wondering if we can have a more accurate accounting: - For the moment we add all system time since the previous entering to the VCPU to the guest time (and I guess there is some real system time in it ???) - Perhaps we can sum nanoseconds spent in the VCPU and add it to cpustat when these ns are greater than 1 ms ? (I'm trying to make something in this way) > - I think that there is per-task accounting of user time and system > time; that should be extended as well. it should be easy to do too... Laurent -- ------------- [email protected] -------------- "Software is hard" - Donald Knuth
Attachment:
signature.asc
Description: OpenPGP digital signature
- Follow-Ups:
- Re: [kvm-devel] [PATCH 0/2][KVM] guest time accounting
- From: Christian Borntraeger <[email protected]>
- Re: [kvm-devel] [PATCH 0/2][KVM] guest time accounting
- From: Avi Kivity <[email protected]>
- Re: [kvm-devel] [PATCH 0/2][KVM] guest time accounting
- References:
- [PATCH 0/2][KVM] guest time accounting
- From: Laurent Vivier <[email protected]>
- Re: [kvm-devel] [PATCH 0/2][KVM] guest time accounting
- From: Avi Kivity <[email protected]>
- [PATCH 0/2][KVM] guest time accounting
- Prev by Date: Re: [PATCH] [244/2many] MAINTAINERS - IEEE 1394 SUBSYSTEM
- Next by Date: Re: [PATCH] [198/2many] MAINTAINERS - FIREWIRE SUBSYSTEM
- Previous by thread: Re: [kvm-devel] [PATCH 0/2][KVM] guest time accounting
- Next by thread: Re: [kvm-devel] [PATCH 0/2][KVM] guest time accounting
- Index(es):