Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jun 2017 18:53:56 +0000 (UTC)
From:      Zbigniew Bodek <zbb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319913 - head/sys/dev/hwpmc
Message-ID:  <201706131853.v5DIruKH034954@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <mkm@semihalf.com>
  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__));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706131853.v5DIruKH034954>