2008-10-23 13:26:29 +08:00
|
|
|
#ifndef _ASM_X86_HW_IRQ_H
|
|
|
|
#define _ASM_X86_HW_IRQ_H
|
2008-05-03 01:00:30 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* (C) 1992, 1993 Linus Torvalds, (C) 1997 Ingo Molnar
|
|
|
|
*
|
|
|
|
* moved some of the old arch/i386/kernel/irq.h to here. VY
|
|
|
|
*
|
|
|
|
* IRQ/IPI changes taken from work by Thomas Radke
|
|
|
|
* <tomsoft@informatik.tu-chemnitz.de>
|
|
|
|
*
|
|
|
|
* hacked by Andi Kleen for x86-64.
|
|
|
|
* unified by tglx
|
|
|
|
*/
|
|
|
|
|
2008-05-03 02:10:09 +08:00
|
|
|
#include <asm/irq_vectors.h>
|
2008-05-03 01:00:30 +08:00
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/profile.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
|
2011-07-27 07:09:06 +08:00
|
|
|
#include <linux/atomic.h>
|
2008-05-03 01:00:30 +08:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/sections.h>
|
|
|
|
|
|
|
|
/* Interrupt handlers registered during init_IRQ */
|
2013-08-06 06:02:37 +08:00
|
|
|
extern asmlinkage void apic_timer_interrupt(void);
|
|
|
|
extern asmlinkage void x86_platform_ipi(void);
|
|
|
|
extern asmlinkage void kvm_posted_intr_ipi(void);
|
|
|
|
extern asmlinkage void error_interrupt(void);
|
|
|
|
extern asmlinkage void irq_work_interrupt(void);
|
|
|
|
|
|
|
|
extern asmlinkage void spurious_interrupt(void);
|
|
|
|
extern asmlinkage void thermal_interrupt(void);
|
|
|
|
extern asmlinkage void reschedule_interrupt(void);
|
|
|
|
|
|
|
|
extern asmlinkage void invalidate_interrupt(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt0(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt1(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt2(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt3(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt4(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt5(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt6(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt7(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt8(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt9(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt10(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt11(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt12(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt13(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt14(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt15(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt16(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt17(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt18(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt19(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt20(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt21(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt22(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt23(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt24(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt25(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt26(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt27(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt28(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt29(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt30(void);
|
|
|
|
extern asmlinkage void invalidate_interrupt31(void);
|
|
|
|
|
|
|
|
extern asmlinkage void irq_move_cleanup_interrupt(void);
|
|
|
|
extern asmlinkage void reboot_interrupt(void);
|
|
|
|
extern asmlinkage void threshold_interrupt(void);
|
|
|
|
|
|
|
|
extern asmlinkage void call_function_interrupt(void);
|
|
|
|
extern asmlinkage void call_function_single_interrupt(void);
|
2008-05-03 01:00:30 +08:00
|
|
|
|
x86, trace: Add irq vector tracepoints
[Purpose of this patch]
As Vaibhav explained in the thread below, tracepoints for irq vectors
are useful.
http://www.spinics.net/lists/mm-commits/msg85707.html
<snip>
The current interrupt traces from irq_handler_entry and irq_handler_exit
provide when an interrupt is handled. They provide good data about when
the system has switched to kernel space and how it affects the currently
running processes.
There are some IRQ vectors which trigger the system into kernel space,
which are not handled in generic IRQ handlers. Tracing such events gives
us the information about IRQ interaction with other system events.
The trace also tells where the system is spending its time. We want to
know which cores are handling interrupts and how they are affecting other
processes in the system. Also, the trace provides information about when
the cores are idle and which interrupts are changing that state.
<snip>
On the other hand, my usecase is tracing just local timer event and
getting a value of instruction pointer.
I suggested to add an argument local timer event to get instruction pointer before.
But there is another way to get it with external module like systemtap.
So, I don't need to add any argument to irq vector tracepoints now.
[Patch Description]
Vaibhav's patch shared a trace point ,irq_vector_entry/irq_vector_exit, in all events.
But there is an above use case to trace specific irq_vector rather than tracing all events.
In this case, we are concerned about overhead due to unwanted events.
So, add following tracepoints instead of introducing irq_vector_entry/exit.
so that we can enable them independently.
- local_timer_vector
- reschedule_vector
- call_function_vector
- call_function_single_vector
- irq_work_entry_vector
- error_apic_vector
- thermal_apic_vector
- threshold_apic_vector
- spurious_apic_vector
- x86_platform_ipi_vector
Also, introduce a logic switching IDT at enabling/disabling time so that a time penalty
makes a zero when tracepoints are disabled. Detailed explanations are as follows.
- Create trace irq handlers with entering_irq()/exiting_irq().
- Create a new IDT, trace_idt_table, at boot time by adding a logic to
_set_gate(). It is just a copy of original idt table.
- Register the new handlers for tracpoints to the new IDT by introducing
macros to alloc_intr_gate() called at registering time of irq_vector handlers.
- Add checking, whether irq vector tracing is on/off, into load_current_idt().
This has to be done below debug checking for these reasons.
- Switching to debug IDT may be kicked while tracing is enabled.
- On the other hands, switching to trace IDT is kicked only when debugging
is disabled.
In addition, the new IDT is created only when CONFIG_TRACING is enabled to avoid being
used for other purposes.
Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Link: http://lkml.kernel.org/r/51C323ED.5050708@hds.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
2013-06-20 23:46:53 +08:00
|
|
|
#ifdef CONFIG_TRACING
|
|
|
|
/* Interrupt handlers registered during init_IRQ */
|
|
|
|
extern void trace_apic_timer_interrupt(void);
|
|
|
|
extern void trace_x86_platform_ipi(void);
|
|
|
|
extern void trace_error_interrupt(void);
|
|
|
|
extern void trace_irq_work_interrupt(void);
|
|
|
|
extern void trace_spurious_interrupt(void);
|
|
|
|
extern void trace_thermal_interrupt(void);
|
|
|
|
extern void trace_reschedule_interrupt(void);
|
|
|
|
extern void trace_threshold_interrupt(void);
|
|
|
|
extern void trace_call_function_interrupt(void);
|
|
|
|
extern void trace_call_function_single_interrupt(void);
|
|
|
|
#define trace_irq_move_cleanup_interrupt irq_move_cleanup_interrupt
|
|
|
|
#define trace_reboot_interrupt reboot_interrupt
|
|
|
|
#define trace_kvm_posted_intr_ipi kvm_posted_intr_ipi
|
|
|
|
#endif /* CONFIG_TRACING */
|
|
|
|
|
2008-05-03 01:00:30 +08:00
|
|
|
/* IOAPIC */
|
2009-02-09 08:18:03 +08:00
|
|
|
#define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1<<(x)) & io_apic_irqs))
|
2008-05-03 01:00:30 +08:00
|
|
|
extern unsigned long io_apic_irqs;
|
|
|
|
|
|
|
|
extern void setup_IO_APIC(void);
|
|
|
|
extern void disable_IO_APIC(void);
|
2009-05-16 04:05:16 +08:00
|
|
|
|
|
|
|
struct io_apic_irq_attr {
|
|
|
|
int ioapic;
|
|
|
|
int ioapic_pin;
|
|
|
|
int trigger;
|
|
|
|
int polarity;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void set_io_apic_irq_attr(struct io_apic_irq_attr *irq_attr,
|
|
|
|
int ioapic, int ioapic_pin,
|
|
|
|
int trigger, int polarity)
|
|
|
|
{
|
2009-10-14 04:32:36 +08:00
|
|
|
irq_attr->ioapic = ioapic;
|
|
|
|
irq_attr->ioapic_pin = ioapic_pin;
|
|
|
|
irq_attr->trigger = trigger;
|
|
|
|
irq_attr->polarity = polarity;
|
2009-05-16 04:05:16 +08:00
|
|
|
}
|
|
|
|
|
2012-09-26 18:44:44 +08:00
|
|
|
/* Intel specific interrupt remapping information */
|
2010-10-10 17:39:09 +08:00
|
|
|
struct irq_2_iommu {
|
|
|
|
struct intel_iommu *iommu;
|
|
|
|
u16 irte_index;
|
|
|
|
u16 sub_handle;
|
|
|
|
u8 irte_mask;
|
|
|
|
};
|
|
|
|
|
2012-09-26 18:44:44 +08:00
|
|
|
/* AMD specific interrupt remapping information */
|
|
|
|
struct irq_2_irte {
|
|
|
|
u16 devid; /* Device ID for IRTE table */
|
|
|
|
u16 index; /* Index into IRTE table*/
|
|
|
|
};
|
|
|
|
|
2009-10-14 04:32:36 +08:00
|
|
|
/*
|
|
|
|
* This is performance-critical, we want to do it O(1)
|
|
|
|
*
|
|
|
|
* Most irqs are mapped 1:1 with pins.
|
|
|
|
*/
|
|
|
|
struct irq_cfg {
|
2014-10-27 16:11:55 +08:00
|
|
|
struct list_head irq_2_pin;
|
2009-10-14 04:32:36 +08:00
|
|
|
cpumask_var_t domain;
|
|
|
|
cpumask_var_t old_domain;
|
|
|
|
u8 vector;
|
|
|
|
u8 move_in_progress : 1;
|
2011-08-24 08:05:25 +08:00
|
|
|
#ifdef CONFIG_IRQ_REMAP
|
2012-09-26 18:44:45 +08:00
|
|
|
u8 remapped : 1;
|
2012-09-26 18:44:44 +08:00
|
|
|
union {
|
|
|
|
struct irq_2_iommu irq_2_iommu;
|
|
|
|
struct irq_2_irte irq_2_irte;
|
|
|
|
};
|
2010-10-10 17:39:09 +08:00
|
|
|
#endif
|
2009-10-14 04:32:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *);
|
2014-10-27 16:12:11 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2009-10-14 04:32:36 +08:00
|
|
|
extern void send_cleanup_vector(struct irq_cfg *);
|
2014-10-27 16:12:11 +08:00
|
|
|
#else
|
|
|
|
static inline void send_cleanup_vector(struct irq_cfg *c) { }
|
|
|
|
#endif
|
2009-10-14 21:06:42 +08:00
|
|
|
|
2010-10-09 03:40:23 +08:00
|
|
|
struct irq_data;
|
|
|
|
int __ioapic_set_affinity(struct irq_data *, const struct cpumask *,
|
|
|
|
unsigned int *dest_id);
|
2014-10-27 16:11:54 +08:00
|
|
|
extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin);
|
2008-05-03 01:00:30 +08:00
|
|
|
extern void setup_ioapic_dest(void);
|
|
|
|
|
2008-05-03 04:02:25 +08:00
|
|
|
extern void enable_IO_APIC(void);
|
|
|
|
|
2008-05-03 01:00:30 +08:00
|
|
|
/* Statistics */
|
|
|
|
extern atomic_t irq_err_count;
|
|
|
|
extern atomic_t irq_mis_count;
|
|
|
|
|
2008-05-03 06:30:50 +08:00
|
|
|
/* EISA */
|
|
|
|
extern void eisa_set_level_irq(unsigned int irq);
|
|
|
|
|
2008-07-23 19:43:14 +08:00
|
|
|
/* SMP */
|
2013-08-06 06:02:37 +08:00
|
|
|
extern __visible void smp_apic_timer_interrupt(struct pt_regs *);
|
|
|
|
extern __visible void smp_spurious_interrupt(struct pt_regs *);
|
|
|
|
extern __visible void smp_x86_platform_ipi(struct pt_regs *);
|
|
|
|
extern __visible void smp_error_interrupt(struct pt_regs *);
|
2009-04-11 02:33:10 +08:00
|
|
|
#ifdef CONFIG_X86_IO_APIC
|
|
|
|
extern asmlinkage void smp_irq_move_cleanup_interrupt(void);
|
|
|
|
#endif
|
2009-01-28 00:07:08 +08:00
|
|
|
#ifdef CONFIG_SMP
|
2013-08-06 06:02:37 +08:00
|
|
|
extern __visible void smp_reschedule_interrupt(struct pt_regs *);
|
|
|
|
extern __visible void smp_call_function_interrupt(struct pt_regs *);
|
|
|
|
extern __visible void smp_call_function_single_interrupt(struct pt_regs *);
|
|
|
|
extern __visible void smp_invalidate_interrupt(struct pt_regs *);
|
2008-07-25 13:12:26 +08:00
|
|
|
#endif
|
2008-07-23 19:43:14 +08:00
|
|
|
|
2014-11-03 16:39:43 +08:00
|
|
|
extern void (*__initconst interrupt[FIRST_SYSTEM_VECTOR
|
|
|
|
- FIRST_EXTERNAL_VECTOR])(void);
|
2013-10-31 04:37:00 +08:00
|
|
|
#ifdef CONFIG_TRACING
|
|
|
|
#define trace_interrupt interrupt
|
|
|
|
#endif
|
2008-08-20 11:50:28 +08:00
|
|
|
|
2014-04-02 20:13:47 +08:00
|
|
|
#define VECTOR_UNDEFINED (-1)
|
|
|
|
#define VECTOR_RETRIGGERED (-2)
|
2014-01-06 00:10:52 +08:00
|
|
|
|
2008-05-03 04:10:39 +08:00
|
|
|
typedef int vector_irq_t[NR_VECTORS];
|
|
|
|
DECLARE_PER_CPU(vector_irq_t, vector_irq);
|
2010-03-16 06:33:06 +08:00
|
|
|
extern void setup_vector_irq(int cpu);
|
2008-08-10 06:09:02 +08:00
|
|
|
|
2008-08-20 11:50:28 +08:00
|
|
|
#ifdef CONFIG_X86_IO_APIC
|
2008-08-10 06:09:02 +08:00
|
|
|
extern void lock_vector_lock(void);
|
|
|
|
extern void unlock_vector_lock(void);
|
|
|
|
extern void __setup_vector_irq(int cpu);
|
|
|
|
#else
|
|
|
|
static inline void lock_vector_lock(void) {}
|
|
|
|
static inline void unlock_vector_lock(void) {}
|
|
|
|
static inline void __setup_vector_irq(int cpu) {}
|
|
|
|
#endif
|
2008-05-03 01:00:30 +08:00
|
|
|
|
2008-05-03 04:10:39 +08:00
|
|
|
#endif /* !ASSEMBLY_ */
|
|
|
|
|
2008-10-23 13:26:29 +08:00
|
|
|
#endif /* _ASM_X86_HW_IRQ_H */
|