summaryrefslogtreecommitdiffstats
path: root/src/asm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/asm.h')
-rwxr-xr-xsrc/asm.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/asm.h b/src/asm.h
index 101faa9..35f803b 100755
--- a/src/asm.h
+++ b/src/asm.h
@@ -22,21 +22,20 @@ static inline void cachepc_mfence(void);
__attribute__((always_inline))
static inline void cachepc_readq(void *p);
-__attribute__((always_inline))
-static inline void cachepc_victim(void *p);
-
uint64_t
cachepc_readpmc(uint64_t event)
{
uint32_t lo, hi;
+ event = 0xC0010201 + 2 * event;
+
asm volatile (
"rdmsr"
: "=a" (lo), "=d" (hi)
: "c"(event)
);
- return ((uint64_t) hi << 32) | (uint64_t)lo;
+ return ((uint64_t) hi << 32) | (uint64_t) lo;
}
void
@@ -54,29 +53,29 @@ cachepc_lfence(void)
{
asm volatile(
"lfence\n\t"
- ::
+ ::: "memory"
);
}
-inline void
+void
cachepc_sfence(void)
{
asm volatile(
"sfence\n\t"
- ::
+ ::: "memory"
);
}
-inline void
+void
cachepc_mfence(void)
{
asm volatile(
"mfence\n\t"
- ::
+ ::: "memory"
);
}
-inline void
+void
cachepc_readq(void *p)
{
asm volatile (
@@ -84,10 +83,3 @@ cachepc_readq(void *p)
: : "r" (p) : "r10"
);
}
-
-inline void
-cachepc_victim(void *p)
-{
- cachepc_mfence();
- cachepc_readq(p);
-}