diff options
author | Andrei Vagin <avagin@google.com> | 2021-04-07 16:22:43 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-07 16:25:02 -0700 |
commit | 0e55b57452d3437f494690dca67bcc55f11d3c60 (patch) | |
tree | 444a828c0af2ddfe962be067b51e923ddfb1e5e4 /test/perf/linux/getpid_benchmark.cc | |
parent | e6133abfca2ca2bbfce36f770f09f28236a7a76c (diff) |
perf/getpid: add a case when syscalls are executed via mov $XXX, %eax; syscall
This is the most often pattern of calling system calls in real applications.
PiperOrigin-RevId: 367320048
Diffstat (limited to 'test/perf/linux/getpid_benchmark.cc')
-rw-r--r-- | test/perf/linux/getpid_benchmark.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/perf/linux/getpid_benchmark.cc b/test/perf/linux/getpid_benchmark.cc index db74cb264..047a034bd 100644 --- a/test/perf/linux/getpid_benchmark.cc +++ b/test/perf/linux/getpid_benchmark.cc @@ -31,6 +31,24 @@ void BM_Getpid(benchmark::State& state) { BENCHMARK(BM_Getpid); +#ifdef __x86_64__ + +#define SYSNO_STR1(x) #x +#define SYSNO_STR(x) SYSNO_STR1(x) + +// BM_GetpidOpt uses the most often pattern of calling system calls: +// mov $SYS_XXX, %eax; syscall. +void BM_GetpidOpt(benchmark::State& state) { + for (auto s : state) { + __asm__("movl $" SYSNO_STR(SYS_getpid) ", %%eax\n" + "syscall\n" + : : : "rax", "rcx", "r11"); + } +} + +BENCHMARK(BM_GetpidOpt); +#endif // __x86_64__ + } // namespace } // namespace testing |