diff options
author | jeff <jeff@FreeBSD.org> | 2007-09-21 04:11:34 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2007-09-21 04:11:34 +0000 |
commit | 275d99eb1a004b5f3c2de64ef6ae613365f9cbc4 (patch) | |
tree | 4c25e6a88c2e934b057b2da3d1024e02e5b158f9 /lib/libkvm/kvm_proc.c | |
parent | bc0eadb21d99ae42fb629bab36adfe6ac36c8ec2 (diff) | |
download | FreeBSD-src-275d99eb1a004b5f3c2de64ef6ae613365f9cbc4.zip FreeBSD-src-275d99eb1a004b5f3c2de64ef6ae613365f9cbc4.tar.gz |
- When using kvm use the new conversion method to derive swtime.
Approved by: re
Diffstat (limited to 'lib/libkvm/kvm_proc.c')
-rw-r--r-- | lib/libkvm/kvm_proc.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index a2e7f33..f945bb3 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -85,6 +85,9 @@ __FBSDID("$FreeBSD$"); #define KREAD(kd, addr, obj) \ (kvm_read(kd, addr, (char *)(obj), sizeof(*obj)) != sizeof(*obj)) +static int ticks; +static int hz; + /* * Read proc's from memory file into buffer bp, which has space to hold * at most maxcnt procs. @@ -368,7 +371,7 @@ nopgrp: kp->ki_acflag = proc.p_acflag; kp->ki_lock = proc.p_lock; if (proc.p_state != PRS_ZOMBIE) { - kp->ki_swtime = proc.p_swtime; + kp->ki_swtime = (ticks - proc.p_swtick) / hz; kp->ki_flag = proc.p_flag; kp->ki_sflag = 0; kp->ki_nice = proc.p_nice; @@ -535,12 +538,14 @@ kvm_getprocs(kd, op, arg, cnt) liveout: nprocs = size == 0 ? 0 : size / kd->procbase->ki_structsize; } else { - struct nlist nl[4], *p; + struct nlist nl[6], *p; nl[0].n_name = "_nprocs"; nl[1].n_name = "_allproc"; nl[2].n_name = "_zombproc"; - nl[3].n_name = 0; + nl[3].n_name = "_ticks"; + nl[4].n_name = "_hz"; + nl[5].n_name = 0; if (kvm_nlist(kd, nl) != 0) { for (p = nl; p->n_type != 0; ++p) @@ -553,6 +558,14 @@ liveout: _kvm_err(kd, kd->program, "can't read nprocs"); return (0); } + if (KREAD(kd, nl[3].n_value, &ticks)) { + _kvm_err(kd, kd->program, "can't read ticks"); + return (0); + } + if (KREAD(kd, nl[4].n_value, &hz)) { + _kvm_err(kd, kd->program, "can't read hz"); + return (0); + } size = nprocs * sizeof(struct kinfo_proc); kd->procbase = (struct kinfo_proc *)_kvm_malloc(kd, size); if (kd->procbase == 0) |