On Wed, 12 Jan 2000, Bruce Evans wrote:

> 
> Please do the work, but send it to me for review.
> 
> I didn't have a fix for this particular problem until after seeing
> your first mail about it.  It didn't make sense for P_INMEM to be so
> apparently broken without it causing problems until recently.

Using the magic of :%s:p_stats->p_\([usi]\)\(u[^a-zA-Z_0-9]\):p_\1\2:g,
and just using vi to edit the headers too :), I submit the following to
you for review.  I'll be testing it in its entirety tomorrow, but I'm
already reasonably confident this is correct.  What do you think?

> 
> Bruce

-- 
 Brian Fundakowski Feldman           \  FreeBSD: The Power to Serve!  /
 [EMAIL PROTECTED]                    `------------------------------'

Index: kern_resource.c
===================================================================
RCS file: /usr2/ncvs/src/sys/kern/kern_resource.c,v
retrieving revision 1.53
diff -u -r1.53 kern_resource.c
--- kern_resource.c     1999/11/29 11:29:03     1.53
+++ kern_resource.c     2000/01/17 07:08:31
@@ -528,7 +528,7 @@
                        tu += (tv.tv_usec - switchtime.tv_usec) +
                            (tv.tv_sec - switchtime.tv_sec) * (int64_t)1000000;
        }
-       ptu = p->p_stats->p_uu + p->p_stats->p_su + p->p_stats->p_iu;
+       ptu = p->p_uu + p->p_su + p->p_iu;
        if (tu < ptu || (int64_t)tu < 0) {
                /* XXX no %qd in kernel.  Truncate. */
                printf("calcru: negative time of %ld usec for pid %d (%s)\n",
@@ -542,30 +542,30 @@
        iu = tu - uu - su;
 
        /* Enforce monotonicity. */
-       if (uu < p->p_stats->p_uu || su < p->p_stats->p_su ||
-           iu < p->p_stats->p_iu) {
-               if (uu < p->p_stats->p_uu)
-                       uu = p->p_stats->p_uu;
-               else if (uu + p->p_stats->p_su + p->p_stats->p_iu > tu)
-                       uu = tu - p->p_stats->p_su - p->p_stats->p_iu;
+       if (uu < p->p_uu || su < p->p_su ||
+           iu < p->p_iu) {
+               if (uu < p->p_uu)
+                       uu = p->p_uu;
+               else if (uu + p->p_su + p->p_iu > tu)
+                       uu = tu - p->p_su - p->p_iu;
                if (st == 0)
-                       su = p->p_stats->p_su;
+                       su = p->p_su;
                else {
                        su = ((tu - uu) * st) / (st + it);
-                       if (su < p->p_stats->p_su)
-                               su = p->p_stats->p_su;
-                       else if (uu + su + p->p_stats->p_iu > tu)
-                               su = tu - uu - p->p_stats->p_iu;
+                       if (su < p->p_su)
+                               su = p->p_su;
+                       else if (uu + su + p->p_iu > tu)
+                               su = tu - uu - p->p_iu;
                }
-               KASSERT(uu + su + p->p_stats->p_iu <= tu,
+               KASSERT(uu + su + p->p_iu <= tu,
                    ("calcru: monotonisation botch 1"));
                iu = tu - uu - su;
-               KASSERT(iu >= p->p_stats->p_iu,
+               KASSERT(iu >= p->p_iu,
                    ("calcru: monotonisation botch 2"));
        }
-       p->p_stats->p_uu = uu;
-       p->p_stats->p_su = su;
-       p->p_stats->p_iu = iu;
+       p->p_uu = uu;
+       p->p_su = su;
+       p->p_iu = iu;
 
        up->tv_sec = uu / 1000000;
        up->tv_usec = uu % 1000000;
Index: proc.h
===================================================================
RCS file: /usr2/ncvs/src/sys/sys/proc.h,v
retrieving revision 1.98
diff -u -r1.98 proc.h
--- proc.h      1999/12/29 04:24:45     1.98
+++ proc.h      2000/01/17 06:57:17
@@ -239,6 +239,9 @@
        struct proc *p_leader;
        struct  pasleep p_asleep;       /* Used by asleep()/await(). */
        void    *p_emuldata;    /* process-specific emulator state data */
+       u_int64_t p_uu;                 /* previous user time (us) */
+       u_int64_t p_su;                 /* previous system time (us) */
+       u_int64_t p_iu;                 /* previous interrupt time (us) */
 };
 
 #define        p_session       p_pgrp->pg_session
Index: resourcevar.h
===================================================================
RCS file: /usr2/ncvs/src/sys/sys/resourcevar.h,v
retrieving revision 1.15
diff -u -r1.15 resourcevar.h
--- resourcevar.h       1999/12/29 04:24:46     1.15
+++ resourcevar.h       2000/01/17 06:56:17
@@ -47,9 +47,6 @@
 #define        pstat_startzero p_ru
        struct  rusage p_ru;            /* stats for this proc */
        struct  rusage p_cru;           /* sum of stats for reaped children */
-       u_int64_t p_uu;                 /* previous user time (us) */
-       u_int64_t p_su;                 /* previous system time (us) */
-       u_int64_t p_iu;                 /* previous interrupt time (us) */
 #define        pstat_endzero   pstat_startcopy
 
 #define        pstat_startcopy p_timer



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to