wartalker
wartalker

Reputation: 348

hard interrupt and softirq

In linux, when net card receive a packet, would trigger a hard interrupt, and then in the interrupt call back function, it will raise a NET_RX_SOFTIRQ, would this softirq run at the same cpu with hard irq?

Upvotes: 8

Views: 8298

Answers (1)

OmPS
OmPS

Reputation: 341

An interrupt request (IRQ) is a request for service, sent at the hardware level. Interrupts can be sent by either a dedicated hardware line, or across a hardware bus as an information packet (a Message Signaled Interrupt, or MSI). When interrupts are enabled, receipt of an IRQ prompts a switch to interrupt context. Kernel interrupt dispatch code retrieves the IRQ number and its associated list of registered Interrupt Service Routines (ISRs), and calls each ISR in turn. The ISR acknowledges the interrupt and ignores redundant interrupts from the same IRQ, then queues a deferred handler to finish processing the interrupt and stop the ISR from ignoring future interrupts.

IRQs have an associated "affinity" property, smp_affinity, which defines the CPU cores that are allowed to execute the ISR for that IRQ. This property can be used to improve application performance by assigning both interrupt affinity and the application's thread affinity to one or more specific CPU cores. This allows cache line sharing between the specified interrupt and application threads.

# cat /proc/irq/32/smp_affinity 
  f

The default value for smp_affinity is f, meaning that the IRQ can be serviced on any of the CPUs in the system. Setting this value to 1, as follows, means that only CPU 0 can service this interrupt:

# echo 1 >/proc/irq/32/smp_affinity
# cat /proc/irq/32/smp_affinity
  1

On systems that support interrupt steering, modifying the smp_affinity of an IRQ sets up the hardware so that the decision to service an interrupt with a particular CPU is made at the hardware level, with no intervention from the kernel.

More detailed information present at Redhat's DOC - 4.3 Interrupts and IRQ tuning

Upvotes: 12

Related Questions