From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932950AbbCQJmw (ORCPT ); Tue, 17 Mar 2015 05:42:52 -0400 Received: from cnbjrel02.sonyericsson.com ([219.141.167.166]:7365 "EHLO cnbjrel02.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932115AbbCQJmr convert rfc822-to-8bit (ORCPT ); Tue, 17 Mar 2015 05:42:47 -0400 From: "Wang, Yalin" To: "'akpm@linux-foundation.org'" , "'heiko.carstens@de.ibm.com'" , "'tglx@linutronix.de'" , "'rientjes@google.com'" , "'linux-kernel@vger.kernel.org'" Date: Tue, 17 Mar 2015 17:42:41 +0800 Subject: [RFC] proc: change /proc/stat show Thread-Topic: [RFC] proc: change /proc/stat show Thread-Index: AdBglraJ3SyTLuUQRKyFpSuy3wfInw== Message-ID: <35FD53F367049845BC99AC72306C23D104A310D42371@CNBJMBX05.corpusers.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch change /proc/stat to show each cpu, we show each present cpus instead of eacn online cpu, because some cpus are online / offline dynamically, we should also show its cputime even it is offline, some lib will read this file to detect cpu numbers, we should also return the real present cpu numbers, not just online cpus. Signed-off-by: Yalin Wang --- fs/proc/stat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 510413eb..60b39e2 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -130,7 +130,7 @@ static int show_stat(struct seq_file *p, void *v) seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(guest_nice)); seq_putc(p, '\n'); - for_each_online_cpu(i) { + for_each_present_cpu(i) { /* Copy values here to work around gcc-2.95.3, gcc-2.96 */ user = kcpustat_cpu(i).cpustat[CPUTIME_USER]; nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE]; @@ -153,6 +153,7 @@ static int show_stat(struct seq_file *p, void *v) seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(steal)); seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(guest)); seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(guest_nice)); + seq_printf(p, " %d", cpu_online(i)? 1 : 0); seq_putc(p, '\n'); } seq_printf(p, "intr %llu", (unsigned long long)sum); -- 2.2.2