Re: [PATCH 04/10] Display /proc/stat information per cgroup

From: Glauber Costa
Date: Wed Oct 05 2011 - 08:11:53 EST


On 10/05/2011 01:04 PM, Peter Zijlstra wrote:
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.
Okay, I will clean this up for next submission.

--
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/