Date: Mon, 10 May 2004 16:05:18 -0700 (PDT) From: Julian Elischer <julian@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 52643 for review Message-ID: <200405102305.i4AN5IVL027806@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=52643 Change 52643 by julian@julian_ref on 2004/05/10 16:05:05 try not crash in boot. Affected files ... .. //depot/projects/nsched/sys/i386/i386/mp_machdep.c#2 edit .. //depot/projects/nsched/sys/kern/kern_exit.c#5 edit .. //depot/projects/nsched/sys/kern/kern_thread.c#12 edit .. //depot/projects/nsched/sys/kern/sched_4bsd.c#7 edit Differences ... ==== //depot/projects/nsched/sys/i386/i386/mp_machdep.c#2 (text+ko) ==== @@ -550,7 +550,7 @@ binuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); - cpu_throw(NULL, choosethread()); /* doesn't return */ + cpu_throw(NULL, choosethread(SW_VOL)); /* doesn't return */ panic("scheduler returned us to %s", __func__); /* NOTREACHED */ ==== //depot/projects/nsched/sys/kern/kern_exit.c#5 (text+ko) ==== @@ -489,15 +489,6 @@ */ cpu_exit(td); - /* - * Release this thread's reference to the ucred. The actual proc - * reference will stay around until the proc is harvested by - * wait(). XXX maybe this should be done there too. - */ - crfree(td->td_ucred); - td->td_ucred = NULL; - - PROC_LOCK(p); PROC_LOCK(p->p_pptr); sx_xunlock(&proctree_lock); @@ -530,7 +521,7 @@ * Allow the scheduler to adjust the priority of the * parent when a process is exiting. */ - if (p->p_pid != 1) + if (p->p_pptr != initproc) sched_exit(p->p_pptr, td); /* @@ -683,6 +674,8 @@ /* * do any thread-system specific cleanups + * like freeing the thread's ucred, + * and any spare threads, etc. */ thread_wait(p); @@ -697,8 +690,6 @@ #ifdef MAC mac_destroy_proc(p); #endif - KASSERT(FIRST_THREAD_IN_PROC(p), - ("kern_wait: no residual thread!")); uma_zfree(proc_zone, p); sx_xlock(&allproc_lock); nprocs--; ==== //depot/projects/nsched/sys/kern/kern_thread.c#12 (text+ko) ==== @@ -645,6 +645,10 @@ KASSERT((p->p_numthreads == 1), ("Multiple threads in wait1()")); KASSERT((p->p_numksegrps == 1), ("Multiple ksegrps in wait1()")); FOREACH_THREAD_IN_PROC(p, td) { + if (td->td_ucred) { + crfree(td->td_ucred); + td->td_ucred = NULL; + } if (td->td_standin != NULL) { thread_free(td->td_standin); td->td_standin = NULL; ==== //depot/projects/nsched/sys/kern/sched_4bsd.c#7 (text+ko) ==== @@ -1202,11 +1202,11 @@ TAILQ_REMOVE(&kg->kg_iq, ke, ke_kgrlist); kg->kg_idle_kses--; } - if (--kg->kg_kses == 0) - ksegrp_unlink(kg); /* * Aggregate stats from the KSE + * ## none yet ## */ + kse_stash(ke); } @@ -1300,12 +1300,14 @@ /* * Whenever we have idle KSEs and there are too many for the concurrancy, - * then free as many as we can. + * then free as many as we can. Don't free too many if we have threads + * to run/kill. */ -#define REDUCE_KSES(skg) \ +#define REDUCE_KSES(kg, skg) \ do { \ while ((skg->skg_concurrancy < skg->skg_kses) && \ - (skg->skg_idle_kses > 0)) { \ + (skg->skg_idle_kses > 0) && \ + (skg->skg_kses > kg->kg_numthreads)) { \ kse_unlink(TAILQ_FIRST(&skg->skg_iq)); \ } \ } while (0) @@ -1318,7 +1320,7 @@ skg = kg->kg_sched; skg->skg_concurrancy = concurrancy; - REDUCE_KSES(skg); + REDUCE_KSES(kg, skg); while (skg->skg_kses < skg->skg_concurrancy) { newke = kse_alloc(); bzero(&newke->ke_startzero, RANGEOF(struct kse, @@ -1554,7 +1556,7 @@ TAILQ_INSERT_TAIL(&kg->kg_iq, ke, ke_kgrlist); kg->kg_idle_kses++; CTR1(KTR_RUNQ, "kse_reassign: ke%p on idle queue", ke); - REDUCE_KSES(kg->kg_sched); /* if we are closing down discard it */ + REDUCE_KSES(kg, kg->kg_sched); /* if we are closing down discard it */ return; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405102305.i4AN5IVL027806>