perf: Fix fixed counter busy detection
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 19 May 2016 22:36:24 +0000 (18:36 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jun 2016 15:48:36 +0000 (11:48 -0400)
We're supposed to shift the mask to the right spot, which is the index
times the width of the mask.  E.g. for fixed counter 1, we want to look at
the 4 bits shifted in by 4.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/perfmon.c

index 08ed5ad..2ab961b 100644 (file)
@@ -117,12 +117,13 @@ static void perfmon_do_cores_alloc(void *opaque)
 
        spin_lock_irqsave(&cctx->lock);
        if (perfmon_is_fixed_event(&pa->ev)) {
-               uint64_t fxctrl_value = read_msr(MSR_CORE_PERF_FIXED_CTR_CTRL), tmp;
+               uint64_t fxctrl_value = read_msr(MSR_CORE_PERF_FIXED_CTR_CTRL);
+               uint64_t tmp;
 
                i = PMEV_GET_EVENT(pa->ev.event);
                if (i >= (int) cpu_caps.fix_counters_x_proc) {
                        i = -EINVAL;
-               } else if (fxctrl_value & (FIXCNTR_MASK << i)) {
+               } else if (fxctrl_value & (FIXCNTR_MASK << (i * FIXCNTR_NBITS))) {
                        i = -EBUSY;
                } else {
                        cctx->fixed_counters[i] = pa->ev;