Re: [PATCH 2/9] Make cpuacct fields per cpu variables

From: Peter Zijlstra
Date: Mon Sep 19 2011 - 12:10:58 EST


On Wed, 2011-09-14 at 17:04 -0300, Glauber Costa wrote:
> @@ -9258,11 +9253,17 @@ static int cpuacct_stats_show(struct cgroup *cgrp, struct cftype *cft,
> struct cgroup_map_cb *cb)
> {
> struct cpuacct *ca = cgroup_ca(cgrp);
> - int i;
> + int i, cpu;
> + u64 acc[CPUACCT_STAT_NSTATS] = { 0, };
> +
> + for_each_present_cpu(cpu) {
> + u64 *vec = per_cpu_ptr(ca->cpustat, cpu);
> + for (i = 0; i < CPUACCT_STAT_NSTATS; i++)
> + acc[i] += vec[i];
> + }
>
> for (i = 0; i < CPUACCT_STAT_NSTATS; i++) {
> - s64 val = percpu_counter_read(&ca->cpustat[i]);
> - val = cputime64_to_clock_t(val);
> + s64 val = cputime64_to_clock_t(acc[i]);
> cb->fill(cb, cpuacct_stat_desc[i], val);
> }
> return 0;

The changelog doesn't mention this function is a lot more expensive now.

Someone might have daft software polling this frequently.. at least its
still fully preemptible so its not much of a problem, but it is
something to be aware of.
--
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/