svn commit: r308101 - head/sys/dev/hwpmc
Andriy Gapon
avg at FreeBSD.org
Sun Oct 30 09:38:11 UTC 2016
Author: avg
Date: Sun Oct 30 09:38:10 2016
New Revision: 308101
URL: https://svnweb.freebsd.org/changeset/base/308101
Log:
hwpmc: fix a race between amd_stop_pmc and amd_intr
It is possible that wrmsr in amd_stop_pmc() causes an overflow in a counter
that it disables. In that case a non-maskable interrupt is generated. The
interrupt handler code was written in such a way that it would re-enable the
counter. That would lead to an unexpected interrupt later on.
This problem was easy to reproduce with
$ pmcstat -T -P instructions -t $pid
if the target process is sufficiently busy and there are context switches from
time to time. There would be a lot of interrupts to "race" with amd_stop_pmc()
called during the context switches. The problem affected only AMD processors.
While there, trace whether amd_intr() claimed an interrupt.
Reviewed by: jhb
MFC after: 2 weeks
Modified:
head/sys/dev/hwpmc/hwpmc_amd.c
Modified: head/sys/dev/hwpmc/hwpmc_amd.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_amd.c Sun Oct 30 02:57:47 2016 (r308100)
+++ head/sys/dev/hwpmc/hwpmc_amd.c Sun Oct 30 09:38:10 2016 (r308101)
@@ -689,12 +689,13 @@ amd_intr(int cpu, struct trapframe *tf)
error = pmc_process_interrupt(cpu, PMC_HR, pm, tf,
TRAPF_USERMODE(tf));
if (error == 0)
- wrmsr(evsel, config | AMD_PMC_ENABLE);
+ wrmsr(evsel, config);
}
atomic_add_int(retval ? &pmc_stats.pm_intr_processed :
&pmc_stats.pm_intr_ignored, 1);
+ PMCDBG1(MDP,INT,2, "retval=%d", retval);
return (retval);
}
More information about the svn-src-head
mailing list