[PATCH [RT] 00/14] RFC - adaptive real-time locks

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Gregory Haskins
Date: Thursday, February 21, 2008 - 8:26 am

The Real Time patches to the Linux kernel converts the architecture
specific SMP-synchronization primitives commonly referred to as
"spinlocks" to an "RT mutex" implementation that support a priority
inheritance protocol, and priority-ordered wait queues.  The RT mutex
implementation allows tasks that would otherwise busy-wait for a
contended lock to be preempted by higher priority tasks without
compromising the integrity of critical sections protected by the lock.
The unintended side-effect is that the -rt kernel suffers from
significant degradation of IO throughput (disk and net) due to the
extra overhead associated with managing pi-lists and context switching.
This has been generally accepted as a price to pay for low-latency
preemption.

Our research indicates that it doesn't necessarily have to be this
way.  This patch set introduces an adaptive technology that retains both
the priority inheritance protocol as well as the preemptive nature of
spinlocks and mutexes and adds a 300+% throughput increase to the Linux
Real time kernel.  It applies to 2.6.24-rt1.  

These performance increases apply to disk IO as well as netperf UDP
benchmarks, without compromising RT preemption latency.  For more
complex applications, overall the I/O throughput seems to approach the
throughput on a PREEMPT_VOLUNTARY or PREEMPT_DESKTOP Kernel, as is
shipped by most distros.

Essentially, the RT Mutex has been modified to busy-wait under
contention for a limited (and configurable) time.  This works because
most locks are typically held for very short time spans.  Too often,
by the time a task goes to sleep on a mutex, the mutex is already being
released on another CPU.

The effect (on SMP) is that by polling a mutex for a limited time we
reduce context switch overhead by up to 90%, and therefore eliminate CPU
cycles as well as massive hot-spots in the scheduler / other bottlenecks
in the Kernel - even though we busy-wait (using CPU cycles) to poll the
lock.

We have put together some data from different types of benchmarks for
this patch series, which you can find here:

ftp://ftp.novell.com/dev/ghaskins/adaptive-locks.pdf

It compares a stock kernel.org 2.6.24 (PREEMPT_DESKTOP), a stock
2.6.24-rt1 (PREEMPT_RT), and a 2.6.24-rt1 + adaptive-lock
(2.6.24-rt1-al) (PREEMPT_RT) kernel.  The machine is a 4-way (dual-core,
dual-socket) 2Ghz 5130 Xeon (core2duo-woodcrest) Dell Precision 490. 

Some tests show a marked improvement (for instance, dbench and hackbench),
whereas some others (make -j 128) the results were not as profound but
they were still net-positive. In all cases we have also verified that
deterministic latency is not impacted by using cyclic-test. 

This patch series also includes some re-work on the raw_spinlock
infrastructure, including Nick Piggin's x86-ticket-locks.  We found that
the increased pressure on the lock->wait_locks could cause rare but
serious latency spikes that are fixed by a fifo raw_spinlock_t
implementation.  Nick was gracious enough to allow us to re-use his
work (which is already accepted in 2.6.25).  Note that we also have a
C version of his protocol available if other architectures need
fifo-lock support as well, which we will gladly post upon request.

Special thanks go to many people who were instrumental to this project,
including:
  *) the -rt team here at Novell for research, development, and testing.
  *) Nick Piggin for his invaluable consultation/feedback and use of his
     x86-ticket-locks.
  *) The reviewers/testers at Suse, Montavista, and Bill Huey for their
     time and feedback on the early versions of these patches.

As always, comments/feedback/bug-fixes are welcome.

Regards,
-Greg

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH [RT] 00/14] RFC - adaptive real-time locks, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 03/14] x86: FIFO ticket spinlocks, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 06/14] optimize rt lock wakeup, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 07/14] adaptive real-time lock support, Gregory Haskins, (Thu Feb 21, 8:27 am)
[PATCH [RT] 09/14] adaptive mutexes, Gregory Haskins, (Thu Feb 21, 8:27 am)
[PATCH [RT] 10/14] adjust pi_lock usage in wakeup, Gregory Haskins, (Thu Feb 21, 8:27 am)
[PATCH [RT] 12/14] remove the extra call to try_to_take_lock, Gregory Haskins, (Thu Feb 21, 8:27 am)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Gregory Haskins, (Thu Feb 21, 9:05 am)
Re: [PATCH [RT] 10/14] adjust pi_lock usage in wakeup, Steven Rostedt, (Thu Feb 21, 9:48 am)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Peter W. Morreale, (Thu Feb 21, 10:04 am)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Sven-Thorsten Dietrich, (Thu Feb 21, 10:06 am)
Re: [PATCH [RT] 10/14] adjust pi_lock usage in wakeup, Peter W. Morreale, (Thu Feb 21, 10:09 am)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Ingo Molnar, (Thu Feb 21, 2:24 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Bill Huey (hui), (Thu Feb 21, 2:33 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Gregory Haskins, (Thu Feb 21, 2:40 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Peter W. Morreale, (Thu Feb 21, 3:12 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Peter W. Morreale, (Thu Feb 21, 3:42 pm)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Gregory Haskins, (Fri Feb 22, 6:29 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Steven Rostedt, (Fri Feb 22, 6:35 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Ingo Molnar, (Fri Feb 22, 6:35 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Peter Zijlstra, (Fri Feb 22, 6:40 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Steven Rostedt, (Fri Feb 22, 6:43 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Steven Rostedt, (Fri Feb 22, 6:46 am)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Paul E. McKenney, (Fri Feb 22, 12:08 pm)
Re: [PATCH [RT] 07/14] adaptive real-time lock support, Pavel Machek, (Fri Feb 22, 12:14 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Paul E. McKenney, (Fri Feb 22, 12:43 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Sven-Thorsten Dietrich, (Fri Feb 22, 12:55 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Peter W. Morreale, (Fri Feb 22, 1:15 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Peter W. Morreale, (Fri Feb 22, 1:36 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Sven-Thorsten Dietrich, (Sat Feb 23, 12:36 am)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Andrew Morton, (Sat Feb 23, 1:03 am)