From owner-p4-projects@FreeBSD.ORG Tue Sep 7 06:16:50 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 86DE816A4D0; Tue, 7 Sep 2004 06:16:50 +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 2F7B716A4CE for ; Tue, 7 Sep 2004 06:16:50 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04AF643D64 for ; Tue, 7 Sep 2004 06:16:50 +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 i876Gn90011963 for ; Tue, 7 Sep 2004 06:16:49 GMT (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i876Gnqp011960 for perforce@freebsd.org; Tue, 7 Sep 2004 06:16:49 GMT (envelope-from julian@freebsd.org) Date: Tue, 7 Sep 2004 06:16:49 GMT Message-Id: <200409070616.i876Gnqp011960@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 61116 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: Tue, 07 Sep 2004 06:16:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=61116 Change 61116 by julian@julian_ref on 2004/09/07 06:16:38 give libthr the choice of being scope_system or scope_process. Affected files ... .. //depot/projects/nsched/sys/kern/kern_thr.c#15 edit Differences ... ==== //depot/projects/nsched/sys/kern/kern_thr.c#15 (text+ko) ==== @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,11 @@ extern int max_threads_per_proc; extern int max_groups_per_proc; +static int thr_scope_sys = 0; +SYSCTL_DECL(_kern_threads); +SYSCTL_INT(_kern_threads, OID_AUTO, thr_scope_sys, CTLFLAG_RW, + &thr_scope_sys, 0, "sys or proc scope scheduling"); + /* * Back end support functions. */ @@ -79,14 +85,18 @@ } /* Initialize our td and new ksegrp.. */ newtd = thread_alloc(); - newkg = ksegrp_alloc(); + if (thr_scope_sys) + newkg = ksegrp_alloc(); + else + newkg = kg; /* * Try the copyout as soon as we allocate the td so we don't have to * tear things down in a failure case below. */ id = newtd->td_tid; if ((error = copyout(&id, uap->id, sizeof(long)))) { - ksegrp_free(newkg); + if (thr_scope_sys) + ksegrp_free(newkg); thread_free(newtd); return (error); } @@ -96,10 +106,12 @@ bcopy(&td->td_startcopy, &newtd->td_startcopy, (unsigned) RANGEOF(struct thread, td_startcopy, td_endcopy)); - bzero(&newkg->kg_startzero, - (unsigned) RANGEOF(struct ksegrp, kg_startzero, kg_endzero)); - bcopy(&kg->kg_startcopy, &newkg->kg_startcopy, - (unsigned) RANGEOF(struct ksegrp, kg_startcopy, kg_endcopy)); + if (thr_scope_sys) { + bzero(&newkg->kg_startzero, + (unsigned)RANGEOF(struct ksegrp, kg_startzero, kg_endzero)); + bcopy(&kg->kg_startcopy, &newkg->kg_startcopy, + (unsigned)RANGEOF(struct ksegrp, kg_startcopy, kg_endcopy)); + } newtd->td_proc = td->td_proc; newtd->td_ucred = crhold(td->td_ucred); @@ -108,7 +120,8 @@ cpu_set_upcall(newtd, td); error = set_mcontext(newtd, &ctx.uc_mcontext); if (error != 0) { - ksegrp_free(newkg); + if (thr_scope_sys) + ksegrp_free(newkg); thread_free(newtd); crfree(td->td_ucred); goto out; @@ -116,18 +129,27 @@ /* Link the thread and kse into the ksegrp and make it runnable. */ PROC_LOCK(td->td_proc); + if (thr_scope_sys) { + sched_init_concurrency(newkg); + } else { + if ((td->td_proc->p_flag & P_HADTHREADS) == 0) { + sched_set_concurrency(kg, mp_ncpus); + } + } + td->td_proc->p_flag |= P_HADTHREADS; newtd->td_sigmask = td->td_sigmask; mtx_lock_spin(&sched_lock); - ksegrp_link(newkg, p); + if (thr_scope_sys) + ksegrp_link(newkg, p); thread_link(newtd, newkg); mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); - sched_init_concurrency(newkg); /* let the scheduler know about these things. */ mtx_lock_spin(&sched_lock); - sched_fork_ksegrp(td, newkg); + if (thr_scope_sys) + sched_fork_ksegrp(td, newkg); sched_fork_thread(td, newtd); TD_SET_CAN_RUN(newtd);