linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] proc: change /proc/stat show
@ 2015-03-17  9:42 Wang, Yalin
  2015-03-17 23:02 ` David Rientjes
  0 siblings, 1 reply; 6+ messages in thread
From: Wang, Yalin @ 2015-03-17  9:42 UTC (permalink / raw)
  To: 'akpm@linux-foundation.org',
	'heiko.carstens@de.ibm.com', 'tglx@linutronix.de',
	'rientjes@google.com',
	'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 <yalin.wang@sonymobile.com>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC] proc: change /proc/stat show
  2015-03-17  9:42 [RFC] proc: change /proc/stat show Wang, Yalin
@ 2015-03-17 23:02 ` David Rientjes
  2015-03-18  1:55   ` Wang, Yalin
  0 siblings, 1 reply; 6+ messages in thread
From: David Rientjes @ 2015-03-17 23:02 UTC (permalink / raw)
  To: Wang, Yalin; +Cc: akpm, heiko.carstens, tglx, linux-kernel

On Tue, 17 Mar 2015, Wang, Yalin wrote:

> 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);

Makes sense, but why do we need to output the cpu state as part of 
/proc/stat?  This information should already be available elsewhere.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [RFC] proc: change /proc/stat show
  2015-03-17 23:02 ` David Rientjes
@ 2015-03-18  1:55   ` Wang, Yalin
  2015-03-18  2:35     ` [RFC V2] " Wang, Yalin
  0 siblings, 1 reply; 6+ messages in thread
From: Wang, Yalin @ 2015-03-18  1:55 UTC (permalink / raw)
  To: 'David Rientjes'; +Cc: akpm, heiko.carstens, tglx, linux-kernel

> -----Original Message-----
> From: David Rientjes [mailto:rientjes@google.com]
> Sent: Wednesday, March 18, 2015 7:02 AM
> To: Wang, Yalin
> Cc: akpm@linux-foundation.org; heiko.carstens@de.ibm.com;
> tglx@linutronix.de; linux-kernel@vger.kernel.org
> Subject: Re: [RFC] proc: change /proc/stat show
> 
> On Tue, 17 Mar 2015, Wang, Yalin wrote:
> 
> > 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);
> 
> Makes sense, but why do we need to output the cpu state as part of
> /proc/stat?  This information should already be available elsewhere.
Yeah,  online / offline info can be read from /sys/devices/cpu .
I can remove this line , if you think it is not needed .

Thanks




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC V2] proc: change /proc/stat show
  2015-03-18  1:55   ` Wang, Yalin
@ 2015-03-18  2:35     ` Wang, Yalin
  2015-03-18 22:07       ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Wang, Yalin @ 2015-03-18  2:35 UTC (permalink / raw)
  To: 'David Rientjes'
  Cc: 'akpm@linux-foundation.org',
	'heiko.carstens@de.ibm.com', 'tglx@linutronix.de',
	'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 <yalin.wang@sonymobile.com>
---
 fs/proc/stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index 510413eb..f009cdd 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];
-- 
2.2.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC V2] proc: change /proc/stat show
  2015-03-18  2:35     ` [RFC V2] " Wang, Yalin
@ 2015-03-18 22:07       ` Andrew Morton
  2015-03-19  7:18         ` Wang, Yalin
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2015-03-18 22:07 UTC (permalink / raw)
  To: Wang, Yalin
  Cc: 'David Rientjes', 'heiko.carstens@de.ibm.com',
	'tglx@linutronix.de',
	'linux-kernel@vger.kernel.org'

On Wed, 18 Mar 2015 10:35:39 +0800 "Wang, Yalin" <Yalin.Wang@sonymobile.com> wrote:

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

/proc/cpuinfo also skips offline CPUs.

> --- 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];

It's a non-back-compatible userspace interface change and I don't know
what might break as a result.  For example, anyone who is using
/proc/stat to find out which CPUs are online will get a surprise!



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [RFC V2] proc: change /proc/stat show
  2015-03-18 22:07       ` Andrew Morton
@ 2015-03-19  7:18         ` Wang, Yalin
  0 siblings, 0 replies; 6+ messages in thread
From: Wang, Yalin @ 2015-03-19  7:18 UTC (permalink / raw)
  To: 'Andrew Morton'
  Cc: 'David Rientjes', 'heiko.carstens@de.ibm.com',
	'tglx@linutronix.de',
	'linux-kernel@vger.kernel.org'

> -----Original Message-----
> From: Andrew Morton [mailto:akpm@linux-foundation.org]
> Sent: Thursday, March 19, 2015 6:08 AM
> To: Wang, Yalin
> Cc: 'David Rientjes'; 'heiko.carstens@de.ibm.com'; 'tglx@linutronix.de';
> 'linux-kernel@vger.kernel.org'
> Subject: Re: [RFC V2] proc: change /proc/stat show
> 
> On Wed, 18 Mar 2015 10:35:39 +0800 "Wang, Yalin"
> <Yalin.Wang@sonymobile.com> wrote:
> 
> > 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.
> 
> /proc/cpuinfo also skips offline CPUs.
> 
> > --- 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];
> 
> It's a non-back-compatible userspace interface change and I don't know
> what might break as a result.  For example, anyone who is using
> /proc/stat to find out which CPUs are online will get a surprise!
> 
I see,
I found on android, sysconf(_SC_NPROCESSORS_ONLN) function is implemented by
read /proc/stat file, and return the online processor numbers,
it will be non-compatible if I change this.

Thanks for your comments.






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-19  7:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17  9:42 [RFC] proc: change /proc/stat show Wang, Yalin
2015-03-17 23:02 ` David Rientjes
2015-03-18  1:55   ` Wang, Yalin
2015-03-18  2:35     ` [RFC V2] " Wang, Yalin
2015-03-18 22:07       ` Andrew Morton
2015-03-19  7:18         ` Wang, Yalin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).