Cache a pointer to the old proc (as well as negative cache) to make

computing the io statistics over and over not as expensive.
This is a bit of a cop out, as I should just allocate a struct with
the computed values, but this will do for now.
This commit is contained in:
Alfred Perlstein 2004-07-12 04:55:07 +00:00
parent 8a3f1adf3b
commit 98c151d6d9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132015

View File

@ -413,6 +413,8 @@ get_system_info(struct system_info *si)
}
}
#define NOPROC ((void *)-1)
const struct kinfo_proc *
get_old_proc(struct kinfo_proc *pp)
{
@ -420,13 +422,22 @@ get_old_proc(struct kinfo_proc *pp)
if (previous_proc_count == 0)
return (NULL);
if (pp->ki_udata == NOPROC)
return (NULL);
if (pp->ki_udata != NULL)
return (pp->ki_udata);
oldpp = bsearch(&pp, previous_pref, previous_proc_count,
sizeof(*previous_pref), compare_pid);
if (oldpp == NULL)
if (oldpp == NULL) {
pp->ki_udata = NOPROC;
return (NULL);
}
oldp = *oldpp;
if (bcmp(&oldp->ki_start, &pp->ki_start, sizeof(pp->ki_start)) != 0)
if (bcmp(&oldp->ki_start, &pp->ki_start, sizeof(pp->ki_start)) != 0) {
pp->ki_udata = NOPROC;
return (NULL);
}
pp->ki_udata = oldp;
return (oldp);
}