lkml.org 
[lkml]   [2012]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] fix idle ticks in cpu summary line of /proc/stat
On Mon, 12 Mar 2012 16:39:06 +0100
Michal Hocko <mhocko@suse.cz> wrote:

> Hmm, the semantic is that the function either returns the sleeptime or
> -1 if nohz is disabled. Bringing also online/offline into it seems
> rather confusing.
> Maybe we shouldn't do the test layer up when we call the function
> instead. This should be much cleaner IMO (it also reduced cpu_online
> call from the governors call paths which might be a problem as well):
>
> diff --git a/fs/proc/stat.c b/fs/proc/stat.c
> index 121f77c..d437258 100644
> --- a/fs/proc/stat.c
> +++ b/fs/proc/stat.c
> @@ -24,7 +24,10 @@
>
> static u64 get_idle_time(int cpu)
> {
> - u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL);
> + u64 idle, idle_time = -1ULL;
> +
> + if (cpu_online(cpu))
> + idle_time = get_cpu_idle_time_us(cpu, NULL);
>
> if (idle_time == -1ULL) {
> /* !NO_HZ so we can rely on cpustat.idle */
> @@ -38,7 +41,10 @@ static u64 get_idle_time(int cpu)
>
> static u64 get_iowait_time(int cpu)
> {
> - u64 iowait, iowait_time = get_cpu_iowait_time_us(cpu, NULL);
> + u64 iowait, iowait_time = -1ULL;
> +
> + if (cpu_online(cpu))
> + iowait_time = get_cpu_iowait_time_us(cpu, NULL);
>
> if (iowait_time == -1ULL)
> /* !NO_HZ so we can rely on cpustat.iowait */
>

That looks better and should be equivalent.

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.



\
 
 \ /
  Last update: 2012-03-12 21:45    [W:0.080 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site