Re: [RFC PATCH] cpuacct: per-cgroup utime/stime statistics - v1

From: Bharata B Rao
Date: Thu Mar 12 2009 - 00:44:22 EST


On Wed, Mar 11, 2009 at 08:46:57PM +0530, Balbir Singh wrote:
> * Bharata B Rao <bharata@xxxxxxxxxxxxxxxxxx> [2009-03-10 18:12:08]:
>
> Hi, Bharata,
>
> I did a quick run of the patch on my machine. The patch applied and
> compile cleanly, here are a few comments?
>
> 1. We could consider enhancing the patch to account for irq, softirq,
> etc time like cpustat does. Not right away, but iteratively

Yes that should not be a problem. We can add those easily if needed.

> 2. The accounting is converted to milliseconds, I would much rather
> export it in cputime to be consistent with other cpu accounting.
> I remember we used to return nanosecond accurate accounting and then
> moved to cputime based accounting for cpuacct.

Ok had thought about it but was hesitant to do because that makes
percpu_counters to work directly on cputime_t type. But I guess that is fine.

> 3. How do we deal with CPU hotplug. Since we use a per-cpu counter,
> any hotplug would mean that the data related to the offlined CPU is
> lost. That is how the current CPU accounting system seems to work.

Not a problem as percpu_counter handles hotplug events as you noted
in the other thread.

> >
> > @@ -9462,20 +9479,33 @@ static struct cgroup_subsys_state *cpuac
> > struct cgroup_subsys *ss, struct cgroup *cgrp)
> > {
> > struct cpuacct *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
> > + int i;
> >
> > if (!ca)
> > - return ERR_PTR(-ENOMEM);
> > + goto out1;
> >
> > ca->cpuusage = alloc_percpu(u64);
> > - if (!ca->cpuusage) {
> > - kfree(ca);
> > - return ERR_PTR(-ENOMEM);
> > - }
> > + if (!ca->cpuusage)
> > + goto out2;
> > +
> > + for (i = 0; i < CPUACCT_STAT_NSTATS; i++)
> > + if (percpu_counter_init(&ca->cpustat[i], 0))
> > + goto out3;
> >
> > if (cgrp->parent)
> > ca->parent = cgroup_ca(cgrp->parent);
> >
> > return &ca->css;
> > +
> > +out3:
> > + i--;
> > + while (i-- >= 0)
> > + percpu_counter_destroy(&ca->cpustat[i]);
> > + free_percpu(ca->cpuusage);
> > +out2:
> > + kfree(ca);
> > +out1:
> > + return ERR_PTR(-ENOMEM);
> > }
> >
>
> Don't like out* as labels, please let us have more meaningful labels.

Ok, I can change them if you don't like out* labels :)

Regards,
Bharata.
--
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/