Re: [PATCH] fix idle ticks in cpu summary line of /proc/stat
From: Martin Schwidefsky
Date: Mon Mar 12 2012 - 16:41:52 EST
On Mon, 12 Mar 2012 16:39:06 +0100
Michal Hocko <mhocko@xxxxxxx> 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.
--
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/