From owner-p4-projects@FreeBSD.ORG Mon Apr 10 19:17:42 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 7C6DD16A406; Mon, 10 Apr 2006 19:17:42 +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 3F6E516A408 for ; Mon, 10 Apr 2006 19:17:42 +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 0AC0543D48 for ; Mon, 10 Apr 2006 19:17:42 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3AJHfvT047928 for ; Mon, 10 Apr 2006 19:17:41 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3AJHfrB047925 for perforce@freebsd.org; Mon, 10 Apr 2006 19:17:41 GMT (envelope-from jhb@freebsd.org) Date: Mon, 10 Apr 2006 19:17:41 GMT Message-Id: <200604101917.k3AJHfrB047925@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 94944 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, 10 Apr 2006 19:17:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=94944 Change 94944 by jhb@jhb_slimer on 2006/04/10 19:16:57 Various upgrade/downgrade tests for rwlocks. Affected files ... .. //depot/projects/smpng/sys/modules/crash/crash.c#31 edit Differences ... ==== //depot/projects/smpng/sys/modules/crash/crash.c#31 (text+ko) ==== @@ -86,6 +86,73 @@ /* Events. */ +static void +upgrade_baz(void) +{ + rw_init(&baz, "baz"); + rw_rlock(&baz); + if (rw_try_upgrade(&baz) == 0) { + printf("crash: umm, upgrade failed?\n"); + rw_runlock(&baz); + } else + rw_wunlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("rlock baz, upgrade, and release", upgrade_baz); + +static void +downgrade_baz(void) +{ + rw_init(&baz, "baz"); + rw_wlock(&baz); + rw_downgrade(&baz); + rw_runlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("wlock baz, downgrade, and release", downgrade_baz); + +static void +upgrade_excl_baz(void) +{ + rw_init(&baz, "baz"); + rw_wlock(&baz); + rw_try_upgrade(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("wlock baz, upgrade", upgrade_excl_baz); + +static void +downgrade_shared_baz(void) +{ + rw_init(&baz, "baz"); + rw_rlock(&baz); + rw_downgrade(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("rlock baz, downgrade", downgrade_shared_baz); + +static void +runlock_upgraded_baz(void) +{ + rw_init(&baz, "baz"); + rw_rlock(&baz); + rw_try_upgrade(&baz); + rw_runlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("rlock baz, upgrade, runlock", runlock_upgraded_baz); + +static void +wunlock_downgraded_baz(void) +{ + rw_init(&baz, "baz"); + rw_wlock(&baz); + rw_downgrade(&baz); + rw_wunlock(&baz); + rw_destroy(&baz); +} +CRASH_EVENT("wlock baz, downgrade, wunlock", wunlock_downgraded_baz); + #ifdef WITNESS static void @@ -356,8 +423,8 @@ if (sx_try_upgrade(&foo) == 0) { printf("crash: umm, upgrade failed?\n"); sx_sunlock(&foo); - } - sx_xunlock(&foo); + } else + sx_xunlock(&foo); } CRASH_EVENT("slock foo, upgrade, and release", upgrade_foo);