OpenZFS on Linux and FreeBSD
Go to file
Ned Bass ec2b41049f Taskq locking optimizations
Testing has shown that tq->tq_lock can be highly contended when a
large number of small work items are dispatched.  The lock hold time
is reduced by the following changes:

1) Use exclusive threads in the work_waitq

When a single work item is dispatched we only need to wake a single
thread to service it.  The current implementation uses non-exclusive
threads so all threads are woken when the dispatcher calls wake_up().
If a large number of threads are in the queue this overhead can become
non-negligible.

2) Conditionally add/remove threads from work waitq outside of tq_lock

Taskq threads need only add themselves to the work wait queue if there
are no pending work items.  Furthermore, the add and remove function
calls can be made outside of the taskq lock since the wait queues are
protected from concurrent access by their own spinlocks.

3) Call wake_up() outside of tq->tq_lock

Again, the wait queues are protected by their own spinlock, so the
dispatcher functions can drop tq->tq_lock before calling wake_up().

A new splat test taskq:contention was added in a prior commit to measure
the impact of these changes.  The following table summarizes the
results using data from the kernel lock profiler.

                        tq_lock time    %diff   Wall clock (s)  %diff
original:               39117614.10     0       41.72           0
exclusive threads:      31871483.61     18.5    34.2            18.0
unlocked add/rm waitq:  13794303.90     64.7    16.17           61.2
unlocked wake_up():     1589172.08      95.9    16.61           60.2

Each row reflects the average result over 5 test runs.
/proc/lock_stats was zeroed out before and collected after each run.
Column 1 is the cumulative hold time in microseconds for tq->tq_lock.
The tests are cumulative; each row reflects the code changes of the
previous rows.  %diff is calculated with respect to "original" as
100*(orig-new)/orig.

Although calling wake_up() outside of the taskq lock dramatically
reduced the taskq lock hold time, the test actually took slightly more
wall clock time.  This is because the point of contention shifts from
the taskq lock to the wait queue lock.  But the change still seems
worthwhile since it removes our taskq implementation as a bottleneck,
assuming the small increase in wall clock time to be statistical
noise.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #32
2012-01-18 10:36:57 -08:00
cmd Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
config Run SPL_AC_PACMAN only if $VENDOR is "arch" 2012-01-13 09:08:12 -08:00
include Linux 3.2 compat: rw_semaphore.wait_lock is raw 2012-01-11 16:28:05 -08:00
lib Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
module Taskq locking optimizations 2012-01-18 10:36:57 -08:00
patches Reimplement rwlocks for Linux lock profiling/analysis. 2009-09-18 16:09:47 -07:00
scripts Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
.gitignore Ignore unsigned module build products 2010-03-11 14:29:17 -08:00
AUTHORS Public Release Prep 2010-05-17 15:18:00 -07:00
COPYING Public Release Prep 2010-05-17 15:18:00 -07:00
ChangeLog Prep for spl-0.5.0 tag 2010-08-13 09:33:50 -07:00
DISCLAIMER Public Release Prep 2010-05-17 15:18:00 -07:00
INSTALL Public Release Prep 2010-05-17 15:18:00 -07:00
META Prep spl-0.6.0-rc6 tag 2011-10-06 14:58:09 -07:00
Makefile.am Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
Makefile.in Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
PKGBUILD-spl-modules.in Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
PKGBUILD-spl.in Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
README.markdown Fix markdown rendering 2010-09-15 09:05:34 -07:00
autogen.sh Public Release Prep 2010-05-17 15:18:00 -07:00
configure Run SPL_AC_PACMAN only if $VENDOR is "arch" 2012-01-13 09:08:12 -08:00
configure.ac Add make rule for building Arch Linux packages 2011-12-14 16:44:10 -08:00
spl-modules.spec.in Fix depmod warning 2011-11-10 10:36:30 -08:00
spl.spec.in Include distribution in release 2011-10-19 11:41:15 -07:00
spl_config.h.in Linux 3.2 compat: rw_semaphore.wait_lock is raw 2012-01-11 16:28:05 -08:00

README.markdown

The Solaris Porting Layer (SPL) is a Linux kernel module which provides many of the Solaris kernel APIs. This shim layer makes it possible to run Solaris kernel code in the Linux kernel with relatively minimal modification. This can be particularly useful when you want to track upstream Solaris development closely and dont want the overhead of maintaining a large patch which converts Solaris primitives to Linux primitives.

To build packages for your distribution:

$ ./configure
$ make pkg

Full documentation for building, configuring, and using the SPL can be found at: http://zfsonlinux.org