Skip to contentSkip to conversation

x86/irq: Add hardcoded hypervisor interrupts to /proc/stat

PATCH In review Michael Kelley 3 participants 8 messages Feb 27, 2023 – Jun 8, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/irq: Add hardcoded hypervisor interrupts to /proc/stat

Some hypervisor interrupts (such as for Hyper-V VMbus and Hyper-V timers) have hardcoded interrupt vectors on x86 and don't have Linux IRQs assigned. These interrupts are shown in /proc/interrupts, but are not reported in the first field of the "intr" line in /proc/stat because the x86 version of arch_irq_stat_cpu() doesn't include them.

Fix this by adding code to arch_irq_stat_cpu() to include these interrupts, similar to existing interrupts that don't have Linux IRQs.

---
 arch/x86/kernel/irq.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/kernel/irq.c +7 -0
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);
Signature · 1 line
1.8.3.1
#1 lore raw

From: Michael Kelley (LINUX) <[email protected]> Sent: Monday, February 27, 2023 10:46 AM

Quoted 11 lines

Some hypervisor interrupts (such as for Hyper-V VMbus and Hyper-V timers) have hardcoded interrupt vectors on x86 and don't have Linux IRQs assigned. These interrupts are shown in /proc/interrupts, but are not reported in the first field of the "intr" line in /proc/stat because the x86 version of arch_irq_stat_cpu() doesn't include them.

Fix this by adding code to arch_irq_stat_cpu() to include these interrupts, similar to existing interrupts that don't have Linux IRQs.

Gentle ping. Any comments on this patch? Seems pretty straightforward to me ....

Michael

Quoted 24 lines
---
 arch/x86/kernel/irq.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/kernel/irq.c +7 -1
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);
--

1.8.3.1

#2 lore raw
In reply to Michael Kelley
Quoted 8 lines · Michael Kelley
arch/x86/kernel/irq.c +0 -0
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif

arch/x86/kernel/irq.c u64 arch_irq_stat_cpu(unsigned int cpu) · line 223

Quoted 10 lines
arch/x86/kernel/irq.c +7 -0
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);

This seems fine, especially since arch_show_interrupts() has them. But, what's with the "#if IS_ENABLED" versus the plain #ifdef? Is there some difference I'm missing? Why not just be consistent with the other code and use a plain #ifdef for both?

#3 lore raw

From: Dave Hansen <[email protected]> Sent: Wednesday, March 22, 2023 11:07 AM

Quoted 17 lines · Michael Kelley
Quoted 15 lines
arch/x86/kernel/irq.c +7 -0
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
Quoted 8 lines

arch/x86/kernel/irq.c u64 arch_irq_stat_cpu(unsigned int cpu) · line 223

Quoted 3 lines
arch/x86/kernel/irq.c +0 -0
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);

This seems fine, especially since arch_show_interrupts() has them. But, what's with the "#if IS_ENABLED" versus the plain #ifdef? Is there some difference I'm missing? Why not just be consistent with the other code and use a plain #ifdef for both?

I'm following the coding pattern in arch_show_interrupts(), in irq_cpustat_t,
and most other places that test CONFIG_HYPERV. Maybe all those existing
cases are a mis-application of Documentation/process/coding-style.rst Section 21, which prefers "if (IS_ENABLED(CONFIG_HYPERV))" over "#ifdef CONFIG_HYPERV". "#if IS_ENABLED()" is not the same as "if (IS_ENABLED())". :-)

Net, I don't have a strong preference either way.

Michael

#4 lore raw
Quoted 27 lines · Michael Kelley (LINUX)

From: Dave Hansen <[email protected]> Sent: Wednesday, March 22, 2023 11:07 AM

Quoted 17 lines · Michael Kelley
Quoted 15 lines
arch/x86/kernel/irq.c +7 -0
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
Quoted 8 lines

arch/x86/kernel/irq.c u64 arch_irq_stat_cpu(unsigned int cpu) · line 223

Quoted 3 lines
arch/x86/kernel/irq.c +0 -0
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);

This seems fine, especially since arch_show_interrupts() has them. But, what's with the "#if IS_ENABLED" versus the plain #ifdef? Is there some difference I'm missing? Why not just be consistent with the other code and use a plain #ifdef for both?

Quoted 8 lines

I'm following the coding pattern in arch_show_interrupts(), in irq_cpustat_t,
and most other places that test CONFIG_HYPERV. Maybe all those existing
cases are a mis-application of Documentation/process/coding-style.rst Section 21, which prefers "if (IS_ENABLED(CONFIG_HYPERV))" over "#ifdef CONFIG_HYPERV". "#if IS_ENABLED()" is not the same as "if (IS_ENABLED())". :-)

Net, I don't have a strong preference either way.

Using IS_ENABLED() is mandatory because CONFIG_HYPERV is a tri-state, i.e. can be a module and thus #define CONFIG_HYPER_MODULE instead of CONFIG_HYPERV.

#5 lore raw

