Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How /proc/interrupts gets updated?

I would like to know how /proc/interrupts is getting up to date?

is it have only irq of drivers were probed or it contains the list of all the possible irqs in the system?

like image 532
0x90 Avatar asked Mar 05 '13 07:03

0x90


People also ask

How interrupts are handled in Linux?

An interrupt is simply a signal that the hardware can send when it wants the processor's attention. Linux handles interrupts in much the same way that it handles signals in user space. For the most part, a driver need only register a handler for its device's interrupts, and handle them properly when they arrive.

What are the data structures used to obtain the interrupt handler of an interrupt?

Each irqaction data structure contains information about the handler for this interrupt, including the address of the interrupt handling routine. As the number of interrupts and how they are handled varies between architectures and, sometimes, between systems, the Linux interrupt handling code is architecture specific.

Can interrupt handler be interrupted?

However, such kernel control paths may be arbitrarily nested; an interrupt handler may be interrupted by another interrupt handler, thus giving raise to a nested execution of kernel threads.


2 Answers

As you can see in the source of the kernel, it displays all possible irqs of the system.
In source/fs/proc/interrupts.c:39 a sequence operation is initialized to return as many elements as interrupts exist in the system for /proc/interrupts.

In source/kernel/irq/proc.c:479 we can see that the counters of every interrupt gets extracted from global counters via kstat_irqs_cpu(irq, cpu).
This means the interrupt count information gets updated in different counters, one for each cpu. The counters get summed upon reading the proc file. This is a common pattern in the kernel. It prevents contention on a global counter.

More onfo about per-cpu variables you can read here. More about interrupts in linux you can get here.

like image 77
krase Avatar answered Nov 11 '22 02:11

krase


All files under /proc are pseudo files , which means there is no actual data present in them.

When you access any file under proc fs , proc methods linked with that particular proc file is invoked , and the proc methods , access certain related kernel data structures and generate data dynamically , which can be read and displayed. Data from proc file is generally used to display status information of the system , or the state of a device driver.

The proc fs is generally implemented as part of the driver , by adding the proc and the seq fs layer to the driver code , however proc is also used by the kernel , to display status information of the system in general.Since there is no general hierarchy or classification among the proc files , they are used rarely in comparison with the newer sysfs file system.

To know how the information is generated , you must study the proc layer implemented in fs/proc/interrupts.c

This website briefly explains some of those methods.

like image 29
Barath Ravikumar Avatar answered Nov 11 '22 02:11

Barath Ravikumar