Date: Mon, 13 Sep 2004 20:17:24 GMT From: Julian Elischer <julian@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 61446 for review Message-ID: <200409132017.i8DKHOVL087273@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=61446 Change 61446 by julian@julian_ref on 2004/09/13 20:17:09 remove hack solution and add a slightly nicer one for preemption problem. Affected files ... .. //depot/projects/nsched/sys/kern/kern_switch.c#23 edit .. //depot/projects/nsched/sys/kern/sched_4bsd.c#50 edit .. //depot/projects/nsched/sys/kern/sched_ule.c#32 edit .. //depot/projects/nsched/sys/sys/proc.h#31 edit Differences ... ==== //depot/projects/nsched/sys/kern/kern_switch.c#23 (text+ko) ==== @@ -226,7 +226,7 @@ * sched_thread_exit() (local) * sched_switch() (local) * sched_thread_exit() (local) - * remrunqueue() (local) + * remrunqueue() (local) (not at the moment) */ static void slot_fill(struct ksegrp *kg) @@ -258,7 +258,6 @@ } } -#ifdef SCHED_4BSD /* * Remove a thread from its KSEGRP's run queue. * This in turn may remove it from a KSE if it was already assigned @@ -310,7 +309,6 @@ } CHECKRUNQ(kg, NULL) } -#endif /* * Change the priority of a thread that is on the run queue. @@ -396,10 +394,6 @@ return; } - if (((flags & (SRQ_YIELDING|SRQ_OURSELF|SRQ_NOPREEMPT)) == 0) && - maybe_preempt(td)) - return; - CHECKRUNQ(kg, td) tda = kg->kg_last_assigned; if ((kg->kg_avail_opennings <= 0) && @@ -457,7 +451,7 @@ kg->kg_last_assigned = td2; } kg->kg_avail_opennings--; - sched_add(td2, flags|SRQ_NOPREEMPT); + sched_add(td2, flags); } else { CTR3(KTR_RUNQ, "setrunqueue: held: td%p kg%p pid%d", td, td->td_ksegrp, td->td_proc->p_pid); @@ -568,8 +562,18 @@ /* * Our thread state says that we are already on a run queue, so * update our state as if we had been dequeued by choosethread(). + * However we must not actually be on the system run queue yet. */ MPASS(TD_ON_RUNQ(td)); + MPASS(td->td_sched->ke_state != KES_ONRUNQ); + if (td->td_proc->p_flag & P_HADTHREADS) { + /* + * If this is a threaded process we actually ARE on the + * ksegrp run queue so take it off that first. + */ + remrunqueue(td); /* maybe use a simpler version */ + } + TD_SET_RUNNING(td); CTR3(KTR_PROC, "preempting to thread %p (pid %d, %s)\n", td, td->td_proc->p_pid, td->td_proc->p_comm); ==== //depot/projects/nsched/sys/kern/sched_4bsd.c#50 (text+ko) ==== @@ -1018,8 +1018,7 @@ #endif { - if (((flags & SRQ_NOPREEMPT) == 0) && - maybe_preempt(td)) + if (maybe_preempt(td)) return; } } ==== //depot/projects/nsched/sys/kern/sched_ule.c#32 (text+ko) ==== @@ -1662,13 +1662,13 @@ /* let jeff work out how to map the flags better */ /* I'm open to suggestions */ - if (flags & (SRQ_YIELDING|SRQ_NOPREEMPT)) { + if (flags & SRQ_YIELDING) /* * Preempting during switching can be bad JUJU * especially for KSE processes */ sched_add_internal(td, 0); - } else + else sched_add_internal(td, 1); } ==== //depot/projects/nsched/sys/sys/proc.h#31 (text+ko) ==== @@ -658,7 +658,6 @@ #define SRQ_YIELDING 0x0001 /* we are yielding (from mi_switch) */ #define SRQ_OURSELF 0x0002 /* it is ourself (from mi_switch) */ #define SRQ_INTR 0x0004 /* it is probably urgent */ -#define SRQ_NOPREEMPT 0x0008 /* Just don't ok? */ /* How values for thread_single(). */ #define SINGLE_NO_EXIT 0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200409132017.i8DKHOVL087273>