x86: irq: Get correct available vectors for cpu disable
authorYinghai Lu <yinghai@kernel.org>
Tue, 13 May 2014 15:39:34 +0000 (11:39 -0400)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 4 Jun 2014 12:18:34 +0000 (14:18 +0200)
check_irq_vectors_for_cpu_disable() can overestimate the number of
available interrupt vectors, so the check for cpu down succeeds, but
the actual cpu removal fails.

It iterates from FIRST_EXTERNAL_VECTOR to NR_VECTORS, which is wrong
because the systems vectors are not taken into account.

Limit the search to first_system_vector instead of NR_VECTORS.

The second indicator for vector availability the used_vectors bitmap
is not taken into account at all. So system vectors,
e.g. IA32_SYSCALL_VECTOR (0x80) and IRQ_MOVE_CLEANUP_VECTOR (0x20),
are accounted as available.

Add a check for the used_vectors bitmap and do not account vectors
which are marked there.

[ tglx: Simplified code. Rewrote changelog and code comments. ]

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Prarit Bhargava <prarit@redhat.com>
Cc: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Elliott, Robert (Server Storage)" <Elliott@hp.com>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/1400160305-17774-2-git-send-email-prarit@redhat.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/irq.c

index 283a76a9cc4099427b8d8b7dcc595cfdddb880a1..11ccfb0a63e78d68908440c1690b3f544ee9c6c7 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/idle.h>
 #include <asm/mce.h>
 #include <asm/hw_irq.h>
+#include <asm/desc.h>
 
 #define CREATE_TRACE_POINTS
 #include <asm/trace/irq_vectors.h>
@@ -334,10 +335,17 @@ int check_irq_vectors_for_cpu_disable(void)
        for_each_online_cpu(cpu) {
                if (cpu == this_cpu)
                        continue;
-               for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS;
-                    vector++) {
-                       if (per_cpu(vector_irq, cpu)[vector] < 0)
-                               count++;
+               /*
+                * We scan from FIRST_EXTERNAL_VECTOR to first system
+                * vector. If the vector is marked in the used vectors
+                * bitmap or an irq is assigned to it, we don't count
+                * it as available.
+                */
+               for (vector = FIRST_EXTERNAL_VECTOR;
+                    vector < first_system_vector; vector++) {
+                       if (!test_bit(vector, used_vectors) &&
+                           per_cpu(vector_irq, cpu)[vector] < 0)
+                                       count++;
                }
        }