Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jan 2003 20:57:34 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Jeff Roberson <jeff@FreeBSD.org>
Cc:        cvs-committers@FreeBSD.org, <cvs-all@FreeBSD.org>
Subject:   Re: cvs commit: src/sys/sys proc.h src/sys/kern sched_4bsd.c
Message-ID:  <20030113202327.Q11731-100000@gamplex.bde.org>
In-Reply-To: <200301130342.h0D3gfKv064506@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030113202327.Q11731-100000>