🌐
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.
🌐
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
Handler: smp call function interrupt(). ... I/O APIC(s). It is also possible to share IRQs (capable to · handle more I/O devices than there are IRQ lines) in Linux.
🌐
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.
🌐
O'Reilly
oreilly.com › library › view › linux-device-drivers › 0596005903 › ch10.html
10. Interrupt Handling - Linux Device Drivers, 3rd Edition [Book]
February 7, 2005 - 9.1. I/O Ports and I/O Memory9.1.1. I/O Registers and Conventional Memory9.2. Using I/O Ports9.2.1. I/O Port Allocation9.2.2. Manipulating I/O ports9.2.3. I/O Port Access from User Space9.2.4. String Operations9.2.5. Pausing I/O9.2.6. Platform Dependencies9.3. An I/O Port Example9.3.1. An Overview of the Parallel Port9.3.2. A Sample Driver9.4. Using I/O Memory9.4.1. I/O Memory Allocation and Mapping9.4.2. Accessing I/O Memory9.4.3. Ports as I/O Memory9.4.4. Reusing short for I/O Memory9.4.5. ISA Memory Below 1 MB9.4.6. isa_readb and Friends9.5. Quick Reference · 10.1. Preparing the Parallel Port10.2. Installing an Interrupt Handler10.2.1.
Authors   Jonathan CorbetAlessandro Rubini
Published   2005
Pages   636
🌐
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.
🌐
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.
Find elsewhere
🌐
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);
🌐
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
🌐
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).
🌐
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
🌐
Baeldung
baeldung.com › home › processes › interrupt handling in linux
Interrupt Handling in Linux | Baeldung on Linux
March 19, 2025 - In this tutorial, we’ll talk about interrupt handling in Linux. We’ll start with the basics: what are interrupts, their types, and how to handle them.
🌐
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
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.
🌐
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.
🌐
The Linux Documentation Project
tldp.org › LDP › lkmpg › 2.6 › html › x1256.html
12.1. Interrupt Handlers
Then, when it receives a keyboard interrupt, it reads the keyboard's status (that's the purpose of the inb(0x64)) and the scan code, which is the value returned by the keyboard. Then, as soon as the kernel thinks it's feasible, it runs got_char which gives the code of the key used (the first seven bits of the scan code) and whether it has been pressed (if the 8th bit is zero) or released (if it's one). Example 12-1.
🌐
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.
🌐
Linux.com
linux.com › home › training and tutorials › kernel interrupt overview
Kernel Interrupt Overview - Linux.com
March 25, 2016 - Only a high priority interrupt ... specific to the current interrupt like keyboard interrupt or network interrupt. So for example e1000_intr is called for e1000e device....
🌐
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.