PERFORCE change 127226 for review
Marko Zec
zec at FreeBSD.org
Fri Oct 5 05:59:11 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=127226
Change 127226 by zec at zec_tpx32 on 2007/10/05 12:58:54
When a process is exiting there is a short window while the
proc is still schedulable but it doesn't have an ucred
associated with it any more. Hence, inside the scheduler
if p->p_ucred is not available, we supply a dummy loadavg
value for purposes of priority recalculation, given that the
process should be gone anyhow in a few microseconds, so
inaccurate priority calculation shouldn't be a problem in
this case.
In short, with this change maintaining per-vprocg load
average accounting should finally work OK, at least with
SCHED_4BSD.
Affected files ...
.. //depot/projects/vimage/src/sys/kern/sched_4bsd.c#12 edit
Differences ...
==== //depot/projects/vimage/src/sys/kern/sched_4bsd.c#12 (text+ko) ====
@@ -389,24 +389,25 @@
static void
schedcpu(void)
{
-#ifndef VIMAGE
- register fixpt_t loadfac = loadfactor(averunnable.ldavg[0]);
-#endif
+ register fixpt_t loadfac;
struct thread *td;
struct proc *p;
struct td_sched *ts;
int awake, realstathz;
+#ifndef VIMAGE
+ loadfac = loadfactor(averunnable.ldavg[0]);
+#endif
realstathz = stathz ? stathz : hz;
sx_slock(&allproc_lock);
FOREACH_PROC_IN_SYSTEM(p) {
PROC_SLOCK(p);
#ifdef VIMAGE
- KASSERT((p->p_ucred != NULL), ("p_ucred"));
- KASSERT((p->p_ucred->cr_vimage != NULL), ("cr_vimage"));
- KASSERT((p->p_ucred->cr_vimage->v_procg != NULL), ("v_procg"));
- INIT_VPROCG(p->p_ucred->cr_vimage->v_procg);
- fixpt_t loadfac = loadfactor(V_averunnable.ldavg[0]);
+ if (p->p_ucred != NULL) {
+ INIT_VPROCG(p->p_ucred->cr_vimage->v_procg);
+ loadfac = loadfactor(V_averunnable.ldavg[0]);
+ } else
+ loadfac = 0;
#endif
FOREACH_THREAD_IN_PROC(p, td) {
awake = 0;
More information about the p4-projects
mailing list