[patch 37/41] x86/irq: Get rid of the first_system_vector bogisity

From: Thomas Gleixner
Date: Fri Aug 25 2017 - 06:56:10 EST


This variable is beyond pointless. Nothing allocates a vector via
alloc_gate() below FIRST_SYSTEM_VECTOR. So nothing can change
first_system_vector.

If there is a need for a gate below FIRST_SYSTEM_VECTOR then it can be
added to the vector defines and FIRST_SYSTEM_VECTOR adjusted accordingly.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
arch/x86/include/asm/desc.h | 11 ++---------
arch/x86/kernel/apic/apic.c | 2 --
arch/x86/kernel/apic/vector.c | 2 +-
arch/x86/kernel/idt.c | 2 +-
arch/x86/kernel/irq.c | 2 +-
5 files changed, 5 insertions(+), 14 deletions(-)

--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -408,21 +408,14 @@ static inline void set_intr_gate(unsigne
_set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
}

-#ifdef CONFIG_X86_LOCAL_APIC
-extern int first_system_vector;
-#else
-#define first_system_vector NR_VECTORS
-#endif
-
/* used_vectors is BITMAP for irq is not managed by percpu vector_irq */
extern unsigned long used_vectors[];

-static inline void alloc_system_vector(int vector)
+static inline void alloc_system_vector(unsigned int vector)
{
+ BUG_ON(vector < FIRST_SYSTEM_VECTOR);
if (!test_bit(vector, used_vectors)) {
set_bit(vector, used_vectors);
- if (first_system_vector > vector)
- first_system_vector = vector;
} else {
BUG();
}
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -177,8 +177,6 @@ static int disable_apic_timer __initdata
int local_apic_timer_c2_ok;
EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);

-int first_system_vector = FIRST_SYSTEM_VECTOR;
-
/*
* Debug level, exported for io_apic.c
*/
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -166,7 +166,7 @@ static int __assign_irq_vector(int irq,
offset = current_offset;
next:
vector += 16;
- if (vector >= first_system_vector) {
+ if (vector >= FIRST_SYSTEM_VECTOR) {
offset = (offset + 1) % 16;
vector = FIRST_EXTERNAL_VECTOR + offset;
}
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -290,7 +290,7 @@ void __init idt_setup_apic_and_irq_gates

idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts));

- for_each_clear_bit_from(i, used_vectors, first_system_vector) {
+ for_each_clear_bit_from(i, used_vectors, FIRST_SYSTEM_VECTOR) {
entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
set_intr_gate(i, entry);
}
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -414,7 +414,7 @@ int check_irq_vectors_for_cpu_disable(vo
* this w/o holding vector_lock.
*/
for (vector = FIRST_EXTERNAL_VECTOR;
- vector < first_system_vector; vector++) {
+ vector < FIRST_SYSTEM_VECTOR; vector++) {
if (!test_bit(vector, used_vectors) &&
IS_ERR_OR_NULL(per_cpu(vector_irq, cpu)[vector])) {
if (++count == this_count)