Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of Nic interruption and CPU binding in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to solve the problem of network card interruption and CPU binding in Linux", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn "how to solve the problem of network card interruption and CPU binding in Linux".

In terms of Linux network tuning, if you find that network traffic is not going, then one aspect to check is whether the network card processing network request interrupt is tied to a single CPU or the same CPU as handling other interrupts.

The way network cards interact with operating systems

There are generally two ways to interact with the operating system:

1. interrupt IRQ

After the NIC receives the network signal, it sends an interrupt to the CPU, and the CPU will immediately stop the work at hand in order to analyze the interrupt signal.

2. DMA(Direct Memory Access)

That is to say, hardware is allowed to cache data in a specified memory space without CPU intervention and process it when CPU is appropriate;

Now symmetric multi-core processor (SMP), a card IRQ or only one CPU to respond, other CPUs can not participate, if the CPU is busy with other interrupts (other cards or other peripherals using interrupts (such as disk)), then it will form a bottleneck.

inspection environment

First, let the network run full. For example, for MySQL/MongoDB services, intensive read operations can be initiated by the client or a large file transfer task can be performed. Find out if a CPU has been busy processing IRQs?

The % irq column in the output from mpstat-P ALL 1 indicates which CPU is busy processing the interrupt percentage of time;

In the example above, the fourth CPU is busy processing interrupts 25.63% of the time, and intr/s also indicates the number of interrupts processed by the CPU per second. As can be seen from the above data, the other CPUs do not handle interrupts much.

So what interrupts are these busy CPUs handling?

Recorded here is the number of interrupts handled by each CPU since startup. The first column is the interrupt number and the last column is the corresponding device name. From the above, we can see that all the interrupts initiated by eth0 are handled by CPU 0, and the interrupt requests handled by CPU 0 are mainly eth0 and LOC interrupts. Sometimes we will see several CPUs for the same interrupt type processed by the same number of requests (such as LOC above), this does not necessarily mean that multiple CPUs will take turns to handle the same interrupt, but because the record here is "since the start" statistics, the middle may be because irq balancer has redistributed the CPU handling the interrupt.

solutions

IRQ Balance is available in most Linux systems (usually/usr/sbin/irqbalance), which automatically adjusts the binding relationship between each interrupt and CPU to avoid all interrupt processing concentrated on a few CPUs. In some cases, this IRQ Balance can cause problems, and irqbalance can occur as the process itself consumes a higher CPU (and of course affects the performance of the business system).

The first thing to see is whether the interrupt of the network card is currently limited to some CPUs? Which CPUs?

From/proc/interrupts above we can see that the interrupt number of eth0 is 74, and then we will look at the CPU binding or affinity of this interrupt number.

$ sudo cat /proc/irq/74/smp_affinity ffffff

The output is a hexadecimal value, 0xffffff ='0 b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

How to modify the configuration: (Set to 2 to bind the interrupt to CPU1, 0x2 = 0b10, and the first CPU is CPU0)

echo 2>/proc/irq/74/smp_affinity The above is "How to solve the network card interrupt and CPU binding problem in Linux" All the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report