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

Troubleshooting skills of excessive utilization of CPU in Linux system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "troubleshooting skills with high CPU utilization in Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Below, here are some troubleshooting techniques for overutilized CPU:

1. Use the top command to locate the process that takes up high cpu.

Execute the top command to get the following results:

From the above figure, we can clearly see that the process PID41843 occupies too much cpu, there is an obvious problem, and the process id is located. Of course, if you want to observe only the CPU and memory and load of the process PID41843, you can use the following command

Top-p 41843

The results are as follows:

2. Use the top command to locate the cpu occupied by each thread in the problem process

Using the cpu occupied by each thread in the problem process, you can use the following command:

Top-p 41843-H

See how each thread of the process PID41843 occupies CPU, as shown in the figure.

From the figure above, you can clearly see that the thread PID41892CPU occupancy rate is *. Next, if there is an exception in the code that locates the thread, the cpu usage is too high.

3. Locate the problem code through the jstack command

The previous step found that the CPU occupied by PID41892 is too high, so convert the PID to hexadecimal, and it is easy to know that PID41892 is converted to hexadecimal to a3a4. Use the following command to locate the problem code:

Jstack 41892 | grep a3a4

The output is as follows:

"Thread" prio=10 tid=0x00007f950043e000 nid=0x54ee in test ()

It can be analyzed that the wait () function cpu under thread Thread has a high utilization rate. The test () function code in the source code is as follows:

The while loop cannot be finished, and the cpu has been preempted all the time. As a result, the program cpu is overused, and the code can be modified.

This is the end of the content of "troubleshooting skills with excessive CPU utilization in Linux system". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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