Incomputing,Intel'sAdvanced Programmable Interrupt Controller (APIC) is a family ofprogrammable interrupt controllers. As its name suggests, the APIC is more advanced than Intel's8259 Programmable Interrupt Controller (PIC), particularly enabling the construction ofmultiprocessor systems. It is one of several architectural designs intended to solve interrupt routing efficiency issues in multiprocessor computer systems.
The APIC is a split architecture design, with a local component (LAPIC) usually integrated into the processor itself, and an optional I/O APIC on a system bus. The first APIC was the 82489DX – it was a discrete chip that functioned both as local and I/O APIC. The 82489DX enabled construction ofsymmetric multiprocessor (SMP) systems with theIntel 486 and earlyPentium processors; for example, the reference two-way 486 SMP system used three 82489DX chips, two as local APICs and one as I/O APIC. Starting with theP54C processor, the local APIC functionality was integrated into the Intel processors' silicon. The first dedicated I/O APIC was the Intel 82093AA, which was intended forPIIX3-based systems.
There are two components in the Intel APIC system, thelocal APIC (LAPIC) and theI/O APIC. There is one LAPIC in each CPU in the system. In the very first implementation (82489DX), the LAPIC was a discrete circuit, as opposed to its later implementation in Intel processors' silicon. There is typically one I/O APIC for each peripheral bus in the system. In original system designs, LAPICs and I/O APICs were connected by a dedicated APIC bus. Newer systems use the system bus for communication between all APIC components.
Each APIC, whether a discrete chip or integrated in a CPU, has a version register containing a four-bit version number for its specific APIC implementation. For example, the 82489DX has an APIC version number of 0, while version 1 was assigned to the first generation of local APICs integrated in the Pentium 90 and 100 processors.[1]: 3-5
In systems containing an8259 PIC, the 8259 may be connected to the LAPIC in the system's bootstrap processor (BSP), one of the system's I/O APICs, or both. Logically, however, the 8259 is only connected once at any given time.
The first-generation Intel APIC chip, the 82489DX, which was meant to be used withIntel 80486 and early Pentium processors, is actually an external local and I/O APIC in one circuit. The Intel MP 1.4 specification refers to it as "discrete APIC" in contrast with the "integrated APIC" found in most of the Pentium processors.[1]: 1-4 The 82489DX had 16 interrupt lines;[2] it also had a quirk that it could lose some ISA interrupts.[3]
In a multiprocessor 486 system, each CPU had to be paired with its own 82489DX; additionally a supplementary 82489DX had to be used as I/O APIC. The 82489DX could not emulate the 8259A (XT-PIC) so these also had to be included as physical chips for backwards compatibility.[1]: 5-3 The 82489DX was packaged as a 132-pinPQFP.[2] It was available for USD $26 per 1,000-unit in quantities.[4]
Local APICs (LAPICs) manage all external interrupts for some specific processor in an SMP system. In addition, they are able to accept and generateinter-processor interrupts (IPIs) between LAPICs. A single LAPIC may support up to 224 usableinterrupt vectors from an I/O APIC. Vector numbers 0 to 31, out of 0 to 255, are reserved for exception handling by x86 processors.
All Intel processors starting with the P5 microarchitecture (P54C) have a built-in local APIC.[5][6] However, if the local APIC is disabled in a P5 processor, it cannot be re-enabled by software; this limitation no longer exists in theP6 processors and later ones.[6]
With the introduction ofPentium 4 HT andPentium D, each CPU core and each CPU thread have the integrated LAPIC.
TheMessage Signaled Interrupts (MSI) feature of the PCI 2.2 and later specifications cannot be used without the local APIC being enabled.[7] Use of MSI obviates the need for an I/O APIC. Additionally, up to 224 interrupts are supported in MSI mode, and IRQ sharing is not allowed.[8]: 10–11
Another advantage of the local APIC is that it also provides a high-resolution (on the order of onemicrosecond or better) timer that can be used in both interval and one-off mode.[6]
The APIC timer had its initial acceptance woes. A Microsoft document from 2002 (which advocated for the adoption ofHigh Precision Event Timer instead) criticized the LAPIC timer for having "poor resolution" and stating that "the clocks silicon is sometimes very buggy".[9] Nevertheless, the APIC timer is used for example byWindows 7 whenprofiling is enabled, and byWindows 8 in all circumstances. (Before Windows 8 claimed exclusive rights to this timer, it was also used by some programs likeCPU-Z.) Under Microsoft Windows the APIC timer is not a shareable resource.[10]
The aperiodic interrupts offered by the APIC timer are used by theLinux kerneltickless kernelfeature. This optional but default feature is new with 2.6.18. When enabled on a computer with an APIC timer, the kernel does not use the8253programmable interval timer for timekeeping.[11] AVMware document notes that "software does not have a reliable way to determine its frequency. Generally, the only way to determine the local APIC timer’s frequency is to measure it using the PIT or CMOS timer, which yields only an approximate result."[12]
I/O APICs contain a redirection table, which is used to route the interrupts it receives from peripheral buses to one or more local APICs. Early I/O APICs (like 82489DX, SIO.A and PCEB/ESC) only had support for 16 interrupt lines, but later ones like 82093AA (separate chip for PIIX3/PIIX4) had support for 24 interrupt lines.[8]: 10–11 It was packaged as a 64-PinPQFP.[13] The 82093AA normally connected to thePIIX3/PIIX4 and used its integrated legacy 8259 PICs.[13] TheICH1 integrated the I/O APIC. An integrated I/O APIC of modern chipsets may provide more than 24 interrupt lines.[14]
According to a 2009 Intel benchmark usingLinux, the I/O APIC reduced interrupt latency by a factor of almost three relative to the 8259 emulation (XT-PIC), while using MSI reduced the latency even more, by a factor of nearly seven relative to the XT-PIC baseline.[8]: 19
ThexAPIC was introduced with thePentium 4, while thex2APIC is the most recent generation of the Intel's programmable interrupt controller, introduced with theNehalem microarchitecture in November 2008.[15] The major improvements of the x2APIC address the number of supported CPUs and performance of the interface.
The x2APIC now uses 32 bits to address CPUs, allowing to address up to 232 − 1 CPUs using the physical destination mode. The logical destination mode now works differently and introduces clusters; using this mode, one can address up to 220 − 16 processors.
The improved interface reduces the number of needed APIC register accesses for sendinginter-processor interrupts (IPIs). Because of this advantage,KVM can and does emulate the x2APIC for older processors that do not physically support it, and this support is exposed fromQEMU going back toConroe and even for AMDOpteron G-series processors (neither of which natively support x2APIC).[16][17]
APICv is Intel's brand name forhardware virtualization support aimed at reducing interrupt overhead in guests. APICv was introduced in theIvy Bridge-EP processor series, which is sold as Xeon E5-26xx v2 (launched in late 2013) and as Xeon E5-46xx v2 (launched in early 2014).[18][19] AMD announced a similar technology calledAVIC,[20][21] it is available family15h models 6Xh (Carrizo) processors and newer.[22]
This sectiondoes notcite anysources. Please helpimprove this section byadding citations to reliable sources. Unsourced material may be challenged andremoved.(February 2014) (Learn how and when to remove this message) |
There are a number of known bugs in implementations of APIC systems, especially with concern to how the8254 is connected. DefectiveBIOSes may not set up interrupt routing properly, or provide incorrectACPI tables and IntelMultiProcessor Specification (MPS) tables.
The APIC can also be a cause of system failure when the operating system does not support it properly. On older operating systems, the I/O and local APICs often had to be disabled. While this is not possible anymore due to the prevalence ofsymmetric multiprocessor andmulti-core systems, the bugs in the firmware and the operating systems are now a rare occurrence.
AMD andCyrix once proposed a somewhat similar-in-purposeOpenPIC architecture supporting up to 32 processors;[23] it had at least declarative support fromIBM andCompaq around 1995.[24] No x86 motherboard was released with OpenPIC however.[25] After the OpenPIC's failure in the x86 market, AMD licensed Intel's APIC for itsAMD Athlon and later processors.
IBM however developed theirMultiProcessor Interrupt Controller (MPIC) based on the OpenPIC register specifications.[26] MPIC was used inPowerPC based designs, including those of IBM, for instance in someRS/6000 systems,[27] but also by Apple, as late as theirPower Mac G5s.[28][29]