Skip to contentSkip to conversation

x86: Distinguish TLB shootdown interrupts from other functions call interrupts

PATCH In review Tomoki Sekiyama 2 participants 5 messages Sep 19, 2012 – Sep 24, 2012

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

PATCH 1/1 x86: Distinguish TLB shootdown interrupts from other functions call interrupts

As TLB shootdown requests to other CPU cores are now done using function call interrupts, TLB shootdowns entry in /proc/interrupts is always shown as 0.

This behavior change was introduced by commit 52aec3308db8 ("x86/tlb:
replace INVALIDATE_TLB_VECTOR by CALL_FUNCTION_VECTOR").

This patch reverts TLB shootdowns entry in /proc/interrupts to count TLB shootdowns separately from the other function call interrupts.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Alex Shi <[email protected]>
---
 arch/x86/include/asm/hardirq.h |    2 +-
 arch/x86/kernel/irq.c          |    5 +++--
 arch/x86/mm/tlb.c              |    3 +++
 3 files changed, 7 insertions(+), 3 deletions(-)
arch/x86/include/asm/hardirq.h +1 -1
index d3895db..af60ab5 100644
@@ -18,7 +18,7 @@ typedef struct {
 #ifdef CONFIG_SMP
 	unsigned int irq_resched_count;
 	unsigned int irq_call_count;
-	unsigned int irq_tlb_count;
+	unsigned int irq_tlb_count;	/* double-counted in irq_call_count */
 #endif
 #ifdef CONFIG_X86_THERMAL_VECTOR
 	unsigned int irq_thermal_count;
arch/x86/kernel/irq.c +3 -2
index d44f782..6dfa8b1 100644
@@ -92,7 +92,8 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	seq_printf(p, "  Rescheduling interrupts\n");
 	seq_printf(p, "%*s: ", prec, "CAL");
 	for_each_online_cpu(j)
-		seq_printf(p, "%10u ", irq_stats(j)->irq_call_count);
+		seq_printf(p, "%10u ", irq_stats(j)->irq_call_count -
+					irq_stats(j)->irq_tlb_count);
 	seq_printf(p, "  Function call interrupts\n");
 	seq_printf(p, "%*s: ", prec, "TLB");
 	for_each_online_cpu(j)
@@ -147,7 +148,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_SMP
 	sum += irq_stats(cpu)->irq_resched_count;
 	sum += irq_stats(cpu)->irq_call_count;
-	sum += irq_stats(cpu)->irq_tlb_count;
+	/* irq_tlb_count is already added to irq_call_count */
 #endif
 #ifdef CONFIG_X86_THERMAL_VECTOR
 	sum += irq_stats(cpu)->irq_thermal_count;
arch/x86/mm/tlb.c +3 -0
index 613cd83..0a054db 100644
@@ -98,6 +98,9 @@ static void flush_tlb_func(void *info)
 {
 	struct flush_tlb_info *f = info;
 
+	/* irq_call_cnt is also incremented; be subtracted on display */
+	inc_irq_stat(irq_tlb_count);
+
 	if (f->flush_mm != this_cpu_read(cpu_tlbstate.active_mm))
 		return;
 
#1 lore raw

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

Quoted 7 lines
arch/x86/kernel/irq.c +1 -1
@@ -147,7 +148,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_SMP
 	sum += irq_stats(cpu)->irq_resched_count;
 	sum += irq_stats(cpu)->irq_call_count;
-	sum += irq_stats(cpu)->irq_tlb_count;
+	/* irq_tlb_count is already added to irq_call_count */

redundant comments here?

arch/x86/mm/tlb.c static void flush_tlb_func(void *info) · line 101

Quoted 12 lines
arch/x86/kernel/irq.c +0 -0
 #endif
 #ifdef CONFIG_X86_THERMAL_VECTOR
 	sum += irq_stats(cpu)->irq_thermal_count;
arch/x86/mm/tlb.c +1 -0
index 613cd83..0a054db 100644
@@ -98,6 +98,9 @@ static void flush_tlb_func(void *info)
 {
 	struct flush_tlb_info *f = info;
 
+	/* irq_call_cnt is also incremented; be subtracted on display */

If is it better to move above explanation to irq_call_cnt definition place: harirq.h?

Quoted 6 lines
arch/x86/mm/tlb.c +2 -0
+	inc_irq_stat(irq_tlb_count);
+
 	if (f->flush_mm != this_cpu_read(cpu_tlbstate.active_mm))
 		return;
 
Signature · 2 lines
Thanks
    Alex
#2 lore raw

Hi Alex,

thank you for the review.

Quoted 6 lines

Review

Quoted 3 lines
    sum += irq_stats(cpu)->irq_call_count;
(quoted diff) +1 -1
-   sum += irq_stats(cpu)->irq_tlb_count;
+   /* irq_tlb_count is already added to irq_call_count */

redundant comments here?

Quoted 7 lines

Review static void flush_tlb_func(void *info) · line 101

Quoted 5 lines
(quoted diff) +1 -0
@@ -98,6 +98,9 @@ static void flush_tlb_func(void *info)
 {
 	struct flush_tlb_info *f = info;
 
+	/* irq_call_cnt is also incremented; be subtracted on display */

If is it better to move above explanation to irq_call_cnt definition place: harirq.h?

Agreed.

In the patch below, I reduced the redundant comments.

--
As TLB shootdown requests to other CPU cores are now using function call interrupts, TLB shootdowns entry in /proc/interrupts is always shown as 0.

This behavior change was introduced by commit 52aec3308db8 ("x86/tlb:
replace INVALIDATE_TLB_VECTOR by CALL_FUNCTION_VECTOR").

This patch reverts TLB shootdowns entry in /proc/interrupts to count TLB shootdowns separately from the other function call interrupts.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Alex Shi <[email protected]>
---
 arch/x86/include/asm/hardirq.h |    2 ++
 arch/x86/kernel/irq.c          |    4 ++--
 arch/x86/mm/tlb.c              |    2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)
arch/x86/include/asm/hardirq.h +2 -0
index d3895db..e34b252 100644
@@ -18,6 +18,8 @@ typedef struct {
 #ifdef CONFIG_SMP
 	unsigned int irq_resched_count;
 	unsigned int irq_call_count;
+	/* irq_tlb_count is double-counted in irq_call_count, so it must be
+	   subtracted from irq_call_count when displaying irq_call_count */
 	unsigned int irq_tlb_count;
 #endif
 #ifdef CONFIG_X86_THERMAL_VECTOR
arch/x86/kernel/irq.c +2 -2
index d44f782..e4595f1 100644
@@ -92,7 +92,8 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	seq_printf(p, "  Rescheduling interrupts\n");
 	seq_printf(p, "%*s: ", prec, "CAL");
 	for_each_online_cpu(j)
-		seq_printf(p, "%10u ", irq_stats(j)->irq_call_count);
+		seq_printf(p, "%10u ", irq_stats(j)->irq_call_count -
+					irq_stats(j)->irq_tlb_count);
 	seq_printf(p, "  Function call interrupts\n");
 	seq_printf(p, "%*s: ", prec, "TLB");
 	for_each_online_cpu(j)
@@ -147,7 +148,6 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_SMP
 	sum += irq_stats(cpu)->irq_resched_count;
 	sum += irq_stats(cpu)->irq_call_count;
-	sum += irq_stats(cpu)->irq_tlb_count;
 #endif
 #ifdef CONFIG_X86_THERMAL_VECTOR
 	sum += irq_stats(cpu)->irq_thermal_count;
arch/x86/mm/tlb.c +2 -0
index 613cd83..2d6d8ed 100644
@@ -98,6 +98,8 @@ static void flush_tlb_func(void *info)
 {
 	struct flush_tlb_info *f = info;
 
+	inc_irq_stat(irq_tlb_count);
+
 	if (f->flush_mm != this_cpu_read(cpu_tlbstate.active_mm))
 		return;
 
Acked-by
#3 lore raw
Quoted 1 line
Quoted 1 line

If is it better to move above explanation to irq_call_cnt definition

place: harirq.h?

Quoted 4 lines

Agreed.

In the patch below, I reduced the redundant comments.

Quoted 72 lines

--
As TLB shootdown requests to other CPU cores are now using function call interrupts, TLB shootdowns entry in /proc/interrupts is always shown as 0.

This behavior change was introduced by commit 52aec3308db8 ("x86/tlb:
replace INVALIDATE_TLB_VECTOR by CALL_FUNCTION_VECTOR").

This patch reverts TLB shootdowns entry in /proc/interrupts to count TLB shootdowns separately from the other function call interrupts.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Alex Shi <[email protected]>
---
 arch/x86/include/asm/hardirq.h |    2 ++
 arch/x86/kernel/irq.c          |    4 ++--
 arch/x86/mm/tlb.c              |    2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)
arch/x86/include/asm/hardirq.h +2 -0
index d3895db..e34b252 100644
@@ -18,6 +18,8 @@ typedef struct {
 #ifdef CONFIG_SMP
 	unsigned int irq_resched_count;
 	unsigned int irq_call_count;
+	/* irq_tlb_count is double-counted in irq_call_count, so it must be
+	   subtracted from irq_call_count when displaying irq_call_count */
 	unsigned int irq_tlb_count;
 #endif
 #ifdef CONFIG_X86_THERMAL_VECTOR
arch/x86/kernel/irq.c +2 -2
index d44f782..e4595f1 100644
@@ -92,7 +92,8 @@ int arch_show_interrupts(struct seq_file *p, int prec)
 	seq_printf(p, "  Rescheduling interrupts\n");
 	seq_printf(p, "%*s: ", prec, "CAL");
 	for_each_online_cpu(j)
-		seq_printf(p, "%10u ", irq_stats(j)->irq_call_count);
+		seq_printf(p, "%10u ", irq_stats(j)->irq_call_count -
+					irq_stats(j)->irq_tlb_count);
 	seq_printf(p, "  Function call interrupts\n");
 	seq_printf(p, "%*s: ", prec, "TLB");
 	for_each_online_cpu(j)
@@ -147,7 +148,6 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 #ifdef CONFIG_SMP
 	sum += irq_stats(cpu)->irq_resched_count;
 	sum += irq_stats(cpu)->irq_call_count;
-	sum += irq_stats(cpu)->irq_tlb_count;
 #endif
 #ifdef CONFIG_X86_THERMAL_VECTOR
 	sum += irq_stats(cpu)->irq_thermal_count;
arch/x86/mm/tlb.c +2 -0
index 613cd83..2d6d8ed 100644
@@ -98,6 +98,8 @@ static void flush_tlb_func(void *info)
 {
 	struct flush_tlb_info *f = info;
 
+	inc_irq_stat(irq_tlb_count);
+
 	if (f->flush_mm != this_cpu_read(cpu_tlbstate.active_mm))
 		return;
 
Signature · 2 lines
Thanks
    Alex
#4 lore raw
In reply to Tomoki Sekiyama

arch/x86/include/asm/hardirq.h typedef struct { · line 23

Quoted 5 lines · Tomoki Sekiyama
arch/x86/include/asm/hardirq.h +2 -0
 	unsigned int irq_resched_count;
 	unsigned int irq_call_count;
+	/* irq_tlb_count is double-counted in irq_call_count, so it must be
+	   subtracted from irq_call_count when displaying irq_call_count */
 	unsigned int irq_tlb_count;

Review again this patch, above comments is not kernel compatible format. Could you change it like standard comment format:

/*
* xxxxxxx
* xxxx
*/

Signature · 2 lines
Thanks
    Alex