]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
timer_list-convert-timer-list-to-be-a-proper-seq_file-v3
authorNathan Zimmer <nzimmer@sgi.com>
Wed, 20 Mar 2013 04:06:55 +0000 (15:06 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 21 Mar 2013 05:27:15 +0000 (16:27 +1100)
v3: Corrected the case where max_cpus != nr_cpu_ids by exiting early.

Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Reported-by: Dave Jones <davej@redhat.com>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/time/timer_list.c

index 8251f3f7ca9f49a1678bf8376b8015c82d0802d1..93f2e0f40b7a29f85ce3ccbe449ab8f19f62da7a 100644 (file)
@@ -276,8 +276,8 @@ static int timer_list_show(struct seq_file *m, void *v)
 /*
  * This itererator really needs some explanation since it is offset and has
  * two passes, one of which is controlled by a config option.
- * In a hotplugged system some cpus, including cpu 0, may be missing so we have
- * to use cpumask_* to iterate over the cpus.
+ * In a hotpluggable systems some cpus, including cpu 0 and the last cpu, may
+ * be missing so we have to use cpumask_* to iterate over the cpus.
  * For the first pass:
  * It returns 1 for the header position.
  * For cpu 0 it returns 2 and the final possible cpu would be nr_cpu_ids + 1.
@@ -285,6 +285,8 @@ static int timer_list_show(struct seq_file *m, void *v)
  * It returnes nr_cpu_ids + 1 for the second header position.
  * For cpu 0 it returns nr_cpu_ids + 2
  * The final possible cpu would be nr_cpu_ids + nr_cpu_ids + 2.
+ * It is also important to remember that cpumask_next returns >= nr_cpu_ids if
+ * no further cpus set.
  */
 static void *timer_list_start(struct seq_file *file, loff_t *offset)
 {
@@ -294,11 +296,9 @@ static void *timer_list_start(struct seq_file *file, loff_t *offset)
                return (void *) 1;
 
        if (n < nr_cpu_ids + 1) {
-               n--;
-               if (n > 0)
-                       n = cpumask_next(n - 1, cpu_online_mask);
-               else
-                       n = cpumask_first(cpu_online_mask);
+               n = cpumask_next(n - 2, cpu_online_mask);
+               if (n >= nr_cpu_ids)
+                       n = nr_cpu_ids;
                *offset = n + 1;
                return (void *)(unsigned long)(n + 2);
        }
@@ -309,10 +309,9 @@ static void *timer_list_start(struct seq_file *file, loff_t *offset)
 
        if (n < nr_cpu_ids * 2 + 2) {
                n -= (nr_cpu_ids + 2);
-               if (n > 0)
-                       n = cpumask_next(n - 1, cpu_online_mask);
-               else
-                       n = cpumask_first(cpu_online_mask);
+               n = cpumask_next(n - 1, cpu_online_mask);
+               if (n >= nr_cpu_ids)
+                       return NULL;
                *offset = n + 2 + nr_cpu_ids;
                return (void *)(unsigned long)(n + 3 + nr_cpu_ids);
        }