LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Cpu usage question (https://www.linuxquestions.org/questions/linux-server-73/cpu-usage-question-665791/)

mokku 08-27-2008 09:49 AM

Cpu usage question
 
I am running a LINUX server with 8 CPU's. If the CPU usage was 100 %
means what's the nature of the CPU usage calculation (That means all
the 8 CPU gives the 100 % usage ...? ).

Sometimes my CPU usage was crossing above 200% also. What it means...?

( Note I have 8 CPU's).

It means now CPU usage was 200/800(8 *100-for each CPU).

So how the Kernel is calculating the total CPU capacity.......?

Please explain with the examples...

My otehr questions is, if I have a script and if I want to use 200% percentage of cpu, how can I use it?

Thanks in advance

colucix 08-27-2008 10:00 AM

If you look at the CPU usage through the top command, the %CPU field is the sum of the percentages of each used CPU. If you have 8 cpu (or cores) and you run a parallel process which is properly scaled, you can see a %CPU of about 800, whereas a scalar process reaches at most 100% (that is it uses one CPU entirely).

If you press 1 (one) in top, the CPU usage in the global section (the upper part of the top output) will be splitted among all the available CPUs (details will be given for each single CPU).

mokku 08-27-2008 01:15 PM

Thank you for your reply, so If the script used 200 percentage, would it show as 200% or I need to check all the cpu to find the total percentage? Thanks in advance.

colucix 08-28-2008 03:06 AM

The first you have told! :) At least for all the parallel processes I've ever seen on Linux systems, like Fedora, Ubuntu and OpenSuSE.

Just out of curiosity... which kind of script would reach such a performance, using 2 CPU? Is it something like Parallel Python?

mokku 08-28-2008 11:39 PM

Its a java thread that user needs to run and wanted to push the cpu to 200% and what is the good way to do it?

chrism01 08-31-2008 09:34 PM

If you want to pressure the cpu, you need a cpu-bound prog eg a simple calc in a tight loop
pseudo-code

while(1)
do
x = 1;
done

this would need to be manually stopped eg ctrl-C.The more complex you make it, the more likely it is to be swapped out of the cpu, esp if it involves any I/O eg checking keybd for stop signal.

sundialsvcs 09-02-2008 08:33 AM

The best way to understand this figure is to go look at the actual code in the Scheduler which computes it.

Generally speaking, the statistics are per process, and they are therefore pretty agnostic as to which CPU(s) participated. Commands like top then "roll-up" those per-process statistics into a summary.

When calculating overall workload of a CPU (for load-balancing purposes), the scheduler applies various "weighted-average"-type statistics to suppress the effect of the nanosecond-to-nanosecond variations that inevitably occur.

All of these things rely heavily on periodic sampling, again for the same reasons.


All times are GMT -5. The time now is 06:14 AM.