Find the full description in my blog post about x86 system call mechanisms over on x86.lol.
This repository contains x86 kernel entry benchmarks for:
- interrupt gates,
- call gates,
sysenter
/sysexit
,syscall
/sysret
.
If you have Nix, you can build the measurement kernel like this:
% nix-build ./ci.nix -A defaultPackage
The kernel will then be result
in the current directory.
If you have Nix with Flakes (still not enabled by default), this can be shortened to:
% nix build
For building and running without Nix you need:
- gcc >= 7.x
- make
Then you can just invoke make to build the kernel:
% make -C src
Then you can find the kernel as src/kernel_entry_benchmark.elf32
.
Whether this works is up to your system. Only the Nix build is tested.
The tiny benchmark kernel assumes that it runs on Qemu and can use the Qemu debug console. You can run it as a Multiboot-compatible kernel:
% qemu-system-x86_64 -kernel result -debugcon stdio -no-reboot -enable-kvm
Interrupt Gate,610
Call Gate,473
Syscall,99
The output is in CSV format. The first column is the kernel entry method and the second is the length of a roundtrip to the kernel using this method in cycles.
I leave implementing serial output and running it on real hardware as an exercise to the reader.
Note: Only Intel CPUs work currently. There seems to be an issue on AMD CPUs that currently limit this benchmark from running there.