🌐
Linux Kernel Labs
linux-kernel-labs.github.io › refs › heads › master › lectures › interrupts.html
Interrupts — The Linux Kernel documentation
In SMP systems we may have multiple interrupt controllers in the systems. For example, on the x86 architecture each core has a local APIC used to process interrupts from locally connected devices like timers or thermals sensors.
🌐
Opensource.com
opensource.com › article › 20 › 10 › linux-kernel-interrupts
How the Linux kernel handles interrupts | Opensource.com
October 5, 2020 - On the bottom of the table, there are some non-numeric interrupts. They are the architecture-specific interrupts, like the local timer interrupt (LOC) on IRQ 236. Some of them are specified in the Linux IRQ vector layout in the Linux kernel source tree.
🌐
Linux Kernel
kernel.org › doc › html › v4.12 › core-api › genericirq.html
Linux generic IRQ handling — The Linux Kernel documentation
This function uses the vCPU specific data to set the vCPU affinity for an irq. The vCPU specific data is passed from outside, such as KVM. One example code path is as below: KVM -> IOMMU -> irq_set_vcpu_affinity(). ... Disable the selected interrupt line. Disables and Enables are nested.
🌐
Montana
cs.montana.edu › courses › spring2005 › 518 › Hypertextbook › jim › media › interrupts_on_linux.pdf pdf
Linux Interrupts: The Basic Concepts Mika J. Järvenpää University of Helsinki
interrupts, interrupt data structures and terms like IDT, bottom half, softirq and tasklet are explained in more detail. ... Device not avail. ... Coproc.seg.ovr. ... Seg. not present ... Stack seg. fault ... General protect. ... This number is called a vector. ... Linux uses this vector 128 to implement a system call ie.
🌐
O'Reilly
oreilly.com › library › view › linux-device-drivers › 0596005903 › ch10.html
10. Interrupt Handling - Linux Device Drivers, 3rd Edition [Book]
February 7, 2005 - Receive Interrupt Mitigation17.9. Changes in Link State17.10. The Socket Buffers17.10.1. The Important Fields17.10.2. Functions Acting on Socket Buffers17.11. MAC Address Resolution17.11.1. Using ARP with Ethernet17.11.2. Overriding ARP17.11.3. Non-Ethernet Headers17.12.
Authors   Jonathan CorbetAlessandro Rubini
Published   2005
Pages   636
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_enterprise_linux_for_real_time › 7 › html › reference_guide › chap-hardware_interrupts
Chapter 3. Hardware Interrupts | Reference Guide | Red Hat Enterprise Linux for Real Time | 7 | Red Hat Documentation
The handler will preempt any other running programs and system activities, which can slow the entire system down, and create latencies. Red Hat Enterprise Linux for Real Time modifies the way interrupts are handled in order to improve performance, and decrease latency. Example 3.1.
🌐
Embien
embien.com › blog › advanced-interrupt-handling-in-Linux
Advanced Interrupt Handling Techniques in Linux
July 28, 2024 - Advanced interrupt handling in Linux: interrupt contexts, deferred interrupt handling with softirqs and tasklets, interrupt flags in Linux, and efficient ISR techniques.
Find elsewhere
🌐
Reddit
reddit.com › r/linux › linux - interrupt handling: overview (part 1)
r/linux on Reddit: Linux - Interrupt Handling: Overview (Part 1)
December 18, 2022 -

