OpenZFS on Linux and FreeBSD
Go to file
Brian Behlendorf d28db80fd0 Update rwlocks to track owner to ensure correct semantics
The behavior of RW_*_HELD was updated because it was not quite right.
It is not sufficient to return non-zero when the lock is help, we must
only do this when the current task in the holder.

This means we need to track the lock owner which is not something
tracked in a Linux semaphore.  After some experimentation the
solution I settled on was to embed the Linux semaphore at the start
of a larger krwlock_t structure which includes the owner field.
This maintains good performance and allows us to cleanly intergrate
with the kernel lock analysis tools.  My reasons:

1) By placing the Linux semaphore at the start of krwlock_t we can
then simply cast krwlock_t to a rw_semaphore and pass that on to
the linux kernel.  This allows us to use '#defines so the preprocessor
can do direct replacement of the Solaris primative with the linux
equivilant.  This is important because it then maintains the location
information for each rw_* call point.

2) Additionally, by adding the owner to krwlock_t we can keep this
needed extra information adjacent to the lock itself.  This removes
the need for a fancy lookup to get the owner which is optimal for
performance.  We can also leverage the existing spin lock in the
semaphore to ensure owner is updated correctly.

3) All helper functions which do not need to strictly be implemented
as a define to preserve location information can be done as a static
inline function.

4) Adding the owner to krwlock_t allows us to remove all memory
allocations done during lock initialization.  This is good for all
the obvious reasons, we do give up the ability to specific the lock
name.  The Linux profiling tools will stringify the lock name used
in the code via the preprocessor and use that.

Update rwlocks validated on:
- SLES10   (ppc64)
- SLES11   (x86_64)
- CHAOS4.2 (x86_64)
- RHEL5.3  (x86_64)
- RHEL6    (x86_64)
- FC11     (x86_64)
2009-09-25 14:14:35 -07:00
cmd Simplify rpm build rules, added config/rpm.am. 2009-07-01 14:37:44 -07:00
config Reimplement rwlocks for Linux lock profiling/analysis. 2009-09-18 16:09:47 -07:00
include Update rwlocks to track owner to ensure correct semantics 2009-09-25 14:14:35 -07:00
lib Simplify rpm build rules, added config/rpm.am. 2009-07-01 14:37:44 -07:00
module Update rwlocks to track owner to ensure correct semantics 2009-09-25 14:14:35 -07:00
patches Reimplement rwlocks for Linux lock profiling/analysis. 2009-09-18 16:09:47 -07:00
scripts Simplify rpm build rules, added config/rpm.am. 2009-07-01 14:37:44 -07:00
AUTHORS Prep for spl-0.4.3 tag. 2009-03-20 14:48:30 -07:00
COPYING Go through and add a header with the proper UCRL number. 2008-05-26 04:38:26 +00:00
ChangeLog Tag spl-0.4.5. 2009-08-04 12:22:33 -07:00
DISCLAIMER Go through and add a header with the proper UCRL number. 2008-05-26 04:38:26 +00:00
INSTALL Trivial commit to remove whitespace 2008-07-09 19:11:29 +00:00
META Tag spl-0.4.5. 2009-08-04 12:22:33 -07:00
Makefile.am Simplify rpm build rules, added config/rpm.am. 2009-07-01 14:37:44 -07:00
Makefile.in Simplify rpm build rules, added config/rpm.am. 2009-07-01 14:37:44 -07:00
autogen.sh Packaging improvements for RHEL and SLES 2009-06-16 10:44:59 -07:00
configure Reimplement rwlocks for Linux lock profiling/analysis. 2009-09-18 16:09:47 -07:00
configure.ac Simplify rpm build rules, added config/rpm.am. 2009-07-01 14:37:44 -07:00
spl-modules.spec.in Various spec file tweaks to handle rpm building of several distros. 2009-08-14 14:09:16 -07:00
spl.spec.in Simplify rpm build rules, added config/rpm.am. 2009-07-01 14:37:44 -07:00
spl_config.h.in Reimplement rwlocks for Linux lock profiling/analysis. 2009-09-18 16:09:47 -07:00
spl_unconfig.h Allow spl_config.h to be included by dependant packages 2009-03-17 14:55:59 -07:00