svn commit: r185555 - head/sys/dev/hwpmc

Joseph Koshy jkoshy at FreeBSD.org
Tue Dec 2 02:46:36 PST 2008


Author: jkoshy
Date: Tue Dec  2 10:46:35 2008
New Revision: 185555
URL: http://svn.freebsd.org/changeset/base/185555

Log:
  - Efficiency tweak: when checking for PMC overflows, only go to
    hardware for PMCs that have been configured for sampling.
  
  - Bug fix: acknowledge PMC hardware overflows irrespective of the
    the (software) PMC's state.

Modified:
  head/sys/dev/hwpmc/hwpmc_amd.c
  head/sys/dev/hwpmc/hwpmc_ppro.c

Modified: head/sys/dev/hwpmc/hwpmc_amd.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_amd.c	Tue Dec  2 10:39:47 2008	(r185554)
+++ head/sys/dev/hwpmc/hwpmc_amd.c	Tue Dec  2 10:46:35 2008	(r185555)
@@ -632,7 +632,6 @@ amd_intr(int cpu, struct trapframe *tf)
 	uint32_t config, evsel, perfctr;
 	struct pmc *pm;
 	struct amd_cpu *pac;
-	struct pmc_hw *phw;
 	pmc_value_t v;
 
 	KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@@ -660,21 +659,19 @@ amd_intr(int cpu, struct trapframe *tf)
 
 	for (i = 0; retval == 0 && i < AMD_NPMCS; i++) {
 
-		if (!AMD_PMC_HAS_OVERFLOWED(i))
-			continue;
-
-		phw = &pac->pc_amdpmcs[i];
-
-		KASSERT(phw != NULL, ("[amd,%d] null PHW pointer", __LINE__));
-
-		if ((pm = phw->phw_pmc) == NULL ||
-		    pm->pm_state != PMC_STATE_RUNNING ||
+		if ((pm = pac->pc_amdpmcs[i].phw_pmc) == NULL ||
 		    !PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) {
 			continue;
 		}
 
+		if (!AMD_PMC_HAS_OVERFLOWED(i))
+			continue;
+
 		retval = 1;	/* Found an interrupting PMC. */
 
+		if (pm->pm_state != PMC_STATE_RUNNING)
+			continue;
+
 		/* Stop the PMC, reload count. */
 		evsel   = AMD_PMC_EVSEL_0 + i;
 		perfctr = AMD_PMC_PERFCTR_0 + i;

Modified: head/sys/dev/hwpmc/hwpmc_ppro.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_ppro.c	Tue Dec  2 10:39:47 2008	(r185554)
+++ head/sys/dev/hwpmc/hwpmc_ppro.c	Tue Dec  2 10:46:35 2008	(r185555)
@@ -688,17 +688,19 @@ p6_intr(int cpu, struct trapframe *tf)
 
 	for (ri = 0; ri < P6_NPMCS; ri++) {
 
-		if (!P6_PMC_HAS_OVERFLOWED(ri))
-			continue;
-
 		if ((pm = pc->pc_p6pmcs[ri].phw_pmc) == NULL ||
-		    pm->pm_state != PMC_STATE_RUNNING ||
 		    !PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) {
 			continue;
 		}
 
+		if (!P6_PMC_HAS_OVERFLOWED(ri))
+			continue;
+
 		retval = 1;
 
+		if (pm->pm_state != PMC_STATE_RUNNING)
+			continue;
+
 		error = pmc_process_interrupt(cpu, pm, tf,
 		    TRAPF_USERMODE(tf));
 		if (error)


More information about the svn-src-all mailing list