diff options
author | Andy Lutomirski <luto@kernel.org> | 2015-10-02 18:28:23 -0700 |
---|---|---|
committer | Andy Lutomirski <luto@kernel.org> | 2015-10-02 18:28:23 -0700 |
commit | e3ca168bacc31dd07145fe9f55f0f84eec951775 (patch) | |
tree | 1e1eeea2cfc37af44abc4d261cd42cad030d32d9 | |
parent | 166a6d3304e1d9a6d406306fa892dc63d42c49f0 (diff) | |
download | misc-tests-e3ca168bacc31dd07145fe9f55f0f84eec951775.tar.gz |
perf_self_monitor: 32-bit and other improvements
Signed-off-by: Andy Lutomirski <luto@kernel.org>
-rw-r--r-- | tight_loop/perf_self_monitor.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tight_loop/perf_self_monitor.c b/tight_loop/perf_self_monitor.c index 378d0fd..51c3338 100644 --- a/tight_loop/perf_self_monitor.c +++ b/tight_loop/perf_self_monitor.c @@ -156,9 +156,32 @@ bool psm_atomic_sample_enosys(uint64_t *count, const struct psm_counter *ctr, void *opaque) { struct psm_atomic duration = psm_atomic_start(ctr); +#ifdef __x86_64__ unsigned long rax; rax = 0xbfffffff; asm volatile ("syscall" : "+a" (rax) : : "rcx", "r11"); +#else + syscall(0x3fffffff); +#endif + return psm_atomic_elapsed(count, &duration, ctr); +} + +bool psm_atomic_sample_bad_prctl_x1000(uint64_t *count, + const struct psm_counter *ctr, void *opaque) +{ + struct psm_atomic duration = psm_atomic_start(ctr); +#ifdef __x86_64__ + unsigned long rax; + register unsigned long rdi asm("rdi"); + for (int i = 0; i < 1000; i++) { + rax = SYS_prctl; + rdi = -1; + asm volatile ("syscall" : "+a" (rax), "+r" (rdi) : : "rcx", "r11"); + } +#else + for (int i = 0; i < 1000; i++) + syscall(SYS_prctl, -1); +#endif return psm_atomic_elapsed(count, &duration, ctr); } @@ -235,7 +258,12 @@ int main() for (int i = 0; i < 20; i++) { uint64_t cost = psm_integer_quantile(ctr, psm_atomic_sample_enosys, NULL, 250, 500) - baseline; - printf("%llu\n", (unsigned long long)cost); + printf("1x ENOSYS: %llu\n", (unsigned long long)cost); + } + + for (int i = 0; i < 20; i++) { + uint64_t cost = psm_integer_quantile(ctr, psm_atomic_sample_bad_prctl_x1000, NULL, 250, 500) - baseline; + printf("1000x bad prctl: %llu\n", (unsigned long long)cost/1000); } psm_counter_destroy(ctr); |