Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Oct 2010 14:54:03 -0400
From:      Martin Turgeon <freebsd@optiksecurite.com>
To:        Bas Smeelen <b.smeelen@ose.nl>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: How is CPU usage calculated?
Message-ID:  <4CBC97CB.80604@optiksecurite.com>
In-Reply-To: <20101015071719.1536f19e@mail.ose.nl>
References:  <20101015071719.1536f19e@mail.ose.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
  Le 2010-10-15 03:17, Bas Smeelen a écrit :
> From: Martin Turgeon [mailto:freebsd@optiksecurite.com]
> To: freebsd-questions@freebsd.org
> Sent: Thu, 14 Oct 2010 21:46:13 +0200
> Subject: How is CPU usage calculated?
>
>    Hi list!
>
>    I did a strange observation yesterday night. The CPU usage reported by
>    top doesn't match what is indicated under it. I was seeing around 80-90%
>    user, 5% system, 1% interrupt and 10% idle. But the process details
>    under it doesn't match. mysqld was taking around 250% (WCPU) with a few
>    httpd processes at 1-2%. The system is running GENERIC 8.0-REL on a Xeon
>    E5630 (quad core with hyperthreading so 8 CPUs). MySQL and Apache each
>    have their own jail (I don't think it will matter but just in case)
>
>    I understand why the mysqld process take more than 100% but how can I
>    know what's taking the rest? Why doesn't the total user CPU usage match
>    the total of the CPU usage of each process? Is there a link with
>    hyperthreading?
>
>    There sure is a logical answer and I would really like to know it :)
> Yes if you have multiple cpu's, cores or hyperthreading than each unit can be used up to 100%
> Mysql has multiple threads, you can check with top -P to see the multiple cores and when top is running give the command H (capital H) to see the threads of each process
>
>
Thanks for your reply!

I didn't knew about -H to show individual threads, but my problem isn't 
there. My problem is that the summary printed in the first lines doesn't 
match the total of the process detailled under the summary. For example, 
I have a user CPU usage est 83.1% in the summary, but the only process 
worth mentionning in the list is mysqld that is taking 255.52% WCPU. 
That's far less than half the "CPU power" but 83% is far more. It's that 
difference that I don't understand.

How is this possible?

Martin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CBC97CB.80604>