diff options
author | phk <phk@FreeBSD.org> | 2002-02-22 13:32:01 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-02-22 13:32:01 +0000 |
commit | fa959f1afd26bbeab46d956b15e7f7a25a23c30e (patch) | |
tree | e5ecf3d25102e8c345e8b21cabef4d87489b8437 | |
parent | 6beb5af66cdd422d033e8a94de23a35073864d0e (diff) | |
download | FreeBSD-src-fa959f1afd26bbeab46d956b15e7f7a25a23c30e.zip FreeBSD-src-fa959f1afd26bbeab46d956b15e7f7a25a23c30e.tar.gz |
Convert p->p_runtime and PCPU(switchtime) to bintime format.
-rw-r--r-- | sys/alpha/alpha/mp_machdep.c | 2 | ||||
-rw-r--r-- | sys/amd64/amd64/mp_machdep.c | 2 | ||||
-rw-r--r-- | sys/amd64/amd64/mptable.c | 2 | ||||
-rw-r--r-- | sys/amd64/include/mptable.h | 2 | ||||
-rw-r--r-- | sys/i386/i386/mp_machdep.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/mptable.c | 2 | ||||
-rw-r--r-- | sys/i386/include/mptable.h | 2 | ||||
-rw-r--r-- | sys/ia64/ia64/mp_machdep.c | 2 | ||||
-rw-r--r-- | sys/kern/init_main.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_proc.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_resource.c | 22 | ||||
-rw-r--r-- | sys/kern/kern_synch.c | 23 | ||||
-rw-r--r-- | sys/sparc64/sparc64/mp_machdep.c | 2 | ||||
-rw-r--r-- | sys/sys/pcpu.h | 2 | ||||
-rw-r--r-- | sys/sys/proc.h | 2 |
17 files changed, 34 insertions, 46 deletions
diff --git a/sys/alpha/alpha/mp_machdep.c b/sys/alpha/alpha/mp_machdep.c index 294d16a..a5fe20c 100644 --- a/sys/alpha/alpha/mp_machdep.c +++ b/sys/alpha/alpha/mp_machdep.c @@ -196,7 +196,7 @@ smp_init_secondary(void) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index a779ff0..27ee7ae 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -2293,7 +2293,7 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index a779ff0..27ee7ae 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -2293,7 +2293,7 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index a779ff0..27ee7ae 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -2293,7 +2293,7 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index a779ff0..27ee7ae 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -2293,7 +2293,7 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index a779ff0..27ee7ae 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -2293,7 +2293,7 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index a779ff0..27ee7ae 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -2293,7 +2293,7 @@ ap_init(void) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/ia64/ia64/mp_machdep.c b/sys/ia64/ia64/mp_machdep.c index 3bbf999..5da86eb 100644 --- a/sys/ia64/ia64/mp_machdep.c +++ b/sys/ia64/ia64/mp_machdep.c @@ -89,7 +89,7 @@ ia64_ap_startup(void) __asm __volatile("ssm psr.ic|psr.i;; srlz.i;;"); - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); mtx_lock_spin(&sched_lock); diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 2bbedb0..6b698e4 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -416,7 +416,8 @@ proc0_post(void *dummy __unused) sx_slock(&allproc_lock); LIST_FOREACH(p, &allproc, p_list) { microtime(&p->p_stats->p_start); - p->p_runtime = 0; + p->p_runtime.sec = 0; + p->p_runtime.frac = 0; } sx_sunlock(&allproc_lock); microuptime(PCPU_PTR(switchtime)); diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index e8c5558..c8503ca 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -330,7 +330,7 @@ exit1(td, rv) * counted somewhere if possible. */ mtx_lock_spin(&sched_lock); - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); mtx_unlock_spin(&sched_lock); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index d791302..3cd3017 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -776,8 +776,8 @@ fork_exit(callout, arg, frame) td->td_savecrit = CRITICAL_FORK; CTR3(KTR_PROC, "fork_exit: new proc %p (pid %d, %s)", p, p->p_pid, p->p_comm); - if (PCPU_GET(switchtime.tv_sec) == 0) - microuptime(PCPU_PTR(switchtime)); + if (PCPU_GET(switchtime.sec) == 0) + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); mtx_unlock_spin(&sched_lock); diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 255b102..b11c23b 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -534,6 +534,7 @@ fill_kinfo_proc(p, kp) struct thread *td; struct tty *tp; struct session *sp; + struct timeval tv; bzero(kp, sizeof(*kp)); @@ -598,7 +599,8 @@ fill_kinfo_proc(p, kp) kp->ki_traceflag = p->p_traceflag; kp->ki_pid = p->p_pid; /* vvv XXXKSE */ - kp->ki_runtime = p->p_runtime; + bintime2timeval(&p->p_runtime, &tv); + kp->ki_runtime = tv.tv_sec * (u_int64_t)1000000 + tv.tv_usec; kp->ki_pctcpu = p->p_kse.ke_pctcpu; kp->ki_estcpu = td->td_ksegrp->kg_estcpu; kp->ki_slptime = td->td_ksegrp->kg_slptime; diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index fb6914f..ffcd488 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -622,6 +622,7 @@ calcru(p, up, sp, ip) u_int64_t uut = 0, sut = 0, iut = 0; int s; struct timeval tv; + struct bintime bt; struct kse *ke; struct ksegrp *kg; @@ -643,7 +644,6 @@ calcru(p, up, sp, ip) tt = 1; } - tu = p->p_runtime; if (ke == curthread->td_kse) { /* * Adjust for the current time slice. This is actually fairly @@ -652,19 +652,15 @@ calcru(p, up, sp, ip) * XXXKSE use a different test due to threads on other * processors also being 'current'. */ - microuptime(&tv); - if (timevalcmp(&tv, PCPU_PTR(switchtime), <)) - printf("microuptime() went backwards (%ld.%06ld -> %ld.%06ld)\n", - (long)PCPU_GET(switchtime.tv_sec), - PCPU_GET(switchtime.tv_usec), - (long)tv.tv_sec, tv.tv_usec); - else - tu += (tv.tv_usec - - PCPU_GET(switchtime.tv_usec)) - + (tv.tv_sec - - PCPU_GET(switchtime.tv_sec)) - * (int64_t)1000000; + + binuptime(&bt); + bintime_sub(&bt, PCPU_PTR(switchtime)); + bintime_add(&bt, &p->p_runtime); + } else { + bt = p->p_runtime; } + bintime2timeval(&bt, &tv); + tu = tv.tv_sec * (u_int64_t)1000000 + tv.tv_usec; ptu = ke->ke_uu + ke->ke_su + ke->ke_iu; if (tu < ptu || (int64_t)tu < 0) { /* XXX no %qd in kernel. Truncate. */ diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 10b6fe4..c849689 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -693,7 +693,7 @@ wakeup_one(ident) void mi_switch() { - struct timeval new_switchtime; + struct bintime new_switchtime; struct thread *td = curthread; /* XXX */ register struct proc *p = td->td_proc; /* XXX */ #if 0 @@ -711,20 +711,9 @@ mi_switch() * Compute the amount of time during which the current * process was running, and add that to its total so far. */ - microuptime(&new_switchtime); - if (timevalcmp(&new_switchtime, PCPU_PTR(switchtime), <)) { -#if 0 - /* XXX: This doesn't play well with sched_lock right now. */ - printf("microuptime() went backwards (%ld.%06ld -> %ld.%06ld)\n", - PCPU_GET(switchtime.tv_sec), PCPU_GET(switchtime.tv_usec), - new_switchtime.tv_sec, new_switchtime.tv_usec); -#endif - new_switchtime = PCPU_GET(switchtime); - } else { - p->p_runtime += (new_switchtime.tv_usec - PCPU_GET(switchtime.tv_usec)) + - (new_switchtime.tv_sec - PCPU_GET(switchtime.tv_sec)) * - (int64_t)1000000; - } + binuptime(&new_switchtime); + bintime_add(&p->p_runtime, &new_switchtime); + bintime_sub(&p->p_runtime, PCPU_PTR(switchtime)); #ifdef DDB /* @@ -783,8 +772,8 @@ mi_switch() sched_lock.mtx_lock = (uintptr_t)td; CTR3(KTR_PROC, "mi_switch: new proc %p (pid %d, %s)", p, p->p_pid, p->p_comm); - if (PCPU_GET(switchtime.tv_sec) == 0) - microuptime(PCPU_PTR(switchtime)); + if (PCPU_GET(switchtime.sec) == 0) + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); } diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index d5a73d3..b4a5e71 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -244,7 +244,7 @@ cpu_mp_bootstrap(struct pcpu *pc) while (smp_started == 0) ; /* nothing */ - microuptime(PCPU_PTR(switchtime)); + binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); /* ok, now grab sched_lock and enter the scheduler */ diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index 8cdaf76..ed72487 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -52,7 +52,7 @@ struct pcpu { struct thread *pc_idlethread; /* Idle thread */ struct thread *pc_fpcurthread; /* Fp state owner */ struct pcb *pc_curpcb; /* Current pcb */ - struct timeval pc_switchtime; + struct bintime pc_switchtime; int pc_switchticks; u_int pc_cpuid; /* This cpu number */ u_int pc_cpumask; /* This cpu mask */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 4a05c24..6a7d20d 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -394,7 +394,7 @@ struct proc { struct vmspace *p_vmspace; /* (b) Address space. */ u_int p_swtime; /* (j) Time swapped in or out. */ struct itimerval p_realtimer; /* (h?/k?) Alarm timer. */ - u_int64_t p_runtime; /* (j) Real time in microsec. */ + struct bintime p_runtime; /* (j) Real time. */ int p_traceflag; /* (j?) Kernel trace points. */ struct vnode *p_tracep; /* (j?) Trace to vnode. */ sigset_t p_siglist; /* (c) Sigs arrived, not delivered. */ |