[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1317805495.6766.5.camel@twins>
Date: Wed, 05 Oct 2011 11:04:55 +0200
From: Peter Zijlstra <a.p.zijlstra@...llo.nl>
To: Glauber Costa <glommer@...allels.com>
Cc: linux-kernel@...r.kernel.org, paul@...lmenage.org,
lizf@...fujitsu.com, daniel.lezcano@...e.fr,
jbottomley@...allels.com
Subject: Re: [PATCH 04/10] Display /proc/stat information per cgroup
On Sun, 2011-10-02 at 23:21 +0400, Glauber Costa wrote:
> @@ -3868,10 +3897,14 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
> */
> void account_steal_time(cputime_t cputime)
> {
> - u64 *cpustat = kstat_this_cpu->cpustat;
> + struct kernel_stat *kstat;
> u64 cputime64 = cputime_to_cputime64(cputime);
> -
> - cpustat[STEAL] += cputime64;
> +#ifdef CONFIG_CGROUP_SCHED
> + kstat = this_cpu_ptr(root_task_group.cpustat);
> +#else
> + kstat = __get_cpu_var(kstat);
> +#endif
> + kstat->cpustat[STEAL] += cputime64;
> }
> @@ -9111,17 +9179,28 @@ int cpu_cgroup_proc_stat(struct seq_file *p)
> jif = boottime.tv_sec;
>
> for_each_possible_cpu(i) {
> - user += kstat_this_cpu->cpustat[USER];
> - nice += kstat_this_cpu->cpustat[NICE];
> - system += kstat_this_cpu->cpustat[SYSTEM];
> - idle += kstat_this_cpu->cpustat[IDLE];
> + struct kernel_stat *kstat, *idle_kstat;
> +#ifdef CONFIG_CGROUP_SCHED
> + kstat = per_cpu_ptr(tg->cpustat, i);
> + idle_kstat = per_cpu_ptr(root_task_group.cpustat, i);
> +#else
> + kstat = per_cpu(kstat, i);
> + idle_kstat = kstat;
> +#endif
> +
> + user += kstat->cpustat[USER];
> + nice += kstat->cpustat[NICE];
> + system += kstat->cpustat[SYSTEM];
That if-deffery just begs to be killed by some helper function. Both
variants appear multiple times I think.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists