Re: [RESEND 2][PATCH 0/4] Virtual Machine Time Accounting

Previous thread: [PATCH] x86: multi-byte single instruction NOPs by Jan Beulich on Monday, September 10, 2007 - 9:08 am. (1 message)

Next thread: [RESEND 2][PATCH 1/4] Introduce a new field "guest" in cpustat by Laurent Vivier on Monday, September 10, 2007 - 10:12 am. (1 message)
To: Ingo Molnar <mingo@...>
Cc: linux-kernel <linux-kernel@...>
Date: Monday, September 10, 2007 - 10:12 am

This new version remove conditional compilation on GUEST_ACCOUNTING.

----------

The aim of these four patches is to introduce Virtual Machine time accounting.

[PATCH 1/4] as recent CPUs introduce a third running state, after "user" and
"system", we need 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/4] like for cpustat, introduce the "gtime" (guest time of the task) and
"cgtime" (guest time of the task children) fields for the
tasks. Modify signal_struct and task_struct. Modify /proc/<pid>/stat to display
these new fields.

[PATCH 3/4] 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. Update "gtime" and "cgtime" in signal_struct and
task_struct accordingly.

[PATCH 4/4] Modify KVM to update guest time accounting.

Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
--
------------- Laurent.Vivier@bull.net --------------
"Software is hard" - Donald Knuth

-

To: Laurent Vivier <Laurent.Vivier@...>
Cc: Ingo Molnar <mingo@...>, linux-kernel <linux-kernel@...>
Date: Monday, October 15, 2007 - 6:51 am

I would move this line
       if (p->flags & PF_VCPU) {
               account_guest_time(p, cputime);
------>               p->flags &= ~PF_VCPU; <---------
               return;
       }
into kvm_guest_exit. Otherwise a guest that is running very long in
guest context would only get the first tick accounted as guest time, no?

Besides that, this looks good and should work for kvm on s390 as well.
Thanks Laurent.

Christian

-

To: Laurent Vivier <Laurent.Vivier@...>
Cc: linux-kernel <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Monday, September 10, 2007 - 3:41 pm

excellent! For all 4 patches:

Acked-by: Ingo Molnar <mingo@elte.hu>

i'd suggest inclusion into 2.6.24.

can the /proc change break anything? Any old procps version perhaps?

Ingo
-

To: Ingo Molnar <mingo@...>
Cc: Laurent Vivier <Laurent.Vivier@...>, linux-kernel <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Tuesday, September 11, 2007 - 10:05 am

We have added numbers to the cpu lines in /proc/stat since
early 2.6. All the programs parsing /proc/stat should just
scan for a number of numbers from the start of the line, without
trying to scan for the terminating newline.

--
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is. Each group
calls the other unpatriotic.
-

To: Ingo Molnar <mingo@...>
Cc: linux-kernel <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Tuesday, September 11, 2007 - 5:38 am

[Empty message]
To: Laurent Vivier <Laurent.Vivier@...>
Cc: Ingo Molnar <mingo@...>, linux-kernel <linux-kernel@...>, Andrew Morton <akpm@...>
Date: Tuesday, September 11, 2007 - 2:59 pm

It's not. At the time iowait was introduced I verified this
in procps.

--
All Rights Reversed
-

To: Laurent Vivier <Laurent.Vivier@...>
Cc: Ingo Molnar <mingo@...>, linux-kernel <linux-kernel@...>
Date: Monday, September 10, 2007 - 3:37 pm

Acked-by: Rik van Riel <riel@redhat.com>

--
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is. Each group
calls the other unpatriotic.
-

Previous thread: [PATCH] x86: multi-byte single instruction NOPs by Jan Beulich on Monday, September 10, 2007 - 9:08 am. (1 message)

Next thread: [RESEND 2][PATCH 1/4] Introduce a new field "guest" in cpustat by Laurent Vivier on Monday, September 10, 2007 - 10:12 am. (1 message)