Linux kernel smp preempt

Understanding link between CONFIG_SMP, Spinlocks and CONFIG_PREEMPT in latest (3.0.0 and above) Linux kernel

To give you full context my discussion begun with an observation that I am running a SMP linux (3.0.1-rt11) on ARM cortex A8 based SoC which is a uniprocessor. I was curious to know if there will be any performance advantage by disabling SMP support. And if yes what impact it will have on my drivers and interrupt handlers. I did some reading and come across two related topics: spinlocks and kernel preemption. I did little more googling and reading but this time all I got is few stale and contradictory answers. So I thought let me try stackoverflow. Origin of my doubts/questions is this para from Linux device drivers 3rd edition chapter 5:

Spinlocks are, by their nature, intended for use on multiprocessor systems, although a uniprocessor workstation running a preemptive kernel behaves like SMP, as far as concurrency is concerned. If a nonpreemptive uniprocessor system ever went into a spin on a lock, it would spin forever; no other thread would ever be able to obtain the CPU to release the lock. For this reason, spinlock operations on uniprocessor systems without preemption enabled are optimized to do nothing, with the exception of the ones that change the IRQ masking status. Because of preemption, even if you never expect your code to run on an SMP system, you still need to implement proper locking.

My doubts/questions are: a) Is Linux kernel preemptive in kernel space by default? If yes, is this preemption limited to only processes or Interrupt handlers can also be preempted? b) Does Linux kernel (on ARM) support nested interrupt? If yes, will each interrupt handler (top half) have its own stack or they share same 4k/8k kernel mode stack? c) If I disable SMP ( CONFIG_SMP ) and preemption ( CONFIG_PREEMPT ) will spin-locks in my drivers and interrupt handlers make any sense? d) How kernel handle interrupts raised while executing top-half i.e will they be disabled or masked? After some googling I found this:

For kernels compiled without CONFIG_SMP, and without CONFIG_PREEMPT spinlocks do not exist at all. This is an excellent design decision: when no-one else can run at the same time, there is no reason to have a lock. If the kernel is compiled without CONFIG_SMP, but CONFIG_PREEMPT is set, then spinlocks simply disable preemption, which is sufficient to prevent any races. For most purposes, we can think of preemption as equivalent to SMP, and not worry about it separately.

But there is no kernel version or date on the source. Can anyone confirm if its still valid for latest Linux kernels?

Читайте также:  Arch linux which terminal

Источник

Оцените статью
Adblock
detector