The linux softirq cpu usage looks strange

6.8k Views Asked by At

I am running a simple program in a client, it continue sending udp packet to a server. The interface of server is a multi-queue netcard, but I set its rx-flow-hash of udp4 to sd. So all packet will be produced in one CPU.

When I receive 40Wpackets/s, the server's that CPU cost 1% in softirq. When I receive 60Wpackets/s, the server's that CPU cost 8% in softirq. When I receive 90Wpackets/s, the server's that CPU cosr 100% in softirq.

The received number is get via running sar -n UDP 1 for a while. The cpu cost is get via mpstat -P ALL 1 for a while.

So I am confused about this.

Why it is not linear?

1

There are 1 best solutions below

0
On

The soft interrupt is executed after a hard interrupt that takes part of the code that does not need to be processed immediately.

So the soft interrupt can be seized by hard interrupt. After a general hard interrupt is executed, a soft interrupt is executed (interrupting the lower half).

But if this time there is a hard interrupt, the soft interrupt will be preempted.

In this way, when the soft interrupt queue after more than 10, will wake up ksoftirqd thread to deal with soft interrupt. Ksoftirqd thread occupied by the cpu is described in the problem of soft%.

So the package is less time, ksoftirq was awakened less, soft% very low. A lot of soft interrupt in the idle process was interrupted by a hard interrupt, cpu consumption is recorded in the idle% inside.

When the load is high, the soft interrupt is interrupted by a hard interrupt, so ksoftirqd has been running, so soft% will suddenly increase a lot.