From owner-p4-projects@FreeBSD.ORG Sat Dec 1 23:59:31 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 068FB16A508; Sat, 1 Dec 2007 23:59:30 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BD7616A419 for ; Sat, 1 Dec 2007 23:59:30 +0000 (UTC) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 442B413C442 for ; Sat, 1 Dec 2007 23:59:30 +0000 (UTC) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id lB1NxU94000251 for ; Sat, 1 Dec 2007 23:59:30 GMT (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lB1NxU3r000248 for perforce@freebsd.org; Sat, 1 Dec 2007 23:59:30 GMT (envelope-from peter@freebsd.org) Date: Sat, 1 Dec 2007 23:59:30 GMT Message-Id: <200712012359.lB1NxU3r000248@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 129919 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Dec 2007 23:59:31 -0000 http://perforce.freebsd.org/chv.cgi?CH=129919 Change 129919 by peter@peter_daintree on 2007/12/01 23:58:58 I'd like to change thread_stash() calls to thread_free(), but I'm not yet certain if the context allows that. Affected files ... .. //depot/projects/bike_sched/sys/kern/kern_thread.c#8 edit Differences ... ==== //depot/projects/bike_sched/sys/kern/kern_thread.c#8 (text+ko) ==== @@ -66,10 +66,19 @@ SYSCTL_INT(_kern_threads, OID_AUTO, max_threads_hits, CTLFLAG_RD, &max_threads_hits, 0, ""); +/* + * I'm unsure if this is safe to remove. thread_free might not be able + * to be called from the contexts that thread_stash is. + */ +#define ZOMBIES 1 +#ifdef ZOMBIES TAILQ_HEAD(, thread) zombie_threads = TAILQ_HEAD_INITIALIZER(zombie_threads); static struct mtx zombie_lock; MTX_SYSINIT(zombie_lock, &zombie_lock, "zombie lock", MTX_SPIN); +static void thread_zombie(struct thread *); +#endif + struct mtx tid_lock; static struct unrhdr *tid_unrhdr; @@ -220,7 +229,36 @@ 16 - 1, 0); } +#ifdef ZOMBIES /* + * Place an unused thread on the zombie list. + * Use the slpq as that must be unused by now. + */ +void +thread_zombie(struct thread *td) +{ + mtx_lock_spin(&zombie_lock); + TAILQ_INSERT_HEAD(&zombie_threads, td, td_slpq); + mtx_unlock_spin(&zombie_lock); +} +#endif + +/* + * Release a thread that has exited after cpu_throw(). + */ +void +thread_stash(struct thread *td) +{ + atomic_subtract_rel_int(&td->td_proc->p_exitthreads, 1); +#ifdef ZOMBIES + thread_zombie(td); +#else + thread_free(td); /* unsafe here? */ +#endif +} + +#ifdef ZOMBIES +/* * Reap zombie kse resource. */ void @@ -247,6 +285,7 @@ } } } +#endif /* * Allocate a thread. @@ -256,7 +295,9 @@ { struct thread *td; +#ifdef ZOMBIES thread_reap(); /* check if any zombies to get */ +#endif td = (struct thread *)uma_zalloc(thread_zone, M_WAITOK); KASSERT(td->td_kstack == 0, ("thread_alloc got thread with kstack")); @@ -423,7 +464,9 @@ sched_relinquish(curthread); cpu_thread_clean(td); crfree(td->td_ucred); +#ifdef ZOMBIES thread_reap(); /* check for zombie threads etc. */ +#endif } /*