OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 02/10] Containers(V10): Example CPU accounting subsystem
Re: [PATCH 02/10] Containers(V10): Example CPU accounting subsystem [message #13566 is a reply to message #13544] Wed, 30 May 2007 07:16 Go to previous message
Andrew Morton is currently offline  Andrew Morton
Messages: 127
Registered: December 2005
Senior Member
On Tue, 29 May 2007 06:01:06 -0700 menage@google.com wrote:

> This example demonstrates how to use the generic container subsystem
> for a simple resource tracker that counts, for the processes in a
> container, the total CPU time used and the %CPU used in the last
> complete 10 second interval.
>
> ...
>
> --- /dev/null
> +++ container-2.6.22-rc2-mm1/kernel/cpu_acct.c
> @@ -0,0 +1,185 @@
> +/*
> + * kernel/cpu_acct.c - CPU accounting container subsystem
> + *
> + * Copyright (C) Google Inc, 2006
> + *
> + * Developed by Paul Menage (menage@google.com) and Balbir Singh
> + * (balbir@in.ibm.com)
> + *
> + */
>
> ...
>
> +static u64 cpuusage_read(struct container *cont,
> + struct cftype *cft)
> +{
> + struct cpuacct *ca = container_ca(cont);
> + u64 time;
> +
> + spin_lock_irq(&ca->lock);
> + cpuusage_update(ca);
> + time = cputime64_to_jiffies64(ca->time);
> + spin_unlock_irq(&ca->lock);
> +
> + /* Convert 64-bit jiffies to seconds */
> + time *= 1000;
> + do_div(time, HZ);

hm, we have jiffies_to_lotsofthings, but we don't appear to have a
jiffies_to_seconds. How odd.
 
Read Message
Read Message
Previous Topic: Re: [ckrm-tech] [RFC] [PATCH 0/3] Add group fairness to CFS
Next Topic: Re: Pid namespaces approaches testing results
Goto Forum:
  


Current Time: Tue Sep 09 23:07:28 GMT 2025

Total time taken to generate the page: 0.12412 seconds