From owner-freebsd-questions@FreeBSD.ORG Thu May 6 12:21:05 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C6E641065677 for ; Thu, 6 May 2010 12:21:05 +0000 (UTC) (envelope-from freebsd-questions@m.gmane.org) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mx1.freebsd.org (Postfix) with ESMTP id 515A68FC14 for ; Thu, 6 May 2010 12:21:04 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OA04a-0004NK-Gj for freebsd-questions@freebsd.org; Thu, 06 May 2010 14:21:00 +0200 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 May 2010 14:21:00 +0200 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 May 2010 14:21:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-questions@freebsd.org connect(): No such file or directory From: Ivan Voras Date: Thu, 06 May 2010 14:20:58 +0200 Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.8) Gecko/20100329 Thunderbird/3.0.3 In-Reply-To: X-Enigmail-Version: 1.0.1 Subject: Re: User cpu time VS system cpu time X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2010 12:21:05 -0000 On 05/06/10 13:33, cronfy wrote: > Hello, > >>> I want to understand difference between user CPU time and system CPU >>> time in system accounting. >> But keep in mind that "kernel time" is a broad category - while IO time in >> itself does not count as CPU time, file system operations for example do, >> because they really can be CPU intensive. > > Ivan, thanks for the great explanation. > > I think that I can measure user filesystem usage with sa - it reports > number of IO operations per user/command. In which other cases kernel > time is used instead of user time for a process? I do not mean all of > them - just that usually occur in practice. Everything the kernel does when requested by the user is counted as kernel time - file system access, network access, getpid(), gettimeofday(), process scheduling, memory management, etc. > I've noticed that there are moments when system load in top for system > time is very high (60-80% while user load is 15-25%, this produces > very high LA also). All processes that were run at this time show high > kernel time usage, although they usually do not. System is getting > back to normal after Apache restart (I think this is related to Apache > shared memory somehow, but not sure). As I told you before - monitor the "top" line for the processes you suspect and you will get a fairly good idea what they are doing. Look at the "STATE" column. When you are looking at per-process statistics, the system time is also accounted. For example, if a process takes 50% of a CPU, it is possible that it takes 25% in userspace and 25% in kernel (the reverse is not true - kernel can take system CPU time without it being accounted on behalf of processes). > This makes me suspect that system time in sa can not be relied on > while measuring user system usage, because it notably varies under > some circumstances for same operations. Am I wrong? Everything can be accounted for by enough statistics :)