From owner-svn-src-all@freebsd.org Tue Jun 13 18:53:57 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82AF7BFC2EB; Tue, 13 Jun 2017 18:53:57 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50B8E3702; Tue, 13 Jun 2017 18:53:57 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5DIruWW034955; Tue, 13 Jun 2017 18:53:56 GMT (envelope-from zbb@FreeBSD.org) Received: (from zbb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5DIruKH034954; Tue, 13 Jun 2017 18:53:56 GMT (envelope-from zbb@FreeBSD.org) Message-Id: <201706131853.v5DIruKH034954@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zbb set sender to zbb@FreeBSD.org using -f From: Zbigniew Bodek Date: Tue, 13 Jun 2017 18:53:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319913 - head/sys/dev/hwpmc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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, 13 Jun 2017 18:53:57 -0000 Author: zbb Date: Tue Jun 13 18:53:56 2017 New Revision: 319913 URL: https://svnweb.freebsd.org/changeset/base/319913 Log: Fix INVARIANTS debug code in HWPMC When HWPMC stops sampling, ps_pmc may be freed before samples are processed. In such situation treat PMC as stopped. Add "ifdef" to fix build without INVARIANTS code. Submitted by: Michal Mazur Obtained from: Semihalf Sponsored by: Stormshield, Netgate Differential revision: https://reviews.freebsd.org/D10912 Modified: head/sys/dev/hwpmc/hwpmc_mod.c Modified: head/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_mod.c Tue Jun 13 18:52:39 2017 (r319912) +++ head/sys/dev/hwpmc/hwpmc_mod.c Tue Jun 13 18:53:56 2017 (r319913) @@ -4224,7 +4224,8 @@ pmc_capture_user_callchain(int cpu, int ring, struct t ps_end = psb->ps_write; do { #ifdef INVARIANTS - if (ps->ps_pmc->pm_state != PMC_STATE_RUNNING) + if ((ps->ps_pmc == NULL) || + (ps->ps_pmc->pm_state != PMC_STATE_RUNNING)) nfree++; #endif if (ps->ps_nsamples != PMC_SAMPLE_INUSE) @@ -4262,9 +4263,11 @@ next: ps = psb->ps_samples; } while (ps != ps_end); +#ifdef INVARIANTS KASSERT(ncallchains > 0 || nfree > 0, ("[pmc,%d] cpu %d didn't find a sample to collect", __LINE__, cpu)); +#endif KASSERT(td->td_pinned == 1, ("[pmc,%d] invalid td_pinned value", __LINE__));