Interrupts with SMP defined

Chris Loveland (
Wed, 4 Mar 1998 17:03:17 -0500 (EST)

In recent kernels I have noticed a problem which causes my system to hang.
It is related to the way that the routines which deal with turning
interrupts on and off are defined when the kernel is compiled with SMP=1.
I am using a uniprocessor machine so my first question is should a
kernel with SMP defined run correctly on a single processor machine?
What happens is that a save_flags, restore flags sequence inside of a
section of code protected by a spinlock turns interupts back on.

spin_lock_irqsave(&some_lock, flags1);
/* interupts now off */
/* interupts are back on, bad stuff happens */
spin_unlock_irqrestore(&some_lock, flags1);

This happens because the above code turns into a mix of calls to the
__save_flags(), __cli(), __restore_flags() and
__global_save_flags(), __global_restore_flags()

The call to save_flags above becomes __global_save_flags() which is just
the code:

unsigned long __global_save_flags(void)

if (!local_irq_count[smp_processor_id()])
return global_irq_holder == (unsigned char) smp_processor_id();
else {
unsigned long x;
return x;

The kernel enters the if part with global_irq_holder set to NO_PROC_ID so
the function returns 0. The successive call to __global_restore_flags
with flags having a value of 0 turns interrupts on.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to