From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 18 22:39:49 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D87A016A405 for ; Tue, 18 Apr 2006 22:39:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 141EA43D62 for ; Tue, 18 Apr 2006 22:39:44 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k3IMdhcG097587; Tue, 18 Apr 2006 18:39:44 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Marco van Tol Date: Tue, 18 Apr 2006 18:38:26 -0400 User-Agent: KMail/1.9.1 References: <20060412215021.GB1146@tols.org> <20060417134825.GA47043@tols.org> <20060418221505.GC58081@tols.org> In-Reply-To: <20060418221505.GC58081@tols.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200604181838.27713.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1407/Tue Apr 18 17:01:55 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: freebsd-hackers@freebsd.org Subject: Re: Per CPU cpu-statistics under SMP X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2006 22:39:49 -0000 On Tuesday 18 April 2006 18:15, Marco van Tol wrote: > On Mon, Apr 17, 2006 at 01:48:25PM +0000, Marco van Tol wrote: > > On Mon, Apr 17, 2006 at 09:04:58AM -0400, John Baldwin wrote: > > [...] > > > > I actually did it differently though to try and make it less confusing. > > > I've added a kern.pcpu_time sysctl which is an array of 0..mp_maxid > > > cp_time[] arrays (so (mp_maxid + 1) * CPUSTATES longs) which is just the > > > per-CPU data. Userland can sum them up if it wants a composite total. > > > Userland would first do a sysctl with a NULL buffer to get the required > > > size (since it can vary with the number of CPUs in the system), malloc() > > > a buffer, and then use the malloc'd buffer to make the requests. You > > > should only have to do the malloc() at process start since FreeBSD doesn't > > > currently allow for more CPUs to be added at runtime. You can try out > > > the patch at http://www.FreeBSD.org/~jhb/patches/cp_time.patch > > > > Great thanks! > > > > I will try to apply the patch, and try to modify gkrellm to support it. > > I'll drop them (gkrellm developers) a note that I'm doing this, as it would > > be a waist of effort if somebody else has been doing preliminary work that > > I'd be doing again. :) > > > > I'll keep you up-to-date. > > I'm trying to apply the patch. Tried it to both todays current and todays > RELENG_6, but both have failing hunks in sys/kern/kern_clock.c. > The rest succeeds. > > I can do two things: > - Try to manually patch it against todays current. > - re-checkout todays RELENG_6, and download the relevant files from the > cvsweb interface from the date you posted the patch from that days > CURRENT. Then try to apply the patch. > > For the latter it may break the kernelbuild, but I'm very tempted to try > that one ahead of the manual patching attempt. ;) > > I'll keep you posted on how far I'm getting with this. Guess I should have > gone straight to current the day you posted the patch. Sorry. Ah, hmm. On 6.x we don't have per-thread stat ticks yet, which is probably why it is failing. It also isn't safe to move sched_lock down either on 6.x. You can still apply the rest of the patch by hand, just leave the 'mtx_lock_spin(&sched_lock)' where it is and change all the 'cp_time[FOO]++' to 'PCPU_LAZY_INC(cp_time[FOO])'. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org