From owner-cvs-all Mon Jan 13 1:57: 4 2003 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9450437B401; Mon, 13 Jan 2003 01:57:02 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5321B43E4A; Mon, 13 Jan 2003 01:57:01 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA15372; Mon, 13 Jan 2003 20:56:58 +1100 Date: Mon, 13 Jan 2003 20:57:34 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Jeff Roberson Cc: cvs-committers@FreeBSD.org, Subject: Re: cvs commit: src/sys/sys proc.h src/sys/kern sched_4bsd.c In-Reply-To: <200301130342.h0D3gfKv064506@repoman.freebsd.org> Message-ID: <20030113202327.Q11731-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 12 Jan 2003, Jeff Roberson wrote: > jeff 2003/01/12 19:42:41 PST > > Modified files: > sys/sys proc.h > sys/kern sched_4bsd.c > Log: > - Unbreak world. I did not notice that libkvm was still used in some places > to access the pctcpu. This will have to be sorted out more later as the > new scheduler requires a procedural interface for this data. A more > complete solution will follow. > > Revision Changes Path > 1.9 +5 -7 src/sys/kern/sched_4bsd.c > 1.289 +1 -0 src/sys/sys/proc.h Procedural interfaces in the kernel can only hinder libkvm here, since libkvm here is constructing a kinfo_proc struct from proc and thread structs read from a dead kernel like fill_kinfo_proc() in the kernel does for live kernels. The pctcpu part of the construction is currently a simple assignment. libkvm would have to duplicate the procedures for all schedulers if the interface were procedural. Another reason that the pctcpu interface shouldn't be precedural or scheduler- dependent is that the pctcpu kernel variable exists only to give a simple interface to userland (and ttyinfo()). In old versions of FreeBSD (e.g., RELENG_4) , kern_synch.c bogusly says: /* * p_pctcpu is only for ps. */ In -current, sched_4bsd.c less bogusly (but with worse English) says: /* * pctcpu is only for ps? * Do it per kse.. and add them up at the end? * XXXKSE */ pctcpu is actually used by at least ttyinfo() and fill_kinfo_proc() in the kernel (the latter just to ship it to userland), ps, libkvm, and anything that uses the relevant part of libkvm. It's use in ps is just a special case of using the relevant part of libkvm. My version of the above comment says: /* * ke_pctcpu is only for applications and * ttyinfo(). * Do it per kse, and add them up at the end? * XXXKSE */ fill_kinfo_proc() could easily call a procedure to calculate the value, and ttyinfo() could not so easily do this (ttyinfo() is called from the tty interrupt handler so the locking issues are more complicated), but schedulers (the only one in -current so far) calculate the value when they consider scheduling since this is simplest and works best. schedcpu() considers scheduling all processes at once, but setting the variable should work just as well for schedulers that handle 1 process at a time by only setting it for that process. I don't see any reasons to change this interface. pctcpu is scheduler- independent, at least compared with things like process priorities. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message