From owner-svn-src-all@FreeBSD.ORG Tue Apr 3 07:48:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2A366106564A; Tue, 3 Apr 2012 07:48:59 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 140EB8FC17; Tue, 3 Apr 2012 07:48:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q337mwEp037983; Tue, 3 Apr 2012 07:48:58 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q337mwEY037981; Tue, 3 Apr 2012 07:48:58 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201204030748.q337mwEY037981@svn.freebsd.org> From: Fabien Thomas Date: Tue, 3 Apr 2012 07:48:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233825 - stable/8/sys/dev/hwpmc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2012 07:48:59 -0000 Author: fabient Date: Tue Apr 3 07:48:58 2012 New Revision: 233825 URL: http://svn.freebsd.org/changeset/base/233825 Log: MFC r233544: Fix random deadlock on pmcstat exit: - Exit the thread when soft shutdown is requested - Wakeup owner thread. Reproduced/tested by looping pmcstat measurement: pmcstat -S instructions -O/tmp/test ls Modified: stable/8/sys/dev/hwpmc/hwpmc_logging.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/dev/hwpmc/hwpmc_logging.c ============================================================================== --- stable/8/sys/dev/hwpmc/hwpmc_logging.c Tue Apr 3 07:15:42 2012 (r233824) +++ stable/8/sys/dev/hwpmc/hwpmc_logging.c Tue Apr 3 07:48:58 2012 (r233825) @@ -284,6 +284,7 @@ pmclog_loop(void *arg) if ((lb = TAILQ_FIRST(&po->po_logbuffers)) == NULL) { mtx_unlock_spin(&po->po_mtx); + /* No more buffers and shutdown required. */ if (po->po_flags & PMC_PO_SHUTDOWN) { mtx_unlock(&pmc_kthread_mtx); /* @@ -292,6 +293,7 @@ pmclog_loop(void *arg) */ fo_close(po->po_file, curthread); mtx_lock(&pmc_kthread_mtx); + break; } (void) msleep(po, &pmc_kthread_mtx, PWAIT, @@ -354,6 +356,7 @@ pmclog_loop(void *arg) lb = NULL; } + wakeup_one(po->po_kthread); po->po_kthread = NULL; mtx_unlock(&pmc_kthread_mtx); @@ -652,8 +655,7 @@ pmclog_deconfigure_log(struct pmc_owner ("[pmclog,%d] po=%p no log file", __LINE__, po)); /* stop the kthread, this will reset the 'OWNS_LOGFILE' flag */ - if (po->po_kthread) - pmclog_stop_kthread(po); + pmclog_stop_kthread(po); KASSERT(po->po_kthread == NULL, ("[pmclog,%d] po=%p kthread not stopped", __LINE__, po));