Skip to content

Commit 346b46b

Browse files
Fernando Luis Vázquez CaoIngo Molnar
authored andcommitted
x86: Add per-cpu stat counter for APIC ICR read tries
In the IPI delivery slow path (NMI delivery) we retry the ICR read to check for delivery completion a limited number of times. [ The reason for the limited retries is that some of the places where it is used (cpu boot, kdump, etc) IPI delivery might not succeed (due to a firmware bug or system crash, for example) and in such a case it is better to give up and resume execution of other code. ] This patch adds a new entry to /proc/interrupts, RTR, which tells user space the number of times we retried the ICR read in the IPI delivery slow path. This should give some insight into how well the APIC message delivery hardware is working - if the counts are way too large then we are hitting a (very-) slow path way too often. Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> Cc: Jörn Engel <joern@logfs.org> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Link: http://lkml.kernel.org/n/tip-vzsp20lo2xdzh5f70g0eis2s@git.kernel.org [ extended the changelog ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent b95a7bd commit 346b46b

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎arch/x86/include/asm/apic.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ extern int wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip);
410410
#endif
411411

412412
#ifdef CONFIG_X86_LOCAL_APIC
413+
414+
DECLARE_PER_CPU(unsigned, icr_read_retry_count);
415+
413416
static inline u32 apic_read(u32 reg)
414417
{
415418
return apic->read(reg);

‎arch/x86/kernel/apic/apic.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ DEFINE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid, BAD_APICID);
7979
EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid);
8080
EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
8181

82+
/*
83+
* ICR read retry counter
84+
*/
85+
DEFINE_PER_CPU(unsigned, icr_read_retry_count);
86+
8287
#ifdef CONFIG_X86_32
8388

8489
/*
@@ -250,6 +255,7 @@ u32 native_safe_apic_wait_icr_idle(void)
250255
send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
251256
if (!send_status)
252257
break;
258+
percpu_inc(icr_read_retry_count);
253259
udelay(100);
254260
} while (timeout++ < 1000);
255261

‎arch/x86/kernel/irq.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ int arch_show_interrupts(struct seq_file *p, int prec)
7474
for_each_online_cpu(j)
7575
seq_printf(p, "%10u ", irq_stats(j)->apic_irq_work_irqs);
7676
seq_printf(p, " IRQ work interrupts\n");
77+
seq_printf(p, "%*s: ", prec, "RTR");
78+
for_each_online_cpu(j)
79+
seq_printf(p, "%10u ", per_cpu(icr_read_retry_count, j));
80+
seq_printf(p, " APIC ICR read retries\n");
7781
#endif
7882
if (x86_platform_ipi_callback) {
7983
seq_printf(p, "%*s: ", prec, "PLT");
@@ -136,6 +140,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
136140
sum += irq_stats(cpu)->irq_spurious_count;
137141
sum += irq_stats(cpu)->apic_perf_irqs;
138142
sum += irq_stats(cpu)->apic_irq_work_irqs;
143+
sum += per_cpu(icr_read_retry_count, cpu);
139144
#endif
140145
if (x86_platform_ipi_callback)
141146
sum += irq_stats(cpu)->x86_platform_ipis;

0 commit comments

Comments
 (0)