After talking in general about the concept of interrupts (https://medium.com/@boutnaru/computer-architecture-interrupts-9d0dc849c1e5) now we are going to deep dive into how they are handled under Linux.

In order to handle an interrupt we first need to register it using a call to “request_irq” which adds the handler (https://elixir.bootlin.com/linux/v6.1/source/include/linux/interrupt.h#L165). In order to remove a handler we call “free_irq”. Fun fact, “request_irq” is referenced in 1280 files in the source code of the Linux kernel (version 6.1).

Overall, we can think about two major use cases when we are handling interrupts. First, interrupts that are designed to execute quickly. Second, interrupts which have to do several operations to complete (meaning they won’t execute quickly).

Due to that, interrupt handling has two phases (by the way it is true not only for Linux). We have “Top Half” and “Bottom Half”. The main reason for the split is the fact that we can’t perform large operations in interrupt-context (when interrupts are disable). So, what “Bottom Half” allows us is to defer work for later. For more information I suggest reading https://0xax.gitbooks.io/linux-insides/content/Interrupts/linux-interrupts-9.html.

We can sum up the phases of a “Top Half” as follows: ensure that the interrupt was triggered by the correct hardware (in case of line sharing), clearing interrupt pending bit on the hardware (if needed), does everything that needs to be immediate (like reading/writing to/from the device) and schedule the “Bottom Half” (if needed). As an example we can see the interrupt handler for a floppy (https://elixir.bootlin.com/linux/v6.1/source/drivers/block/floppy.c#L1712) that calls the deferred work in the following line https://elixir.bootlin.com/linux/v6.1/source/drivers/block/floppy.c#L1765.

Thus, “Top Half” runs in an interrupt context, which is used for quick responses to external events and it is responsible for creating the deferred work for later (the “Bottom Half”) - as we can see in the timeline diagram shown below.

Lastly, We have three types for the category of “Bottom Half”: workques, tasklets and softirq (https://www.oreilly.com/library/view/understanding-the-linux/0596002130/ch04s07.html). We will dive into each one of them in future writeups. By the way, there are also timers and normal regular kernel threads that can be used for deferred work but they are less natural for interrupt handling so I won’t go over them in this series.

Next we are going to start diving into workques, tasklets and softirq. See you in the next writeup :-).

https://hugh712.gitbooks.io/embeddedsystem/content/Images/RealTime/RT006.png
🌐
O'Reilly
oreilly.com › library › view › understanding-the-linux › 0596005652 › ch04s06.html
4.6. Interrupt Handling - Understanding the Linux Kernel, 3rd Edition [Book]
November 17, 2005 - The _ _do_IRQ( ) function4.6.1.8. Reviving a lost interrupt4.6.1.9. Interrupt service routines4.6.1.10. Dynamic allocation of IRQ lines4.6.2.
Authors   Daniel P. BovetMarco Cesati
Published   2005
Pages   942
🌐
Linux Kernel Labs
linux-kernel-labs.github.io › refs › heads › master › labs › interrupts.html
I/O access and Interrupts — The Linux Kernel documentation
Because such a situation is relatively common, the kernel provides the request_threaded_irq() function to write interrupt handling routines running in two phases: a process-phase and an interrupt context phase: #include <linux/interrupt.h> int request_threaded_irq(unsigned int irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long flags, const char *name, void *dev);
🌐
EmbeTronicX
embetronicx.com › tutorials › linux › device-drivers › interrupts-in-linux-kernel
Interrupts in Linux Kernel - Linux Device Driver Tutorial Part 12
May 19, 2023 - You can also read Sysfs, Procfs, Workqueue, Completion, Softirq, and threaded IRQ in the Linux device driver. ... This tutorial discusses the interrupts and how the kernel responds to them, with special functions called interrupt handlers (ISR).
🌐
Baeldung
baeldung.com › home › processes › interrupt handling in linux
Interrupt Handling in Linux | Baeldung on Linux
March 19, 2025 - The Programmable Interrupt Controllers (PIC) are responsible for collecting the IRQ and determining the order for passing the interrupt signals to the processor. Each CPU has IRQ assigned, and the PIC listens to the IRQ. Recent Linux systems distribute the IRQ among the cores with the Advanced ...
🌐
XML.com
xml.com › ldd › chapter › book › ch09.html
Linux Device Drivers, 2nd Edition: Chapter 9: Interrupt Handling
The number is a symbolic constant defined in <linux/interrupt.h> that identifies the bottom half to run. The function that corresponds to each bottom half is provided by the driver that owns the bottom half. For example, when mark_bh(SCSI_BH) is called, the function being scheduled for execution is scsi_bottom_half_handler, which is part of the SCSI driver.
🌐
GitHub
github.com › ANSANJAY › InterruptHandlinginKernel
GitHub - ANSANJAY/InterruptHandlinginKernel: A deep dive into the interrupt handling mechanisms within the Linux kernel. Explore how different devices, from keyboards to Ethernet ports, trigger and process interrupts. Complete with hands-on examples and real-world use cases. · GitHub
A deep dive into the interrupt handling mechanisms within the Linux kernel. Explore how different devices, from keyboards to Ethernet ports, trigger and process interrupts. Complete with hands-on examples and real-world use cases. - ANSANJAY/InterruptHandlinginKernel
Starred by 10 users
Forked by 2 users
Languages   C 91.5% | Makefile 8.5%
🌐
Site24x7
site24x7.com › learn › linux › kernel-hardware-interrupts.html
What are hardware interrupts, and how do Linux kernels handle them: Site24x7
This is why the Linux kernel handles hardware interrupts in two steps: First it executes the process most critical for replying to the interrupt, followed by the less urgent one. Hardware interrupts enable the hardware device to interact with the operating system. At times, however, hardware interrupts might cause serious problems for the production server. For example, the server might be running heavy counting tasks for a big data application.
🌐
Medium
medium.com › @boutnaru › linux-interrupt-handling-overview-part-1-bd0a841047d2
Linux — Interrupt Handling: Overview (Part 1) | by Shlomi Boutnaru, Ph.D. | Medium
December 17, 2022 - For more information I suggest reading https://0xax.gitbooks.io/linux-insides/content/Interrupts/linux-interrupts-9.html. We can sum up the phases of a “Top Half” as follows: ensure that the interrupt was triggered by the correct hardware (in case of line sharing), clearing interrupt pending bit on the hardware (if needed), does everything that needs to be immediate (like reading/writing to/from the device) and schedule the “Bottom Half” (if needed). As an example we can see the interrupt handler for a floppy (https://elixir.bootlin.com/linux/v6.1/source/drivers/block/floppy.c#L1712) that calls the deferred work in the following line https://elixir.bootlin.com/linux/v6.1/source/drivers/block/floppy.c#L1765.
🌐
The Linux Documentation Project
tldp.org › LDP › tlk › dd › interrupts.html
Chapter 7 Interrupts and Interrupt Handling
This code must understand the interrupt topology of the system. If, for example, the floppy controller interrupts on pin 6 1 of the interrupt controller then it must recognize the interrupt as from the floppy and route it to the floppy device driver's interrupt handling code.
🌐
Embien
embien.com › blog › writing-interrupt-service-routines-for-linux
Writing Interrupt Service Routines for Linux
July 21, 2024 - Learn writing interrupt service routines for Linux with Linux Device Driver Development best practices, flags, functions, and ISR examples for Linux driver development.
🌐
Linux.com
linux.com › home › training and tutorials › kernel interrupt overview
Kernel Interrupt Overview - Linux.com
March 25, 2016 - Only a high priority interrupt could interrupt the interrupt handler. This could result in nested interrupts. The common interrupt handler then calls the specific interrupt handler specific to the current interrupt like keyboard interrupt or network interrupt. So for example e1000_intr is called ...