From 593077d613b6bed8c4607015c7a2d86f87868155 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Thu, 10 Nov 2016 11:12:45 +0000 Subject: pmc_process_csw_out: ignore deleted counters I see the fllowing panic on AMD when exiting pmcstat: panic: [pmc,1473] pp_pmcval outside of expected range cpu=2 ri=17 pp_pmcval=fffffffffa529f5b pm_reloadcount=10000 It seems that at least on AMD a performance counter keeps counting after overflowing. When pmcstat exits it sets counters that it used to PMC_STATE_DELETED and waits until their use count goes to zero. amd_intr() wouldn't reload a counter in that state and, thus, a counter would be allowed to overflow. That means that the counter's value would be allowed to go outside the expected range. MFC after: 2 weeks --- sys/dev/hwpmc/hwpmc_mod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 55dc499b1c40..36bcccb8c27a 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -1431,8 +1431,8 @@ pmc_process_csw_out(struct thread *td) * save the reading. */ - if (pp != NULL && pp->pp_pmcs[ri].pp_pmc != NULL) { - + if (pm->pm_state != PMC_STATE_DELETED && pp != NULL && + pp->pp_pmcs[ri].pp_pmc != NULL) { KASSERT(pm == pp->pp_pmcs[ri].pp_pmc, ("[pmc,%d] pm %p != pp_pmcs[%d] %p", __LINE__, pm, ri, pp->pp_pmcs[ri].pp_pmc)); -- cgit v1.3