sched/cpuacct: Show all possible CPUs in cpuacct output
authorZhao Lei <zhaolei@cn.fujitsu.com>
Tue, 22 Mar 2016 08:37:07 +0000 (16:37 +0800)
committerIngo Molnar <mingo@kernel.org>
Thu, 31 Mar 2016 08:45:56 +0000 (10:45 +0200)
commit5ca3726af7f66a8cc71ce4414cfeb86deb784491
tree8d0a4dbad445676935894d4bc2c7ceea346c3ee0
parent283d757378371e8044d873e661b1dccee46c5887
sched/cpuacct: Show all possible CPUs in cpuacct output

Current code show stats of online CPUs in cpuacct.statcpus,
show stats of present cpus in cpuacct.usage(_percpu), and using
present CPUs for setting cpuacct.usage.

It will cause inconsistent result when a CPU is online or offline
or hotpluged.

We should always use possible CPUs to avoid above problem.

Here are the contents of a cpuacct.usage_percpu sysfs file,
on a 4 CPU system with maxcpus=32:

Before the patch:
 # cat cpuacct.usage_percpu
 2456565 411435 1052897 832584

After the patch:
 # cat cpuacct.usage_percpu
 2456565 411435 1052897 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/a11d56cef12d0b4807f8be3a46bf9798c3014d59.1458635566.git.zhaolei@cn.fujitsu.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/cpuacct.c