Re: /proc 2.6.24 changes for guest CPU accounting

From: AP
Date: Tue Jun 24 2008 - 09:04:54 EST


On Mon, Jun 23, 2008 at 12:51:11PM +0200, Michael Kerrisk wrote:
> > You must also notes that "user time" includes "guest time", if you want
> > real "user time" you must subtract "guest time".
> > The "guest time" is included in "user time" to not loose it when the
> > "reader" is not aware of the "guest time".
>
> Hi Laurent (and Christian)
>
> So, I just want to confirm. You are saying that guest_time and
> cguest_time are respectively also included in the following fields
>
> utime %lu
...
> cutime %ld
...
> Right?

If this function in ./kernel/sched.c is anything to go by and I'm not
being a complete noob, yes:

/*
* Account guest cpu time to a process.
* @p: the process that the cpu time gets accounted to
* @cputime: the cpu time spent in virtual machine since the last update
*/
static void account_guest_time(struct task_struct *p, cputime_t cputime)
{
cputime64_t tmp;
struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;

tmp = cputime_to_cputime64(cputime);

p->utime = cputime_add(p->utime, cputime);
p->gtime = cputime_add(p->gtime, cputime);

cpustat->user = cputime64_add(cpustat->user, tmp);
cpustat->guest = cputime64_add(cpustat->guest, tmp);
}

As such, I'll follow up with a new version of my previous patch.

AP
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/