How is CPU usage calculated?

Bas Smeelen b.smeelen at ose.nl
Fri Oct 15 07:17:22 UTC 2010


From: Martin Turgeon [mailto:freebsd at optiksecurite.com]
To: freebsd-questions at 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    


DISCLAIMER: This e-mail is for the intended recipient(s) only. Access, disclosure, copying,
distribution or reliance on any of it by anyone else is prohibited. If you have received it
by mistake please let us know by reply and then delete it from your system.


More information about the freebsd-questions mailing list