Re: [PATCH V2 1/2] trace,x86: Add external_interrupts to the irq_vectors class

2019-04-08 Thread Daniel Bristot de Oliveira
On 4/5/19 11:15 PM, Thomas Gleixner wrote:
> On Mon, 1 Apr 2019, Daniel Bristot de Oliveira wrote:
> 
>> Currently, the irq_vectors is showing the entry and exit events for
>> the interrupts of the architecture, but not for external interrupts.
> 
> Those are covered by the irq tracepoints. Is there a really good reason why
> we need both?

The irq_handler_* tracepoints might give the "imprecise" idea that more than one
interrupts were raised when we have shared handlers. For instance:

 %< 
f-892   [000] d.h.   790.617251: external_interrupt_entry: vector=37
f-892   [000] d.h.   790.617257: irq_handler_entry: irq=11 name=uhci_hcd:usb3
f-892   [000] d.h.   790.617343: irq_handler_exit: irq=11 ret=handled
f-892   [000] d.h.   790.617343: irq_handler_entry: irq=11 name=uhci_hcd:usb4
f-892   [000] d.h.   790.617349: irq_handler_exit: irq=11 ret=unhandled
f-892   [000] d.h.   790.617350: irq_handler_entry: irq=11 name=qxl
f-892   [000] d.h.   790.617360: irq_handler_exit: irq=11 ret=handled
f-892   [000] d.h.   790.617387: external_interrupt_exit: vector=37
 >% 

In this case, a single interrupt occurrence (vector 37) caused two handlers to
handle their interrupt.

>From a latency analysis perspective, the external_interrupt_* tracepoints turn
clearer that a single interrupt interfered in the thread execution happened, not
two separated executions of the same vector.

The outer-most tracepoints also help to have a more precise accounting of the
interference:

Using the sum of the irq_handler_* tracepoints we have:
(790.617343−790.617257)+(790.617349−790.617343)+(790.617360−790.617350) = 102 us

While using the irq_vector based one:
 790.617387-790.617251 = 136 us

So, the proposed tracepoints help clarify the logical sequence of the interrupt
handling, while increasing the precision of the measurements.

Thoughts?

-- Daniel
> Thanks,
> 
>   tglx
> 



Re: [PATCH V2 1/2] trace,x86: Add external_interrupts to the irq_vectors class

2019-04-05 Thread Thomas Gleixner
On Mon, 1 Apr 2019, Daniel Bristot de Oliveira wrote:

> Currently, the irq_vectors is showing the entry and exit events for
> the interrupts of the architecture, but not for external interrupts.

Those are covered by the irq tracepoints. Is there a really good reason why
we need both?

Thanks,

tglx



[PATCH V2 1/2] trace,x86: Add external_interrupts to the irq_vectors class

2019-04-01 Thread Daniel Bristot de Oliveira
Currently, the irq_vectors is showing the entry and exit events for
the interrupts of the architecture, but not for external interrupts.

Adds the tracepoints for external interrupts.

Example of output:
 -0 [000] d.h.   102.890935: external_interrupt_entry: vector=35
 -0 [000] d.h.   102.890960: external_interrupt_exit: vector=35

Changes from V1:
  - Fix a compilation problem when CONFIG_X86_LOCAL_APIC is not set (kbuild 
test)

Signed-off-by: Daniel Bristot de Oliveira 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Cc: Andy Lutomirski 
Cc: Clark Williams 
Cc: linux-kernel@vger.kernel.org
Cc: x...@kernel.org
---
 arch/x86/include/asm/trace/irq_vectors.h | 10 +-
 arch/x86/kernel/irq.c|  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/trace/irq_vectors.h 
b/arch/x86/include/asm/trace/irq_vectors.h
index 33b9d0f0aafe..38e73d56db70 100644
--- a/arch/x86/include/asm/trace/irq_vectors.h
+++ b/arch/x86/include/asm/trace/irq_vectors.h
@@ -138,6 +138,12 @@ DEFINE_IRQ_VECTOR_EVENT(deferred_error_apic);
 DEFINE_IRQ_VECTOR_EVENT(thermal_apic);
 #endif
 
+/*
+ * external_interrupt - called when entering/exiting from regular device
+ * interrupt vector handler.
+ */
+DEFINE_IRQ_VECTOR_EVENT(external_interrupt);
+
 TRACE_EVENT(vector_config,
 
TP_PROTO(unsigned int irq, unsigned int vector,
@@ -385,7 +391,9 @@ TRACE_EVENT(vector_free_moved,
  __entry->is_managed)
 );
 
-
+#else /* CONFIG_X86_LOCAL_APIC */
+#define trace_external_interrupt_entry(vector) do {} while(0)
+#define trace_external_interrupt_exit(vector) do {} while(0)
 #endif /* CONFIG_X86_LOCAL_APIC */
 
 #undef TRACE_INCLUDE_PATH
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 59b5f2ea7c2f..715afe3a4f24 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -237,6 +237,7 @@ __visible unsigned int __irq_entry do_IRQ(struct pt_regs 
*regs)
unsigned vector = ~regs->orig_ax;
 
entering_irq();
+   trace_external_interrupt_entry(vector);
 
/* entering_irq() tells RCU that we're not quiescent.  Check it. */
RCU_LOCKDEP_WARN(!rcu_is_watching(), "IRQ failed to wake up RCU");
@@ -255,6 +256,7 @@ __visible unsigned int __irq_entry do_IRQ(struct pt_regs 
*regs)
}
}
 
+   trace_external_interrupt_exit(vector);
exiting_irq();
 
set_irq_regs(old_regs);
-- 
2.19.0