From owner-cvs-src@FreeBSD.ORG Thu Apr 24 06:22:34 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4396437B401; Thu, 24 Apr 2003 06:22:34 -0700 (PDT) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3F11543F3F; Thu, 24 Apr 2003 06:22:33 -0700 (PDT) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 0946B5308; Thu, 24 Apr 2003 15:22:30 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: "Poul-Henning Kamp" From: Dag-Erling Smorgrav Date: Thu, 24 Apr 2003 15:22:29 +0200 In-Reply-To: <2049.1051187056@critter.freebsd.dk> ("Poul-Henning Kamp"'s message of "Thu, 24 Apr 2003 14:24:16 +0200") Message-ID: User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 References: <2049.1051187056@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_proc.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Apr 2003 13:22:35 -0000 --=-=-= "Poul-Henning Kamp" writes: > The correct solution is to record the start time as "uptime" and add > "boottime" to that value before presentation. How about the attached patch? DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=p_start.diff Index: src/sys/fs/procfs/procfs_status.c =================================================================== RCS file: /home/ncvs/src/sys/fs/procfs/procfs_status.c,v retrieving revision 1.47 diff -u -r1.47 procfs_status.c --- src/sys/fs/procfs/procfs_status.c 17 Apr 2003 22:16:58 -0000 1.47 +++ src/sys/fs/procfs/procfs_status.c 24 Apr 2003 13:20:28 -0000 @@ -42,6 +42,7 @@ */ #include +#include #include #include #include @@ -129,13 +130,14 @@ } if (p->p_sflag & PS_INMEM) { - struct timeval ut, st; + struct timeval start, ut, st; calcru(p, &ut, &st, (struct timeval *) NULL); mtx_unlock_spin(&sched_lock); - sbuf_printf(sb, " %lld,%ld %ld,%ld %ld,%ld", - (long long)p->p_stats->p_start.tv_sec, - p->p_stats->p_start.tv_usec, + start = p->p_stats->p_start; + timevaladd(&start, &boottime); + sbuf_printf(sb, " %ld,%ld %ld,%ld %ld,%ld", + start.tv_sec, start.tv_usec, ut.tv_sec, ut.tv_usec, st.tv_sec, st.tv_usec); } else { Index: src/sys/kern/init_main.c =================================================================== RCS file: /home/ncvs/src/sys/kern/init_main.c,v retrieving revision 1.229 diff -u -r1.229 init_main.c --- src/sys/kern/init_main.c 13 Apr 2003 21:29:10 -0000 1.229 +++ src/sys/kern/init_main.c 24 Apr 2003 13:12:53 -0000 @@ -467,7 +467,7 @@ */ sx_slock(&allproc_lock); LIST_FOREACH(p, &allproc, p_list) { - microtime(&p->p_stats->p_start); + microuptime(&p->p_stats->p_start); p->p_runtime.sec = 0; p->p_runtime.frac = 0; } Index: src/sys/kern/kern_acct.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_acct.c,v retrieving revision 1.63 diff -u -r1.63 kern_acct.c --- src/sys/kern/kern_acct.c 17 Apr 2003 22:20:30 -0000 1.63 +++ src/sys/kern/kern_acct.c 24 Apr 2003 13:21:59 -0000 @@ -250,8 +250,10 @@ acct.ac_stime = encode_comp_t(st.tv_sec, st.tv_usec); /* (3) The elapsed time the command ran (and its starting time) */ - acct.ac_btime = p->p_stats->p_start.tv_sec; - microtime(&tmp); + tmp = boottime; + timevaladd(&tmp, &p->p_stats->p_start); + acct.ac_btime = tmp.tv_sec; + microuptime(&tmp); timevalsub(&tmp, &p->p_stats->p_start); acct.ac_etime = encode_comp_t(tmp.tv_sec, tmp.tv_usec); Index: src/sys/kern/kern_fork.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_fork.c,v retrieving revision 1.193 diff -u -r1.193 kern_fork.c --- src/sys/kern/kern_fork.c 22 Apr 2003 20:54:04 -0000 1.193 +++ src/sys/kern/kern_fork.c 24 Apr 2003 13:14:26 -0000 @@ -688,7 +688,7 @@ * If RFSTOPPED not requested, make child runnable and add to * run queue. */ - microtime(&(p2->p_stats->p_start)); + microuptime(&p2->p_stats->p_start); if ((flags & RFSTOPPED) == 0) { mtx_lock_spin(&sched_lock); p2->p_state = PRS_NORMAL; Index: src/sys/kern/kern_kthread.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_kthread.c,v retrieving revision 1.29 diff -u -r1.29 kern_kthread.c --- src/sys/kern/kern_kthread.c 17 Apr 2003 22:28:28 -0000 1.29 +++ src/sys/kern/kern_kthread.c 24 Apr 2003 13:14:49 -0000 @@ -79,7 +79,7 @@ struct thread *td; struct proc *p2; - if (!proc0.p_stats /* || proc0.p_stats->p_start.tv_sec == 0 */) + if (!proc0.p_stats) panic("kthread_create called too soon"); error = fork1(&thread0, RFMEM | RFFDG | RFPROC | RFSTOPPED | flags, Index: src/sys/kern/kern_proc.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_proc.c,v retrieving revision 1.182 diff -u -r1.182 kern_proc.c --- src/sys/kern/kern_proc.c 24 Apr 2003 12:12:06 -0000 1.182 +++ src/sys/kern/kern_proc.c 24 Apr 2003 13:15:14 -0000 @@ -679,8 +679,7 @@ } if ((p->p_sflag & PS_INMEM) && p->p_stats) { kp->ki_start = p->p_stats->p_start; - if (kp->ki_start.tv_sec < 3600) - kp->ki_start.tv_sec += boottime.tv_sec; + timevaladd(&kp->ki_start, &boottime); kp->ki_rusage = p->p_stats->p_ru; kp->ki_childtime.tv_sec = p->p_stats->p_cru.ru_utime.tv_sec + p->p_stats->p_cru.ru_stime.tv_sec; Index: src/sys/nfsclient/nfs_lock.c =================================================================== RCS file: /home/ncvs/src/sys/nfsclient/nfs_lock.c,v retrieving revision 1.33 diff -u -r1.33 nfs_lock.c --- src/sys/nfsclient/nfs_lock.c 26 Mar 2003 19:21:34 -0000 1.33 +++ src/sys/nfsclient/nfs_lock.c 24 Apr 2003 13:16:08 -0000 @@ -116,6 +116,7 @@ MALLOC(p->p_nlminfo, struct nlminfo *, sizeof(struct nlminfo), M_LOCKF, M_WAITOK | M_ZERO); p->p_nlminfo->pid_start = p->p_stats->p_start; + timevaladd(&p->p_nlminfo->pid_start, &boottime); } msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; msg.lm_msg_ident.msg_seq = ++(p->p_nlminfo->msg_seq); --=-=-=--