From owner-p4-projects@FreeBSD.ORG Mon Aug 14 19:54:58 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 C40CC16A4EB; Mon, 14 Aug 2006 19:54:58 +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 9DF0716A4DE for ; Mon, 14 Aug 2006 19:54:58 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BF2643D5A for ; Mon, 14 Aug 2006 19:54:58 +0000 (GMT) (envelope-from jhb@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 k7EJswIP023202 for ; Mon, 14 Aug 2006 19:54:58 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7EJswSa023199 for perforce@freebsd.org; Mon, 14 Aug 2006 19:54:58 GMT (envelope-from jhb@freebsd.org) Date: Mon, 14 Aug 2006 19:54:58 GMT Message-Id: <200608141954.k7EJswSa023199@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 103893 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: Mon, 14 Aug 2006 19:54:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=103893 Change 103893 by jhb@jhb_mutex on 2006/08/14 19:53:56 Add a mutex cycle. Affected files ... .. //depot/projects/smpng/sys/modules/crash2/crash2.c#12 edit Differences ... ==== //depot/projects/smpng/sys/modules/crash2/crash2.c#12 (text+ko) ==== @@ -88,6 +88,7 @@ static int event[NTHREADS]; static struct rwlock foo; static struct mtx bar; +static struct mtx abc, def, ghi, jkl; static struct sx one, two, three, four; static struct lock fee, fi, fo, fum; @@ -99,6 +100,19 @@ /* Events. */ +static struct mtx *mtxen[] = { &abc, &def, &ghi, &jkl }; + +static void +mtx_deadlock(int thread) +{ + + mtx_lock(mtxen[thread % 4]); + tsleep(mtxen, 0, "mtx_dead", hz/10); + mtx_lock(mtxen[(thread + 1) % 4]); +} +CRASH2_EVENT("mutex cycle", mtx_deadlock, mtx_deadlock, mtx_deadlock, + mtx_deadlock); + static struct lock *locks[] = { &fee, &fi, &fo, &fum }; static struct sx *sxs[] = { &one, &two, &three, &four }; @@ -124,7 +138,7 @@ { lockmgr(locks[thread % 4], LK_EXCLUSIVE, NULL, curthread); - tsleep(sxs, 0, "lk_dead", hz/10); + tsleep(locks, 0, "lk_dead", hz/10); lockmgr(locks[(thread + 1) % 4], LK_EXCLUSIVE, NULL, curthread); } CRASH2_EVENT("lockmgr cycle", lockmgr_deadlock, lockmgr_deadlock, @@ -367,6 +381,10 @@ rw_init(&foo, "foo"); mtx_init(&bar, "bar", NULL, MTX_DEF); + mtx_init(&abc, "abc", NULL, MTX_DEF); + mtx_init(&def, "def", NULL, MTX_DEF); + mtx_init(&ghi, "ghi", NULL, MTX_DEF); + mtx_init(&jkl, "jkl", NULL, MTX_DEF); sx_init(&one, "one"); sx_init(&two, "two"); sx_init(&three, "three"); @@ -414,6 +432,10 @@ sx_destroy(&three); sx_destroy(&two); sx_destroy(&one); + mtx_destroy(&jkl); + mtx_destroy(&ghi); + mtx_destroy(&def); + mtx_destroy(&abc); mtx_destroy(&bar); rw_destroy(&foo); return (0);