[patch] getting rid of the Big Kernel Spinlock, 2.4.0-test7

From: Ingo Molnar (mingo@elte.hu)
Date: Mon Aug 28 2000 - 10:58:45 EST


during 2.3 we got rid of 99% of lock_kernel()s within the core kernel.
IMHO the time has arrived to get rid of the big kernel spinlock forever -
by changing it to a ordinary semaphore. Most lock_kernel() code paths are
holding the kernel lock for a long time and they do it rarely - so a
semaphore is more suited to do this than a spinlock. It's even a speedup
(and a debugging help), because lock_kernel() will not spin wasting CPU
cycles anymore.

the attached biglock-2.4.0-test7-A6 patch implements this and does a
couple of related cleanups:

- the impact of the 'big IRQ lock' is smaller as well, thus schedule() now
  enforces that it is to be called with IRQs turned on. sleep_on() enables
  IRQs, and entry.S's reschedule as well. (the later is a code path taken
  by returning IRQ handlers which might not always disable IRQs.)

  As a result neither release_kernel_lock(), nor the tq_scheduler path
  needs to do a sti() - which speeds up the common schedule() path. Nor
  the performance, nor the semantics of sleep_on() are impacted.

- new sema_locked() added to semaphore.h - similar to is_spin_locked().

- got rid of asm/smp_lock.h - linux/smplock.h has the generic code, now
  that no global-IRQ locking logic is present in schedule(). This
  simplifies things.

- irqs_enabled() added to asm/hardirq.h.

the only place that still needs to spin actively is
reacquire_kernel_lock() - because semaphore.c calls schedule() itself, so
we cannot call down() at that point. Solving this is not impossible, but
needs more changes than justified i think.

the patch has the IMHO nice side-effect of 'speeding up races' - more
processes can run when the kernel lock is taken because there is no active
spinning - thus SMP, kernel-lock related races are triggered with higher
probability.

the patch compiles/boots/works just fine on SMP and UP x86 systems. Other
architectures have to add the (trivial and generic) sema_locked() and
irqs_enabled() functions. The patch should be an invariant and does not
intend to change semantics of any kernel functionality otherwise.

        Ingo



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:21 EST