X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-Id: <200710111458.l9BEwBoo022386@tigris.pounder.sol.net> To: cygwin AT cygwin DOT com From: cygzw AT trodman DOT com (Tom Rodman) Reply-to: cygwin AT cygwin DOT com Subject: interpretation of %CPU in 'procps' output for multi-cpu & hyperthreading Date: Thu, 11 Oct 2007 09:58:10 -0500 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Pls look at the example below (PS1 prompt def shown, and shell alias/funct defs shown). Notice that gzip is listed as having 3 threads ( 'OurServer109' is a 4 CPU box with hyperthreading on, so it has 8 virtual CPUs ). I would guess gzip must run on exactly 1 cpu, at any given time. If so, then at most, gzip could use 1/8 of the total CPU resources or 12.5%, as reported by windows task manager, right? So procps is reporting the percent of the current virtual CPU, that gzip is using, right? Notice that 'pslist' (from SysInternals) shows gzip, using 9%; 9/12.5 * 100 = 72% of 1 virtual CPU. Is there a way to prove that a given process with more than 1 thread, is still restricted to just one CPU? Any comments/corrections of my misconceptions, appreciated. We're running 'CYGWIN_NT-5.2 OurServer109 1.5.20s(0.155/4/2) 20060403 13:33:45 i686 Cygwin'. -- thanks, Tom --my ugly two line shell prompt: # 09:18:49 Thu 071011 2j tty3 9692 ~ # OurServer109 staffuser1 $ echo $PS1 #9692 is $$ # \t \D{%a %y%m%d} \jj \l 9692 \w\n# \h \u $ --snip # 09:04:51 Thu 071011 2j tty3 9692 /adm/bin/sys/s # OurServer109 staffuser1 $ ps_ -C gzip PID PPID %CPU S VSZ USER TT SESS PGRP START COMMAND 9564 6712 87.4 R 2060 staffuser1 tty0 6712 9564 07:47 gzip OurSrvr063#e_drive#Installs.bkf # 09:11:50 Thu 071011 2j tty3 9692 /adm/bin/sys/s # OurServer109 staffuser1 --snip # 09:12:22 Thu 071011 2j tty3 9692 /adm/bin/sys/s # OurServer109 staffuser1 $ _top 9:12:33 AM 10/11/2007 Process information for OurServer109: Name Pid CPU Thd Hnd Priv CPU Time Elapsed Time Idle 0 89 8 0 0 756:50:46.203 97:50:32.617 gzip 6924 9 3 67 2060 1:14:46.171 1:25:34.382 pslist 6688 1 2 90 960 0:00:00.187 0:00:01.249 cqmghost 3352 1 13 223 3176 1:04:59.343 97:50:13.054 --snip # 09:18:37 Thu 071011 2j tty3 9692 ~ # OurServer109 staffuser1 $ which ps_ ps_ is aliased to `procps -wwHo pid,ppid,%cpu,state,vsize,user,tty,session,pgrp,bsdstart,args' # 09:18:43 Thu 071011 2j tty3 9692 ~ # OurServer109 staffuser1 $ which _top _top is a function _top () { pslist -s ${1:-2} | perl -ne ' next if $. == 1; # skip first run, since it usually does not correct CPU% (bug in PsList 1.26) # 1st pslist line would match regex on next code line below $trig = m{Process information for } if (!$after1streport); #regex flips true then never used again $after1streport=1 if $trig; if ( ($after1streport) and (!$zero_percent_CPU) ) { print "\n" if ($zero_percent_CPU = m{^\w+\s+\d+\s+0\s+}); #only triggers on 1st process using under 1% CPU print unless ($zero_percent_CPU or m{^\s*$}); } else { if(m{Process information for }) {$zero_percent_CPU=0;print} } ' } -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/