Do IRQ move cleanup with a timer instead of an IPI
Subsystems (9)
cover Do IRQ move cleanup with a timer instead of an IPI
No point to waste a vector for cleaning up the leftovers of a moved interrupt. Aside of that this must be the lowest priority of all vectors which makes FRED systems utilizing vectors 0x10-0x1f more complicated than necessary.
Schedule a timer instead.
Thomas Gleixner (2):
x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup() x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback
Xin Li (1):
tools: Get rid of IRQ_MOVE_CLEANUP_VECTOR from tools
arch/x86/include/asm/hw_irq.h | 4 +- arch/x86/include/asm/idtentry.h | 1 - arch/x86/include/asm/irq_vectors.h | 7 -- arch/x86/kernel/apic/vector.c | 109 ++++++++++++++---- arch/x86/kernel/idt.c | 1 - arch/x86/platform/uv/uv_irq.c | 2 +- drivers/iommu/amd/iommu.c | 2 +- drivers/iommu/hyperv-iommu.c | 4 +- drivers/iommu/intel/irq_remapping.c | 2 +- tools/arch/x86/include/asm/irq_vectors.h | 7 -- .../beauty/tracepoints/x86_irq_vectors.sh | 2 +- 11 files changed, 92 insertions(+), 49 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup()
From: Thomas Gleixner <[email protected]>
Rename send_cleanup_vector() to vector_schedule_cleanup() for the next patch to replace vector cleanup IPI with a timer callback.
--- arch/x86/include/asm/hw_irq.h | 4 ++-- arch/x86/kernel/apic/vector.c | 8 ++++---- arch/x86/platform/uv/uv_irq.c | 2 +- drivers/iommu/amd/iommu.c | 2 +- drivers/iommu/hyperv-iommu.c | 4 ++-- drivers/iommu/intel/irq_remapping.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)
arch/x86/include/asm/hw_irq.h +2 -2
@@ -97,10 +97,10 @@ extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);extern void lock_vector_lock (void );extern void unlock_vector_lock (void );#ifdef CONFIG_SMP -extern void send_cleanup_vector (struct irq_cfg *); +extern void vector_schedule_cleanup (struct irq_cfg *);extern void irq_complete_move (struct irq_cfg *cfg);#else -static inline void send_cleanup_vector (struct irq_cfg *c) { } +static inline void vector_schedule_cleanup (struct irq_cfg *c) { }static inline void irq_complete_move (struct irq_cfg *c) { }#endif
arch/x86/kernel/apic/vector.c +4 -4
@@ -967,7 +967,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_irq_move_cleanup)raw_spin_unlock (&vector_lock); } -static void __send_cleanup_vector (struct apic_chip_data *apicd) +static void __vector_schedule_cleanup (struct apic_chip_data *apicd) {unsigned int cpu;
@@ -983,13 +983,13 @@ static void __send_cleanup_vector(struct apic_chip_data *apicd)raw_spin_unlock (&vector_lock); } -void send_cleanup_vector (struct irq_cfg *cfg) +void vector_schedule_cleanup (struct irq_cfg *cfg) {struct apic_chip_data *apicd; apicd = container_of(cfg, struct apic_chip_data, hw_irq_cfg);if (apicd->move_in_progress) -__send_cleanup_vector (apicd); +__vector_schedule_cleanup (apicd); }void irq_complete_move (struct irq_cfg *cfg)
@@ -1007,7 +1007,7 @@ void irq_complete_move(struct irq_cfg *cfg)* on the same CPU. */ if (apicd->cpu ==smp_processor_id ()) -__send_cleanup_vector (apicd); +__vector_schedule_cleanup (apicd); }/*
arch/x86/platform/uv/uv_irq.c +1 -1
@@ -58,7 +58,7 @@ uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask, ret = parent->chip->irq_set_affinity (parent, mask, force);if (ret >=0 ) {uv_program_mmr (cfg, data->chip_data); -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg); }return ret;
drivers/iommu/amd/iommu.c +1 -1
@@ -3658,7 +3658,7 @@ static int amd_ir_set_affinity(struct irq_data *data,* at the new destination. So, time to cleanup the previous * vector allocation. */ -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return IRQ_SET_MASK_OK_DONE ; }
drivers/iommu/hyperv-iommu.c +2 -2
@@ -51,7 +51,7 @@ static int hyperv_ir_set_affinity(struct irq_data *data,if (ret <0 || ret ==IRQ_SET_MASK_OK_DONE )return ret; -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return 0 ; }
@@ -257,7 +257,7 @@ static int hyperv_root_ir_set_affinity(struct irq_data *data,if (ret <0 || ret ==IRQ_SET_MASK_OK_DONE )return ret; -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return 0 ; }
drivers/iommu/intel/irq_remapping.c +1 -1
@@ -1180,7 +1180,7 @@ intel_ir_set_affinity(struct irq_data *data, const struct cpumask *mask,* at the new destination. So, time to cleanup the previous * vector allocation. */ -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return IRQ_SET_MASK_OK_DONE ; }
Signature · 1 line
2.34.1
Re: [PATCH 1/3] x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup()
Quoted 135 lines · Xin Li
From: Thomas Gleixner <[email protected]>
Rename
send_cleanup_vector()tovector_schedule_cleanup()for the next patch to replace vector cleanup IPI with a timer callback.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Xin Li <[email protected]>--- arch/x86/include/asm/hw_irq.h | 4 ++-- arch/x86/kernel/apic/vector.c | 8 ++++---- arch/x86/platform/uv/uv_irq.c | 2 +- drivers/iommu/amd/iommu.c | 2 +- drivers/iommu/hyperv-iommu.c | 4 ++-- drivers/iommu/intel/irq_remapping.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)arch/x86/include/asm/hw_irq.h +2
-2@@ -97,10 +97,10 @@ extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data);extern void lock_vector_lock (void );extern void unlock_vector_lock (void );#ifdef CONFIG_SMP -extern void send_cleanup_vector (struct irq_cfg *); +extern void vector_schedule_cleanup (struct irq_cfg *);extern void irq_complete_move (struct irq_cfg *cfg);#else -static inline void send_cleanup_vector (struct irq_cfg *c) { } +static inline void vector_schedule_cleanup (struct irq_cfg *c) { }static inline void irq_complete_move (struct irq_cfg *c) { }#endif arch/x86/kernel/apic/vector.c +4
-4@@ -967,7 +967,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_irq_move_cleanup)raw_spin_unlock (&vector_lock); } -static void __send_cleanup_vector (struct apic_chip_data *apicd) +static void __vector_schedule_cleanup (struct apic_chip_data *apicd) {unsigned int cpu;@@ -983,13 +983,13 @@ static void __send_cleanup_vector(struct apic_chip_data *apicd)raw_spin_unlock (&vector_lock); } -void send_cleanup_vector (struct irq_cfg *cfg) +void vector_schedule_cleanup (struct irq_cfg *cfg) {struct apic_chip_data *apicd; apicd = container_of(cfg, struct apic_chip_data, hw_irq_cfg);if (apicd->move_in_progress) -__send_cleanup_vector (apicd); +__vector_schedule_cleanup (apicd); }void irq_complete_move (struct irq_cfg *cfg)@@ -1007,7 +1007,7 @@ void irq_complete_move(struct irq_cfg *cfg)* on the same CPU. */ if (apicd->cpu ==smp_processor_id ()) -__send_cleanup_vector (apicd); +__vector_schedule_cleanup (apicd); }/* arch/x86/platform/uv/uv_irq.c +1
-1@@ -58,7 +58,7 @@ uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask, ret = parent->chip->irq_set_affinity (parent, mask, force);if (ret >=0 ) {uv_program_mmr (cfg, data->chip_data); -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg); }return ret;drivers/iommu/amd/iommu.c +1
-1@@ -3658,7 +3658,7 @@ static int amd_ir_set_affinity(struct irq_data *data,* at the new destination. So, time to cleanup the previous * vector allocation. */ -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return IRQ_SET_MASK_OK_DONE ; }drivers/iommu/hyperv-iommu.c +2
-2@@ -51,7 +51,7 @@ static int hyperv_ir_set_affinity(struct irq_data *data,if (ret <0 || ret ==IRQ_SET_MASK_OK_DONE )return ret; -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return 0 ; }@@ -257,7 +257,7 @@ static int hyperv_root_ir_set_affinity(struct irq_data *data,if (ret <0 || ret ==IRQ_SET_MASK_OK_DONE )return ret; -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return 0 ; }drivers/iommu/intel/irq_remapping.c +1
-1@@ -1180,7 +1180,7 @@ intel_ir_set_affinity(struct irq_data *data, const struct cpumask *mask,* at the new destination. So, time to cleanup the previous * vector allocation. */ -send_cleanup_vector (cfg); +vector_schedule_cleanup (cfg);return IRQ_SET_MASK_OK_DONE ; }Signature · 1 line
2.34.1
Signature · 1 line
Steve Wahl, Hewlett Packard Enterprise
RE: [PATCH 1/3] x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup()
Quoted 1 line
Reviewed-by Steve Wahl <[email protected]>
Thanks, will add your RB to this patch in the next iteration.
Xin
PATCH 2/3 x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback
In reply to Xin LiFrom: Thomas Gleixner <[email protected]>
Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback for cleaning up the leftovers of a moved interrupt.
The only new job incurred is to do vector cleanup in lapic_offline() in case the vector cleanup timer has not expired.
--- arch/x86/include/asm/idtentry.h | 1 - arch/x86/include/asm/irq_vectors.h | 7 -- arch/x86/kernel/apic/vector.c | 101 +++++++++++++++++++++++------ arch/x86/kernel/idt.c | 1 - 4 files changed, 80 insertions(+), 30 deletions(-)
arch/x86/include/asm/idtentry.h +0 -1
@@ -648,7 +648,6 @@ DECLARE_IDTENTRY_SYSVEC(X86_PLATFORM_IPI_VECTOR, sysvec_x86_platform_ipi);#ifdef CONFIG_SMP DECLARE_IDTENTRY (RESCHEDULE_VECTOR , sysvec_reschedule_ipi); -DECLARE_IDTENTRY_SYSVEC (IRQ_MOVE_CLEANUP_VECTOR , sysvec_irq_move_cleanup);DECLARE_IDTENTRY_SYSVEC (REBOOT_VECTOR , sysvec_reboot);DECLARE_IDTENTRY_SYSVEC (CALL_FUNCTION_SINGLE_VECTOR , sysvec_call_function_single);DECLARE_IDTENTRY_SYSVEC (CALL_FUNCTION_VECTOR , sysvec_call_function);
arch/x86/include/asm/irq_vectors.h +0 -7
@@ -35,13 +35,6 @@*/ #define FIRST_EXTERNAL_VECTOR 0x20 -/* -* Reserve the lowest usable vector (and hence lowest priority) 0x20 for -* triggering cleanup after irq migration. 0x21-0x2f will still be used -* for device interrupts. -*/ -#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR -#define IA32_SYSCALL_VECTOR 0x80/*
arch/x86/kernel/apic/vector.c +80 -21
146 lines not on this page · raw message
arch/x86/kernel/idt.c +0 -1
@@ -131,7 +131,6 @@ static const __initconst struct idt_data apic_idts[] = {INTG (RESCHEDULE_VECTOR , asm_sysvec_reschedule_ipi),INTG (CALL_FUNCTION_VECTOR , asm_sysvec_call_function),INTG (CALL_FUNCTION_SINGLE_VECTOR , asm_sysvec_call_function_single), -INTG (IRQ_MOVE_CLEANUP_VECTOR , asm_sysvec_irq_move_cleanup), INTG(REBOOT_VECTOR, asm_sysvec_reboot), #endif
Signature · 1 line
2.34.1
Peter Zijlstra
maintainerRe: [PATCH 2/3] x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback
Quoted 3 lines · Xin Li
+/*
+ * Called withvector_lockheld
+ */
Instead of comments like that, I tend to add a lockdep_assert*() statement to the same effect. Which unlike comment actually validate the claim and since it's code it tends to not go stale like comments do.
arch/x86/kernel/apic/vector.c static void free_moved_vector(struct apic_chip_data *apicd) · line 966
Quoted 5 lines
arch/x86/kernel/apic/vector.c +2
-0+static void __vector_cleanup (struct vector_cleanup *cl,bool check_irr) {struct apic_chip_data *apicd;struct hlist_node *tmp; +bool rearm = false;
lockdep_assert_held(&vector_lock);
Quoted 41 lines
arch/x86/kernel/apic/vector.c +29
-0+hlist_for_each_entry_safe (apicd, tmp, &cl->head, clist) {unsigned int irr, vector = apicd->prev_vector;/* * Paranoia: Check if the vector that needs to be cleaned +* up is registered at the APICs IRR. That's clearly a +* hardware issue if the vector arrived on the old target +* _after_ interrupts were disabled above. Keep @apicd +* on the list and schedule the timer again to give the CPU +* a chance to handle the pending interrupt. +* +* Do not check IRR when called from lapic_offline(), because +* fixup_irqs() was just called to scan IRR for set bits and +* forward them to new destination CPUs via IPIs. */ + irr = check_irr ?apic_read (APIC_IRR + (vector /32 *0x10 )) :0 ;if (irr & (1U << (vector %32 ))) { +pr_warn_once ("Moved interrupt pending in old target APIC %u\n" , apicd->irq); + rearm = true;continue ; }free_moved_vector (apicd); } +/* +* Must happen under vector_lock to make the timer_pending() check +* in __vector_schedule_cleanup() race free against the rearm here. +*/ +if (rearm) +mod_timer (&cl->timer, jiffies +1 ); +} + +static void vector_cleanup_callback (struct timer_list *tmr) +{ +struct vector_cleanup *cl =container_of (tmr,typeof (*cl), timer); + +/* Prevent vectors vanishing under us */ +raw_spin_lock_irq (&vector_lock); +__vector_cleanup (cl, true); +raw_spin_unlock_irq (&vector_lock); }
RE: [PATCH 2/3] x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback
Quoted 7 lines
Quoted 3 lines
+/*
+ * Called withvector_lockheld
+ */Instead of comments like that, I tend to add a lockdep_assert*() statement to the same effect. Which unlike comment actually validate the claim and since it's code it tends to not go stale like comments do.
neat, will do!
Quoted 3 lines
arch/x86/kernel/apic/vector.c static void free_moved_vector(struct apic_chip_data *apicd) · line 966
Quoted 1 line
arch/x86/kernel/apic/vector.c +1
-0+bool rearm = false;lockdep_assert_held(&vector_lock);
My bad, didn't notice that quite a few functions in the file already do that.
Re: [PATCH 2/3] x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback
In reply to Xin LiQuoted 3 lines · Xin Li
+/*
+ * Called withvector_lockheld
+ */
Such a comment is patently bad.
Quoted 2 lines
+static void
__vector_cleanup(struct vector_cleanup *cl, bool check_irr)
{
....
lockdep_assert_held(&vector_lock);Documents the requirement clearly _and_ catches any caller which does not hold the lock when lockdep is enabled.
Thanks,
tglx
RE: [PATCH 2/3] x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback
Quoted 13 lines
Quoted 3 lines
+/*
+ * Called withvector_lockheld
+ */Such a comment is patently bad.
Review
Quoted 3 lines
(quoted diff) +2
-0+static void __vector_cleanup(struct vector_cleanup *cl, bool +check_irr) {.... lockdep_assert_held(&vector_lock);
Quoted 2 lines
Documents the requirement clearly _and_ catches any caller which does not hold the lock when lockdep is enabled.
Peter Z gave the same comment, I will address in the next iteration.
Thanks!
Xin
PATCH 3/3 tools: Get rid of IRQ_MOVE_CLEANUP_VECTOR from tools
In reply to Xin LiGet rid of IRQ_MOVE_CLEANUP_VECTOR from tools.
--- tools/arch/x86/include/asm/irq_vectors.h | 7 ------- tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-)
tools/arch/x86/include/asm/irq_vectors.h +0 -7
@@ -35,13 +35,6 @@*/ #define FIRST_EXTERNAL_VECTOR 0x20 -/* -* Reserve the lowest usable vector (and hence lowest priority) 0x20 for -* triggering cleanup after irq migration. 0x21-0x2f will still be used -* for device interrupts. -*/ -#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR -#define IA32_SYSCALL_VECTOR 0x80/*
tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh +1 -1
@@ -12,7 +12,7 @@ x86_irq_vectors=${arch_x86_header_dir}/irq_vectors.h # FIRST_EXTERNAL_VECTOR is not that useful, find what is its number # and then replace whatever is using it and that is useful, which at -# the time of writing of this script was: IRQ_MOVE_CLEANUP_VECTOR. +# the time of writing of this script was: 0x20. first_external_regex='^#define[[:space:]]+FIRST_EXTERNAL_VECTOR[[:space:]]+(0x[[:xdigit:]]+)$' first_external_vector=$(grep -E ${first_external_regex} ${x86_irq_vectors} | sed -r "s/${first_external_regex}/\1/g")
Signature · 1 line
2.34.1