From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Vivier Subject: [PATCH 0/2][KVM] guest time accounting Date: Fri, 10 Aug 2007 17:58:49 +0200 Message-ID: <46BC8B39.6050202@bull.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Cc: linux-kernel To: kvm-devel Return-path: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 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. Signed-Off-by: Laurent Vivier -- ------------- Laurent.Vivier@bull.net -------------- "Software is hard" - Donald Knuth