Skip to content

Commit

Permalink
jevents: Mask RDPMC with 48bit mask
Browse files Browse the repository at this point in the history
Also drop ifdef for ICC. We can use the same method for gcc/clang.

Thanks to Travis Downs and Kan Liang for analysis

Fixes #173
  • Loading branch information
Andi Kleen committed Sep 10, 2019
1 parent ec7a7d8 commit 30d4df6
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions jevents/rdpmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
#include <linux/perf_event.h>
#include <stdint.h>
#include <stdlib.h>
#include <x86intrin.h>
#include "jevents.h"

#if defined(__ICC) || defined(__INTEL_COMPILER)
#include "immintrin.h"
#endif

/**
* DOC: Ring 3 counting for CPU performance counters
*
Expand Down Expand Up @@ -130,15 +127,13 @@ unsigned long long rdpmc_read(struct rdpmc_ctx *ctx)
rmb();
index = buf->index;
offset = buf->offset;
if (index == 0) /* rdpmc not allowed */
return offset;
#if defined(__ICC) || defined(__INTEL_COMPILER)
if (index == 0) { /* rdpmc not allowed */
val = 0;
break;
}
val = _rdpmc(index - 1);
#else
val = __builtin_ia32_rdpmc(index - 1);
#endif
rmb();
} while (buf->lock != seq);
return val + offset;
return (val + offset) & 0xffffffffffff;
}

0 comments on commit 30d4df6

Please sign in to comment.