From owner-p4-projects@FreeBSD.ORG Sun Jun 25 05:47:16 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C84B016A4B3; Sun, 25 Jun 2006 05:47:16 +0000 (UTC) X-Original-To: perforce@freebsd.org 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 8B38B16A4A0 for ; Sun, 25 Jun 2006 05:47:16 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3C3E443D53 for ; Sun, 25 Jun 2006 05:47:16 +0000 (GMT) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5P5lGHs074897 for ; Sun, 25 Jun 2006 05:47:16 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5P5lF4Q074894 for perforce@freebsd.org; Sun, 25 Jun 2006 05:47:15 GMT (envelope-from kmacy@freebsd.org) Date: Sun, 25 Jun 2006 05:47:15 GMT Message-Id: <200606250547.k5P5lF4Q074894@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 99969 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: Sun, 25 Jun 2006 05:47:17 -0000 http://perforce.freebsd.org/chv.cgi?CH=99969 Change 99969 by kmacy@kmacy_storage:sun4v_work_sleepq on 2006/06/25 05:46:34 grab thread lock before sleepq_remove to save some awkwardnesss Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/kern/kern_synch.c#9 edit .. //depot/projects/kmacy_sun4v/src/sys/kern/sys_generic.c#5 edit .. //depot/projects/kmacy_sun4v/src/sys/kern/vfs_subr.c#7 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/kern/kern_synch.c#9 (text+ko) ==== @@ -116,11 +116,7 @@ * flag the mutex is not re-locked before returning. */ int -msleep(ident, mtx, priority, wmesg, timo) - void *ident; - struct mtx *mtx; - int priority, timo; - const char *wmesg; +msleep(void *ident, struct mtx *mtx, int priority, const char *wmesg, int timo) { struct thread *td; struct proc *p; @@ -133,6 +129,7 @@ if (KTRPOINT(td, KTR_CSW)) ktrcsw(1, 0); #endif + TD_SLOCK_ASSERT(td, MA_NOTOWNED); WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, mtx == NULL ? NULL : &mtx->mtx_object, "Sleeping on \"%s\"", wmesg); KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL, @@ -161,9 +158,11 @@ * sleep queue first. We have to do this to handle recursive * sleeps. */ - if (TD_ON_SLEEPQ(td)) + if (TD_ON_SLEEPQ(td)) { + TD_SLOCK(td); sleepq_remove(td, td->td_wchan); - + TD_SUNLOCK(td); + } flags = SLEEPQ_MSLEEP; if (catch) flags |= SLEEPQ_INTERRUPTIBLE; @@ -224,11 +223,7 @@ } int -msleep_spin(ident, mtx, wmesg, timo) - void *ident; - struct mtx *mtx; - const char *wmesg; - int timo; +msleep_spin(void *ident, struct mtx *mtx, const char *wmesg, int timo) { struct thread *td; struct proc *p; ==== //depot/projects/kmacy_sun4v/src/sys/kern/sys_generic.c#5 (text+ko) ==== @@ -1136,9 +1136,13 @@ } TAILQ_REMOVE(&td->td_selq, sip, si_thrlist); sip->si_thread = NULL; + mtx_unlock(&sellock); + atomic_clear_int(&td->td_flags, TDF_SELECT); + TD_SLOCK(td); sleepq_remove(td, &selwait); - mtx_unlock(&sellock); + TD_SUNLOCK(td); + } static void selectinit(void *); ==== //depot/projects/kmacy_sun4v/src/sys/kern/vfs_subr.c#7 (text+ko) ==== @@ -1731,7 +1731,9 @@ int ret = 0; td = FIRST_THREAD_IN_PROC(updateproc); + TD_SLOCK(td); sleepq_remove(td, &lbolt); + TD_SUNLOCK(td); mtx_lock(&sync_mtx); if (rushjob < syncdelay / 2) { rushjob += 1; @@ -1754,7 +1756,9 @@ if (howto & RB_NOSYNC) return; td = FIRST_THREAD_IN_PROC(updateproc); + TD_SLOCK(td); sleepq_remove(td, &lbolt); + TD_SUNLOCK(td); mtx_lock(&sync_mtx); syncer_state = SYNCER_SHUTTING_DOWN; rushjob = 0;