genirq: Prevent proc race against freeing of irq descriptors
[pandora-kernel.git] / fs / proc / stat.c
index 42b274d..81a48d1 100644 (file)
 
 static cputime64_t get_idle_time(int cpu)
 {
-       u64 idle_time = get_cpu_idle_time_us(cpu, NULL);
+       u64 idle_time = -1ULL;
        cputime64_t idle;
 
+       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 */
+               /* !NO_HZ or cpu offline so we can rely on cpustat.idle */
                idle = kstat_cpu(cpu).cpustat.idle;
                idle = cputime64_add(idle, arch_idle_time(cpu));
        } else
-               idle = usecs_to_cputime(idle_time);
+               idle = usecs_to_cputime64(idle_time);
 
        return idle;
 }
 
 static cputime64_t get_iowait_time(int cpu)
 {
-       u64 iowait_time = get_cpu_iowait_time_us(cpu, NULL);
+       u64 iowait_time = -1ULL;
        cputime64_t iowait;
 
+       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 */
+               /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
                iowait = kstat_cpu(cpu).cpustat.iowait;
        else
-               iowait = usecs_to_cputime(iowait_time);
+               iowait = usecs_to_cputime64(iowait_time);
 
        return iowait;
 }
@@ -135,7 +141,7 @@ static int show_stat(struct seq_file *p, void *v)
 
        /* sum again ? it could be updated? */
        for_each_irq_nr(j)
-               seq_printf(p, " %u", kstat_irqs(j));
+               seq_printf(p, " %u", kstat_irqs_usr(j));
 
        seq_printf(p,
                "\nctxt %llu\n"