Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Apr 2003 23:03:50 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Philippe Charnier <charnier@FreeBSD.org>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/bin/ps print.c
Message-ID:  <20030415213215.R1029@gamplex.bde.org>
In-Reply-To: <200304141951.h3EJpao1076018@repoman.freebsd.org>
References:  <200304141951.h3EJpao1076018@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 14 Apr 2003, Philippe Charnier wrote:

> charnier    2003/04/14 12:51:36 PDT
>
>   FreeBSD src repository
>
>   Modified files:
>     bin/ps               print.c
>   Log:
>   Correct style bugs. Don't skip zombies in cputime(), according to Bruce,
>   zombie CPU times are valid. Adjust array size in strftime(3).
>
>   Submitted by:   Bruce

The zombies part wasn't ready for committing.

Actually, zombie CPU times aren't valid, at least mostly.  Usually
(perhaps still always), zombies have completed exiting when we see
them in ps, so they don't have any user pages to hold the times and
we don't need to check for them specially (if there are no user pages,
the the kernel clears PS_INMEM and ps doesn't set ki_valid; when
ki_valid is not set, ps can't find any times so it prints 0).

It is a bug for ps to not display times and other things in swapped
out user pages, but in any case ki_valid should be be clear if the
"user area" as seen by ps is invalid.  OTOH, ps doesn't see a real
user area.  It just sees whatever kvm_getprocs() returns, which is
normally whatever the kern.proc.all sysctl returns.  The kernel bzeros
fields that it can't set, so "invalid" time fields are just as valid
as any that we can invent so there doesn't need to be a special case
for swapped out times either.  (Support for reading swapped out user
pages was lost in rev.1.30 of ps.c, or perhaps earlier when it rotted
in libkvm.)

If/when the kernel is premptible, ps might be able to see kernel
implementation details involving setting the process state to PRS_ZOMBIE
before setting PS_INMEM, or vice versa.  Locking in the kernel should
prevent problems, and in any case the zombie and inmem checks are
mostly bogus, since we depend on the kern.proc.all sysctl returning a
coherent state.  The sysctl of course has to have locking and check
the flags to decide if the user area, etc., is accessible.  I think
we already depend on fields whose primary copy is inaccessible being
initialized to 0, since there are many more special cases than can be
covered by a single validity flag.

Bruce



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