From owner-cvs-all@FreeBSD.ORG Tue Apr 15 06:03:56 2003 Return-Path: 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 D815037B401; Tue, 15 Apr 2003 06:03:56 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id E2E3743F85; Tue, 15 Apr 2003 06:03:54 -0700 (PDT) (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 XAA24983; Tue, 15 Apr 2003 23:03:51 +1000 Date: Tue, 15 Apr 2003 23:03:50 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Philippe Charnier In-Reply-To: <200304141951.h3EJpao1076018@repoman.freebsd.org> Message-ID: <20030415213215.R1029@gamplex.bde.org> References: <200304141951.h3EJpao1076018@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/bin/ps print.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Apr 2003 13:03:57 -0000 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