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);
struct perf_event_mmap_page *setup_perf(struct perf_event_attr *attr)
{
void *perf_addr;
- int fd;
+ int fd, ret;
fd = sys_perf_event_open(attr, 0, -1, -1, 0);
if (fd < 0)
PROT_READ, MAP_SHARED, fd, 0);
if (perf_addr == MAP_FAILED)
return NULL;
- close(fd);
+ ret = close(fd);
+ if (ret) {
+ perror("Error closing LTTng-UST perf memory mapping FD");
+ }
return perf_addr;
}
* the field here.
*/
+ lttng_context_update(*ctx);
return 0;
setup_error: