From owner-p4-projects@FreeBSD.ORG Mon Sep 13 20:17:25 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3898016A4CE; Mon, 13 Sep 2004 20:17:25 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EC8C116A4CE for ; Mon, 13 Sep 2004 20:17:24 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D323843D46 for ; Mon, 13 Sep 2004 20:17:24 +0000 (GMT) (envelope-from julian@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i8DKHOAC087276 for ; Mon, 13 Sep 2004 20:17:24 GMT (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i8DKHOVL087273 for perforce@freebsd.org; Mon, 13 Sep 2004 20:17:24 GMT (envelope-from julian@freebsd.org) Date: Mon, 13 Sep 2004 20:17:24 GMT Message-Id: <200409132017.i8DKHOVL087273@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to julian@freebsd.org using -f From: Julian Elischer To: Perforce Change Reviews Subject: PERFORCE change 61446 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2004 20:17:25 -0000 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