From owner-p4-projects@FreeBSD.ORG Fri Jun 23 22:53:19 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 B17C316A492; Fri, 23 Jun 2006 22:53:19 +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 8D34616A47C for ; Fri, 23 Jun 2006 22:53:19 +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 4369043D45 for ; Fri, 23 Jun 2006 22:53:19 +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 k5NMrJSS065840 for ; Fri, 23 Jun 2006 22:53:19 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5NMrJOa065837 for perforce@freebsd.org; Fri, 23 Jun 2006 22:53:19 GMT (envelope-from kmacy@freebsd.org) Date: Fri, 23 Jun 2006 22:53:19 GMT Message-Id: <200606232253.k5NMrJOa065837@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 99905 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: Fri, 23 Jun 2006 22:53:20 -0000 http://perforce.freebsd.org/chv.cgi?CH=99905 Change 99905 by kmacy@kmacy_storage:sun4v_work_sleepq on 2006/06/23 22:52:43 add profiling to sx locks Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/kern/kern_sx.c#3 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/kern/kern_sx.c#3 (text+ko) ==== @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -85,6 +86,8 @@ cv_init(&sx->sx_excl_cv, description); sx->sx_excl_wcnt = 0; sx->sx_xholder = NULL; + + lock_profile_init(&sx->sx_object, description); lock_init(&sx->sx_object, &lock_class_sx, description, NULL, LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE | LO_UPGRADABLE); } @@ -101,6 +104,7 @@ cv_destroy(&sx->sx_shrd_cv); cv_destroy(&sx->sx_excl_cv); + lock_profile_destroy(&sx->sx_object); lock_destroy(&sx->sx_object); } @@ -108,6 +112,8 @@ _sx_slock(struct sx *sx, const char *file, int line) { + int contested; + mtx_lock(sx->sx_lock); KASSERT(sx->sx_xholder != curthread, ("%s (%s): slock while xlock is held @ %s:%d\n", __func__, @@ -119,13 +125,18 @@ */ while (sx->sx_cnt < 0) { sx->sx_shrd_wcnt++; + lock_profile_obtain_lock_failed(&sx->sx_object, &contested); cv_wait(&sx->sx_shrd_cv, sx->sx_lock); sx->sx_shrd_wcnt--; } + /* Acquire a shared lock. */ sx->sx_cnt++; + if (sx->sx_cnt == 1) + lock_profile_obtain_lock_success(&sx->sx_object, file, line); + LOCK_LOG_LOCK("SLOCK", &sx->sx_object, 0, 0, file, line); WITNESS_LOCK(&sx->sx_object, 0, file, line); @@ -153,7 +164,9 @@ void _sx_xlock(struct sx *sx, const char *file, int line) { - + + int contested; + mtx_lock(sx->sx_lock); /* @@ -172,6 +185,7 @@ /* Loop in case we lose the race for lock acquisition. */ while (sx->sx_cnt != 0) { sx->sx_excl_wcnt++; + lock_profile_obtain_lock_failed(&sx->sx_object, &contested); cv_wait(&sx->sx_excl_cv, sx->sx_lock); sx->sx_excl_wcnt--; } @@ -182,6 +196,7 @@ sx->sx_cnt--; sx->sx_xholder = curthread; + lock_profile_obtain_lock_success(&sx->sx_object, file, line); LOCK_LOG_LOCK("XLOCK", &sx->sx_object, 0, 0, file, line); WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line); @@ -226,6 +241,9 @@ * lockers won't be blocked forever, don't wake shared lock waiters if * there are exclusive lock waiters. */ + if (sx->sx_cnt == 0) + lock_profile_release_lock(&sx->sx_object); + if (sx->sx_excl_wcnt > 0) { if (sx->sx_cnt == 0) cv_signal(&sx->sx_excl_cv); @@ -251,6 +269,7 @@ sx->sx_cnt++; sx->sx_xholder = NULL; + lock_profile_release_lock(&sx->sx_object); /* * Wake up waiters if there are any. Give precedence to slock waiters. */