Benchmark for testing Linux kernel spin locks performance with different threads and critical sections. The test scenario is similar to glibc bench-pthread-lock.
The bench configuration consists of 3 parts:
- thread number
- critical-section length
- non-critical-section length
The length is the number of unit work, each unit work will roughly take 15 cycles in Icelake.
Compile and install the kernel module:
make
sudo make installRun the test
echo "[nthreads] [crit_len] [non_crit_len] > /proc/spinlock_bench
# nthreads should <= num_online_cpus()
# example: echo "16 2 8" > /proc/spinlock_benchCheck the results
cat /proc/spinlock_benchThe benchmark will run several rounds and show result in throughputs. The highest and lowest number are discarded as outliers.