Interrupt
In fact, the interrupt is an asynchronous event handling mechanism, can improve concurrent processing capability of the system.
Since the interrupt handler will interrupt the operation of other processes, therefore, in order to reduce the impact on the normal operation of the process scheduling, interrupt handler needs to run as fast as possible. If the interruption itself to do much, so deal with them will not be much problem; but if you break a lot of things to deal with, interrupt service routine is likely to run for a long time.
- note:
The interrupt handler in response to an interrupt, the interrupt will be temporarily closed. This leads to the last break before the process is complete, the other can not interrupt response, that interrupts may be lost.
Soft interrupt (softirq)
Linux will interrupt the process is divided into two stages, namely upper and lower halves:
- The upper half is used to process the interrupt quickly, it is prohibited under interrupt operation mode, or the time mainly deal with hardware closely related to sensitive work. That is, we often say that the hardware interrupt, is characterized by rapid implementation;
- The bottom half is used to delay processing the upper half of unfinished business, usually run as kernel threads. That is, we often say that the soft interrupt, is characterized by delayed execution.
View and soft interrupt kernel threads
- / Proc / softirqs provides a soft interrupt operation;
- / Proc / interrupts to provide a hardware interrupt the operation.
View software interrupt on the CPU cumulative number of times:
// Linux 中的软中断包括网络收发、定时、调度、RCU 锁等各种类型,可以通过查看 /proc/softirqs 来观察软中断的运行情况。
// TIMER(定时中断)、NET_RX(网络接收)、SCHED(内核调度)、RCU(RCU 锁)
[root@k8s /proc]# cat softirqs
CPU0 CPU1
HI: 5 1
TIMER: 444492709 271957759
NET_TX: 18937 15860
NET_RX: 34769092 430587974
BLOCK: 12265925 0
BLOCK_IOPOLL: 0 0
TASKLET: 853 592
SCHED: 4489427 66716813
HRTIMER: 0 0
RCU: 151213683 128619479
Each corresponds to a soft interrupt CPU kernel thread, the kernel thread called soft interrupt ksoftirqd / CPU number.
// 查看软中断线程运行情况
[root@k8s /proc]# ps aux | grep softirq
root 6 0.0 0.0 0 0 ? S Apr02 0:06 [ksoftirqd/0]
root 14 0.0 0.0 0 0 ? S Apr02 2:06 [ksoftirqd/1]
Sar
sar (System Activity Reporter system activity report) is one of system performance analysis tool is currently the most comprehensive on Linux, can be reported from the multifaceted activities of the system, including: reading and writing of documentation, use of system calls, disk I / O, CPU efficiency, memory usage, process activities and related activities such as IPC
[root@k8s /proc]# sar -n DEV 5
Linux 3.10.0-1062.4.1.el7.x86_64 (instance-010oj085) 04/07/2020 _x86_64_ (2 CPU)
04:28:56 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
04:29:01 PM vethweplf08851b 3.20 3.20 0.24 1.19 0.00 0.00 0.00
04:29:01 PM vethweplaa5bdc5 0.00 0.00 0.00 0.00 0.00 0.00 0.00
04:29:01 PM weave 30.40 31.60 3.54 9.76 0.00 0.00 0.00
04:29:01 PM vethwepl932b3c7 10.40 12.20 1.56 3.68 0.00 0.00 0.00
04:29:01 PM vxlan-6784 0.00 0.00 0.00 0.00 0.00 0.00 0.00
- The first column: indicates the time of the report.
- Second row: IFACE express card.
- Third, four: rxpck / s and txpck / s respectively received per second, the number of frames sent by the network, i.e. PPS.
- Fifth, six: rxkB / s and txkB / s respectively received per second, the number of kilobytes transmitted, i.e. BPS
You can analyze the network soft interrupt this tool
Study notes
from geeks time: "Linux Performance Tuning combat"