Skip to content

Commit 210f84b

Browse files
Wincy Vanbonzini
authored andcommitted
x86: irq: Define a global vector for nested posted interrupts
We are using the same vector for nested/non-nested posted interrupts delivery, this may cause interrupts latency in L1 since we can't kick the L2 vcpu out of vmx-nonroot mode. This patch introduces a new vector which is only for nested posted interrupts to solve the problems above. Signed-off-by: Wincy Van <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent a512177 commit 210f84b

File tree

7 files changed

+29
-1
lines changed

7 files changed

+29
-1
lines changed

arch/x86/entry/entry_64.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR x86_platform_ipi smp_x86_platform_ipi
705705
#ifdef CONFIG_HAVE_KVM
706706
apicinterrupt3 POSTED_INTR_VECTOR kvm_posted_intr_ipi smp_kvm_posted_intr_ipi
707707
apicinterrupt3 POSTED_INTR_WAKEUP_VECTOR kvm_posted_intr_wakeup_ipi smp_kvm_posted_intr_wakeup_ipi
708+
apicinterrupt3 POSTED_INTR_NESTED_VECTOR kvm_posted_intr_nested_ipi smp_kvm_posted_intr_nested_ipi
708709
#endif
709710

710711
#ifdef CONFIG_X86_MCE_THRESHOLD

arch/x86/include/asm/entry_arch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ BUILD_INTERRUPT3(kvm_posted_intr_ipi, POSTED_INTR_VECTOR,
2525
smp_kvm_posted_intr_ipi)
2626
BUILD_INTERRUPT3(kvm_posted_intr_wakeup_ipi, POSTED_INTR_WAKEUP_VECTOR,
2727
smp_kvm_posted_intr_wakeup_ipi)
28+
BUILD_INTERRUPT3(kvm_posted_intr_nested_ipi, POSTED_INTR_NESTED_VECTOR,
29+
smp_kvm_posted_intr_nested_ipi)
2830
#endif
2931

3032
/*

arch/x86/include/asm/hardirq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ typedef struct {
1515
#ifdef CONFIG_HAVE_KVM
1616
unsigned int kvm_posted_intr_ipis;
1717
unsigned int kvm_posted_intr_wakeup_ipis;
18+
unsigned int kvm_posted_intr_nested_ipis;
1819
#endif
1920
unsigned int x86_platform_ipis; /* arch dependent */
2021
unsigned int apic_perf_irqs;

arch/x86/include/asm/hw_irq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern asmlinkage void apic_timer_interrupt(void);
3030
extern asmlinkage void x86_platform_ipi(void);
3131
extern asmlinkage void kvm_posted_intr_ipi(void);
3232
extern asmlinkage void kvm_posted_intr_wakeup_ipi(void);
33+
extern asmlinkage void kvm_posted_intr_nested_ipi(void);
3334
extern asmlinkage void error_interrupt(void);
3435
extern asmlinkage void irq_work_interrupt(void);
3536

@@ -62,6 +63,7 @@ extern void trace_call_function_single_interrupt(void);
6263
#define trace_reboot_interrupt reboot_interrupt
6364
#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
6465
#define trace_kvm_posted_intr_wakeup_ipi kvm_posted_intr_wakeup_ipi
66+
#define trace_kvm_posted_intr_nested_ipi kvm_posted_intr_nested_ipi
6567
#endif /* CONFIG_TRACING */
6668

6769
#ifdef CONFIG_X86_LOCAL_APIC

arch/x86/include/asm/irq_vectors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
*/
8484
#define X86_PLATFORM_IPI_VECTOR 0xf7
8585

86-
#define POSTED_INTR_WAKEUP_VECTOR 0xf1
8786
/*
8887
* IRQ work vector:
8988
*/
@@ -98,6 +97,8 @@
9897
/* Vector for KVM to deliver posted interrupt IPI */
9998
#ifdef CONFIG_HAVE_KVM
10099
#define POSTED_INTR_VECTOR 0xf2
100+
#define POSTED_INTR_WAKEUP_VECTOR 0xf1
101+
#define POSTED_INTR_NESTED_VECTOR 0xf0
101102
#endif
102103

103104
/*

arch/x86/kernel/irq.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ int arch_show_interrupts(struct seq_file *p, int prec)
155155
seq_printf(p, "%10u ", irq_stats(j)->kvm_posted_intr_ipis);
156156
seq_puts(p, " Posted-interrupt notification event\n");
157157

158+
seq_printf(p, "%*s: ", prec, "NPI");
159+
for_each_online_cpu(j)
160+
seq_printf(p, "%10u ",
161+
irq_stats(j)->kvm_posted_intr_nested_ipis);
162+
seq_puts(p, " Nested posted-interrupt event\n");
163+
158164
seq_printf(p, "%*s: ", prec, "PIW");
159165
for_each_online_cpu(j)
160166
seq_printf(p, "%10u ",
@@ -313,6 +319,19 @@ __visible void smp_kvm_posted_intr_wakeup_ipi(struct pt_regs *regs)
313319
exiting_irq();
314320
set_irq_regs(old_regs);
315321
}
322+
323+
/*
324+
* Handler for POSTED_INTERRUPT_NESTED_VECTOR.
325+
*/
326+
__visible void smp_kvm_posted_intr_nested_ipi(struct pt_regs *regs)
327+
{
328+
struct pt_regs *old_regs = set_irq_regs(regs);
329+
330+
entering_ack_irq();
331+
inc_irq_stat(kvm_posted_intr_nested_ipis);
332+
exiting_irq();
333+
set_irq_regs(old_regs);
334+
}
316335
#endif
317336

318337
__visible void __irq_entry smp_trace_x86_platform_ipi(struct pt_regs *regs)

arch/x86/kernel/irqinit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ static void __init apic_intr_init(void)
150150
alloc_intr_gate(POSTED_INTR_VECTOR, kvm_posted_intr_ipi);
151151
/* IPI for KVM to deliver interrupt to wake up tasks */
152152
alloc_intr_gate(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi);
153+
/* IPI for KVM to deliver nested posted interrupt */
154+
alloc_intr_gate(POSTED_INTR_NESTED_VECTOR, kvm_posted_intr_nested_ipi);
153155
#endif
154156

155157
/* IPI vectors for APIC spurious and error interrupts */

0 commit comments

Comments
 (0)