From: Sean Christopherson <[email protected]> Sent: Wednesday, March 22, 2023 6:27 PM

Quoted 37 lines · Michael Kelley (LINUX)
Quoted 1 line

From: Dave Hansen <[email protected]> Sent: Wednesday, March 22, 2023

11:07 AM

Quoted 33 lines
Quoted 17 lines · Michael Kelley
Quoted 15 lines
arch/x86/kernel/irq.c +7 -0
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
Quoted 8 lines

arch/x86/kernel/irq.c u64 arch_irq_stat_cpu(unsigned int cpu) · line 223

Quoted 3 lines
arch/x86/kernel/irq.c +0 -0
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);

This seems fine, especially since arch_show_interrupts() has them. But, what's with the "#if IS_ENABLED" versus the plain #ifdef? Is there some difference I'm missing? Why not just be consistent with the other code and use a plain #ifdef for both?

I'm following the coding pattern in arch_show_interrupts(), in irq_cpustat_t,
and most other places that test CONFIG_HYPERV. Maybe all those existing
cases are a mis-application of Documentation/process/coding-style.rst Section 21, which prefers "if (IS_ENABLED(CONFIG_HYPERV))" over "#ifdef CONFIG_HYPERV". "#if IS_ENABLED()" is not the same as "if (IS_ENABLED())". :-)

Quoted 4 lines
Quoted 1 line

Net, I don't have a strong preference either way.

Using IS_ENABLED() is mandatory because CONFIG_HYPERV is a tri-state, i.e. can be a module and thus #define CONFIG_HYPER_MODULE instead of CONFIG_HYPERV.

Ah, right. Thanks.

Michael

#6 lore raw

From: Michael Kelley (LINUX) <[email protected]> Sent: Thursday, March 23, 2023 10:36 AM

Quoted 40 lines

From: Sean Christopherson <[email protected]> Sent: Wednesday, March 22, 2023 6:27 PM

Quoted 37 lines · Michael Kelley (LINUX)
Quoted 1 line

From: Dave Hansen <[email protected]> Sent: Wednesday, March 22, 2023

11:07 AM

Quoted 33 lines
Quoted 17 lines · Michael Kelley
Quoted 15 lines
arch/x86/kernel/irq.c +7 -0
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
Quoted 8 lines

arch/x86/kernel/irq.c u64 arch_irq_stat_cpu(unsigned int cpu) · line 223

Quoted 3 lines
arch/x86/kernel/irq.c +0 -0
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);

This seems fine, especially since arch_show_interrupts() has them. But, what's with the "#if IS_ENABLED" versus the plain #ifdef? Is there some difference I'm missing? Why not just be consistent with the other code and use a plain #ifdef for both?

I'm following the coding pattern in arch_show_interrupts(), in irq_cpustat_t,
and most other places that test CONFIG_HYPERV. Maybe all those existing
cases are a mis-application of Documentation/process/coding-style.rst Section 21, which prefers "if (IS_ENABLED(CONFIG_HYPERV))" over "#ifdef CONFIG_HYPERV". "#if IS_ENABLED()" is not the same as "if (IS_ENABLED())". :-)

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Net, I don't have a strong preference either way.

Using IS_ENABLED() is mandatory because CONFIG_HYPERV is a tri-state, i.e. can be a module and thus #define CONFIG_HYPER_MODULE instead of CONFIG_HYPERV.

Ah, right. Thanks.

x86 maintainers: Any issues with picking up this patch for the 6.4 merge window?

Michael

#7 lore raw
In reply to Dave Hansen

From: Dave Hansen <[email protected]> Sent: Wednesday, March 22, 2023 11:07 AM

Quoted 17 lines · Michael Kelley
Quoted 15 lines
arch/x86/kernel/irq.c +7 -0
index 766ffe3..9f668d2 100644
@@ -211,6 +211,13 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	sum += irq_stats(cpu)->irq_threshold_count;
 #endif
+#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
+	sum += irq_stats(cpu)->irq_hv_callback_count;
+#endif
+#if IS_ENABLED(CONFIG_HYPERV)
+	sum += irq_stats(cpu)->irq_hv_reenlightenment_count;
+	sum += irq_stats(cpu)->hyperv_stimer0_count;
+#endif
Quoted 8 lines

arch/x86/kernel/irq.c u64 arch_irq_stat_cpu(unsigned int cpu) · line 223

Quoted 3 lines
arch/x86/kernel/irq.c +0 -0
 #ifdef CONFIG_X86_MCE
 	sum += per_cpu(mce_exception_count, cpu);
 	sum += per_cpu(mce_poll_count, cpu);

This seems fine, especially since arch_show_interrupts() has them. But, what's with the "#if IS_ENABLED" versus the plain #ifdef? Is there some difference I'm missing? Why not just be consistent with the other code and use a plain #ifdef for both?

Dave --

With Sean's explanation for #if IS_ENABLED, are you OK with giving this
an ACK as an x86 maintainer? This patch has been hanging around for a
while now ...

Michael