Fix: perf counters: sign-extend pmc register
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Jul 2016 18:47:00 +0000 (14:47 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Jul 2016 18:47:00 +0000 (14:47 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/lttng-context-perf-counters.c

index 0b8f9fa2ee27bd1646d3785bc58668ea069063f7..a7e1b63f4ab02f5666fbbe3c5c4a23b8dcda5a19 100644 (file)
@@ -113,11 +113,17 @@ uint64_t read_perf_counter(
                cmm_barrier();
 
                idx = pc->index;
-               if (idx)
-                       count = pc->offset + rdpmc(idx - 1);
-               else
+               if (idx) {
+                       int64_t pmcval;
+
+                       pmcval = rdpmc(idx - 1);
+                       /* Sign-extend the pmc register result. */
+                       pmcval <<= 64 - pc->pmc_width;
+                       pmcval >>= 64 - pc->pmc_width;
+                       count = pc->offset + pmcval;
+               } else {
                        count = 0;
-
+               }
                cmm_barrier();
        } while (CMM_LOAD_SHARED(pc->lock) != seq);
 
This page took 0.026184 seconds and 4 git commands to generate.