X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-context-perf-counters.c;h=c3728867af8f018d202ea38e8f126b51bd8015ac;hb=3046b99ebe14547404cb0578c1007aa5eda42472;hp=97ddf977d1ba17706ae337bb66d3c1241da13038;hpb=73d2b7cba6bc5c468190cfba5290d0002a3d23ab;p=lttng-ust.git diff --git a/liblttng-ust/lttng-context-perf-counters.c b/liblttng-ust/lttng-context-perf-counters.c index 97ddf977..c3728867 100644 --- a/liblttng-ust/lttng-context-perf-counters.c +++ b/liblttng-ust/lttng-context-perf-counters.c @@ -110,11 +110,17 @@ uint64_t read_perf_counter(struct perf_event_mmap_page *pc) 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);