Ubuntu top command cpu usage more than 100
Through the study of load average and CPU context switching in my previous two articles: “Linux CPU Context Switch Deep Dive”, “Linux CPU Context Switch Troubleshooting”, I believe you have a preliminary understanding of CPU performance. But what metrics do you use most to troubleshoot high CPU usages? Show
CPU UsageThe CPU usage is a statistic of CPU usage per unit time, displayed as a percentage. So, as the most commonly used and most familiar CPU metric, can you tell how the CPU usage is calculated? Also, do you know the meaning behind`%user`, Let’s deep dive into CPU usage in this article. As I mentioned earlier, Linux is a multitasking OS, which divides the time of each CPU into very short time slices, and then allocates them to each task in turn through the scheduler, thus creating the illusion of multitasking running at the same time. In order to obtain CPU time, Linux triggers a time interrupt through a pre-defined beat rate (express as HZ in the kernel), and uses the global variable The beat rate $ grep 'CONFIG_HZ=' /boot/config-$(uname -r) CONFIG_HZ_250=y CONFIG_HZ=250 `%user`1 means 250 interrupts are triggered per second (1 interrupt every 4 milliseconds). Upon receiving a time interrupt, the kernel drops everything and performs various scheduling and timekeeping related tasks. The tick rate Issue
Environment
Subscriber exclusive contentA Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more. Current Customers and PartnersLog in for full access Log In CPU utilization is the amount of work a CPU does to perform the tasks given to it. It’s an important metric to track because high CPU usage can negatively impact the performance of a system. CPU usage can vary according to the CPU core count, since the system performs faster and more efficiently in the case of a higher core system. If the CPU cores are unable to handle the heavy load of an application, it results in context switching of tasks. But too much context switching will also cause a rise in CPU usage. Tracking and monitoring CPU efficiency are essential for handling system processes and resources. Luckily, there are a number of tools available to monitor this metric. Causes of high CPU utilizationSince high CPU utilization indicates poor system performance, it should be avoided. Higher than average CPU usage can often be attributed to one of the following causes: 1. System idle processIf a system is idle, the OS creates a process called the System Idle Process to prevent the system from shutting off. This process appears to show high CPU usage, but it actually indicates the percentage of CPU capacity not being used. If the idle process is taking up to 99% of the CPU's power, it means only 1% is being used to run actual tasks. 2. Autostart programs and background processesAutostart programs are applications that are launched automatically when booting the operating system and they continue to run in the background. Too many background processes running simultaneously on a computer consume CPU resources and unnecessarily cause high CPU usage. 3. Virus and malwareIf a system becomes extremely slow with a CPU usage of nearly 100%—but with no clear cause—the problem may be a virus or malware. These are often invisible and heavily utilize the CPU. 4. BrowserEven the browser can cause high CPU usage if:
5. Programs with high CPU requirementApplications or programs that require high processing power, including video editing software and high-resolution video games—can easily drive up CPU usage. Effects of high CPU utilizationHigh CPU utilization adversely impacts system performance in the following ways:
It's essential to check the CPU usage regularly to understand the cause and impact of high CPU utilization. Determining CPU utilizationBelow are some of the most popular commands used for real-time monitoring of the CPU usage in a Linux system. top CommandThe For example, running the In the output above, the top command displays various important CPU statistics, including idle time and wait time. You can calculate the overall CPU utilization using the idle time using the formula given below: CPU utilization = 100 - idle time For example, in the output above, the idle time is 98.3%, so the CPU utilization can be calculated as follows: CPU utilization = 100 - 98.3 = 1.7% The top command generates a list of processes sorted by the parameter %CPU, or percentage of CPU consumed by a process. This list includes various details about each process and is refreshed automatically every 5 seconds. mpstat CommandThe Running the This command shows various CPU statistics including idle time, io wait time and steal time. Similar to the The following command can be run to get statistics for each of the CPUs or processors: mpstat -P ALL This command will generate an output similar to the one shown in figure 3. Fig 3: Output of mpstat -p ALL commandThus, the CPU utilization of processors CPU0 and CPU1 can be calculated as shown below: CPU0 = 100 - 92.13 = 7.87 CPU1= 100 - 22.78 = 77.22 Monitoring CPU utilization per processChecking the CPU utilization for each process is essential. A system may show high CPU utilization even though only a few processes account for most of the usage. Investigate individual processes to identify the cause and terminate them as needed. In addition to ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 0 is another useful command for viewing process-level CPU statistics. ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 0 command The ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 0 command provides information about the processes running in the Linux system. It’s used to view process-related information, including the user of the process, the type of terminal used, and the ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 3 of the process. Running the ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 0 command on a Linux system will generate an output similar to the one shown below. Fig 4: Output of ps commandYou can also use the ps command to view the top 10 most CPU-intensive processes by running the following command: ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 The output of this command will look similar to the figure below. Fig 5: Top 10 most CPU consuming processesThe output of the above command provides process-related information such as process ID(PID), process user, and the command used to run the process. This information is sorted according to CPU utilization and helps a user identify the process using most of the CPU so they can take action accordingly. ConclusionCPU utilization represents the amount of work a CPU handles to process resources or manage an operating system’s tasks. This metric is used to determine system performance by estimating the average CPU usage over a certain period of time. Several factors contribute to high CPU usage so it’s essential to find the root cause to reduce it. This article provides three useful commands— ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10 0 to help users monitor and troubleshoot CPU related issues on Linux. In most scenarios, these commands are sufficient to troubleshoot and reduce the high CPU utilization. Why does top show more than 100% CPU?htop shows that cpu usage of per core over 100%? Some blogs explain that this is because I'm using a multi-core machine(this is true). If there are 8 (logic) cores, the max value of CPU% is gonna be 800%. CPU% over 100% means that my task is occupying more than one core. What is CPU above 100 in Linux top command?Yes, if a process in top goes over 100% or top shows >1.0 in load, this means that more than one core is occupied, or the system is oversubscribed. Oversubscription means that there is more work to be put onto the core than is phsyically manageble. Why is my CPU usage above 100%?CPU usage going up to 100% can be caused by multiple things such as a failing hard drive, virus/malware, or software that utilizes the CPU so much. What is the 800% CPU in top command?If you have 8 cores, then top can display CPU usage from 0% (idle system) to 800% (full power). Your program is just using your 4 cores with hyper-threading (so 8 virtual cores) at maximum capacity. So top gives you nearly 8 x 100% = 800%. |