Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do spin_lock and spin_unlock hurt performance of an SMP kernel on a single-cpu machine?

On my Ubuntu machine, default kernel image which is running is built for smp (CONFIG_SMP=y). But this machine has only 1 cpu.

On uni-processor kernel, unlike smp kernel, spin_lock/unlock are null functions. So how does spin_lock() and spin_unlock() behave in this setup?

Is there any performance impact due to such smp specific code?

like image 396
Vinit Dhatrak Avatar asked Oct 29 '09 17:10

Vinit Dhatrak


1 Answers

Current Linux kernels contain a patch that you can google for with the terms "SMP alternatives". In short, during boot, if the kernel detects that it's running on a uniprocessor machines, the spinlock functions are hot-patched with no-ops.

like image 129
janneb Avatar answered Nov 03 '22 22:11

janneb