zfs/module/spl
Brian Behlendorf 10129680f8 Ensure kmem_alloc() and vmem_alloc() never fail
The Solaris semantics for kmem_alloc() and vmem_alloc() are that they
must never fail when called with KM_SLEEP.  They may only fail if
called with KM_NOSLEEP otherwise they must block until memory is
available.  This is quite different from how the Linux memory
allocators work, under Linux a memory allocation failure is always
possible and must be dealt with.

At one point in the past the kmem code did properly implement this
behavior, however as the code evolved this behavior was overlooked
in places.  This patch goes through all three implementations of
the kmem/vmem allocation functions and ensures that they will all
block in the KM_SLEEP case when memory is not available.  They
may still fail in the KM_NOSLEEP case in which case the caller
is responsible for handling the failure.

Special care is taken in vmalloc_nofail() to avoid thrashing the
system on the virtual address space spin lock.  The down side of
course is if you do see a failure here, which is unlikely for
64-bit systems, your allocation will delay for an entire second.
Still this is preferable to locking up your system and it is the
best we can do given the constraints.

Additionally, the code was cleaned up to be much more readable
and comments were added to describe the various kmem-debug-*
configure options.  The default configure options remain:
"--enable-debug-kmem --disable-debug-kmem-tracking"
2010-07-26 15:47:55 -07:00
..
.gitignore sun-misc-gitignore 2010-01-08 09:37:54 -08:00
Makefile.in Add basic credential support and splat tests. 2009-07-27 17:18:59 -07:00
spl-atomic.c Public Release Prep 2010-05-17 15:18:00 -07:00
spl-condvar.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-cred.c Public Release Prep 2010-05-17 15:18:00 -07:00
spl-debug.c Remove deadcode caused by removal of format1 arg 2010-07-21 16:31:42 -07:00
spl-err.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-generic.c Display DEBUG keyword during module load when --enable-debug is used. 2010-07-20 15:31:03 -07:00
spl-kmem.c Ensure kmem_alloc() and vmem_alloc() never fail 2010-07-26 15:47:55 -07:00
spl-kobj.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-kstat.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-module.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-mutex.c Public Release Prep 2010-05-17 15:18:00 -07:00
spl-proc.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-rwlock.c Public Release Prep 2010-05-17 15:18:00 -07:00
spl-taskq.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-thread.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00
spl-time.c Minor 32-bit fix cast to hrtime_t before the mutliply. 2010-05-23 09:51:17 -07:00
spl-vnode.c Fix two minor compiler warnings 2010-07-26 10:24:26 -07:00
spl-xdr.c Prefix all SPL debug macros with 'S' 2010-07-20 13:30:40 -07:00