mirror_zfs/include/sys
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
..
fm Public Release Prep 2010-05-17 15:18:00 -07:00
fs Public Release Prep 2010-05-17 15:18:00 -07:00
sysevent Public Release Prep 2010-05-17 15:18:00 -07:00
acl_impl.h Public Release Prep 2010-05-17 15:18:00 -07:00
acl.h Public Release Prep 2010-05-17 15:18:00 -07:00
atomic.h Public Release Prep 2010-05-17 15:18:00 -07:00
attr.h Public Release Prep 2010-05-17 15:18:00 -07:00
bitmap.h Public Release Prep 2010-05-17 15:18:00 -07:00
bootconf.h Public Release Prep 2010-05-17 15:18:00 -07:00
bootprops.h Stub out additional missing headers 2010-06-11 15:57:25 -07:00
buf.h Public Release Prep 2010-05-17 15:18:00 -07:00
byteorder.h Public Release Prep 2010-05-17 15:18:00 -07:00
callb.h Public Release Prep 2010-05-17 15:18:00 -07:00
cmn_err.h Public Release Prep 2010-05-17 15:18:00 -07:00
compress.h Public Release Prep 2010-05-17 15:18:00 -07:00
condvar.h Public Release Prep 2010-05-17 15:18:00 -07:00
conf.h Public Release Prep 2010-05-17 15:18:00 -07:00
console.h Public Release Prep 2010-05-17 15:18:00 -07:00
cpupart.h Stub out additional missing headers 2010-06-11 15:57:25 -07:00
cpuvar.h Public Release Prep 2010-05-17 15:18:00 -07:00
crc32.h Public Release Prep 2010-05-17 15:18:00 -07:00
cred.h Public Release Prep 2010-05-17 15:18:00 -07:00
ctype.h Public Release Prep 2010-05-17 15:18:00 -07:00
ddi.h Public Release Prep 2010-05-17 15:18:00 -07:00
debug.h Display DEBUG keyword during module load when --enable-debug is used. 2010-07-20 15:31:03 -07:00
dirent.h Public Release Prep 2010-05-17 15:18:00 -07:00
disp.h Public Release Prep 2010-05-17 15:18:00 -07:00
dkio.h Public Release Prep 2010-05-17 15:18:00 -07:00
dklabel.h Public Release Prep 2010-05-17 15:18:00 -07:00
dnlc.h Public Release Prep 2010-05-17 15:18:00 -07:00
dumphdr.h Public Release Prep 2010-05-17 15:18:00 -07:00
efi_partition.h Public Release Prep 2010-05-17 15:18:00 -07:00
errno.h Public Release Prep 2010-05-17 15:18:00 -07:00
file.h Public Release Prep 2010-05-17 15:18:00 -07:00
int_limits.h Public Release Prep 2010-05-17 15:18:00 -07:00
int_types.h Public Release Prep 2010-05-17 15:18:00 -07:00
inttypes.h Public Release Prep 2010-05-17 15:18:00 -07:00
isa_defs.h Public Release Prep 2010-05-17 15:18:00 -07:00
kidmap.h Public Release Prep 2010-05-17 15:18:00 -07:00
kmem.h Ensure kmem_alloc() and vmem_alloc() never fail 2010-07-26 15:47:55 -07:00
kobj.h Public Release Prep 2010-05-17 15:18:00 -07:00
kstat.h Cleanly split Linux proc.h (fs) from conflicting Solaris proc.h (process) 2010-06-11 15:57:25 -07:00
list.h Public Release Prep 2010-05-17 15:18:00 -07:00
Makefile.in Build system and packaging (RPM support) 2009-03-09 15:56:55 -07:00
mkdev.h Public Release Prep 2010-05-17 15:18:00 -07:00
mntent.h Public Release Prep 2010-05-17 15:18:00 -07:00
modctl.h Public Release Prep 2010-05-17 15:18:00 -07:00
mode.h Public Release Prep 2010-05-17 15:18:00 -07:00
mount.h Public Release Prep 2010-05-17 15:18:00 -07:00
mutex.h Fix compilation error due to undefined ACCESS_ONCE macro. 2010-07-20 13:47:52 -07:00
note.h Public Release Prep 2010-05-17 15:18:00 -07:00
open.h Public Release Prep 2010-05-17 15:18:00 -07:00
param.h Public Release Prep 2010-05-17 15:18:00 -07:00
pathname.h Public Release Prep 2010-05-17 15:18:00 -07:00
policy.h Public Release Prep 2010-05-17 15:18:00 -07:00
pool.h Stub out additional missing headers 2010-06-11 15:57:25 -07:00
priv_impl.h Stub out additional missing headers 2010-06-11 15:57:25 -07:00
proc.h Cleanly split Linux proc.h (fs) from conflicting Solaris proc.h (process) 2010-06-11 15:57:25 -07:00
processor.h Public Release Prep 2010-05-17 15:18:00 -07:00
pset.h Stub out additional missing headers 2010-06-11 15:57:25 -07:00
random.h Public Release Prep 2010-05-17 15:18:00 -07:00
refstr.h Public Release Prep 2010-05-17 15:18:00 -07:00
resource.h Public Release Prep 2010-05-17 15:18:00 -07:00
rwlock.h Split <sys/debug.h> header 2010-07-20 13:29:35 -07:00
sdt.h Public Release Prep 2010-05-17 15:18:00 -07:00
sid.h Minor cleanup and Solaris API additions. 2010-06-11 15:57:25 -07:00
signal.h Split <sys/debug.h> header 2010-07-20 13:29:35 -07:00
stat.h Public Release Prep 2010-05-17 15:18:00 -07:00
stropts.h Public Release Prep 2010-05-17 15:18:00 -07:00
sunddi.h Split <sys/debug.h> header 2010-07-20 13:29:35 -07:00
sunldi.h Public Release Prep 2010-05-17 15:18:00 -07:00
sysdc.h Stub out additional missing headers 2010-06-11 15:57:25 -07:00
sysevent.h Public Release Prep 2010-05-17 15:18:00 -07:00
sysmacros.h Fix max_ncpus definition. 2010-07-20 15:49:25 -07:00
systeminfo.h Public Release Prep 2010-05-17 15:18:00 -07:00
systm.h Public Release Prep 2010-05-17 15:18:00 -07:00
t_lock.h Public Release Prep 2010-05-17 15:18:00 -07:00
taskq.h Implementation of the TQ_FRONT flag. 2010-07-01 10:59:38 -07:00
thread.h Split <sys/debug.h> header 2010-07-20 13:29:35 -07:00
time.h Public Release Prep 2010-05-17 15:18:00 -07:00
timer.h Minor cleanup and Solaris API additions. 2010-06-11 15:57:25 -07:00
types32.h Public Release Prep 2010-05-17 15:18:00 -07:00
types.h Add __divdi3(), remove __udivdi3() kernel dependency 2010-07-13 16:44:02 -07:00
u8_textprep.h Public Release Prep 2010-05-17 15:18:00 -07:00
uio.h Add xuio_* structures and typedefs. 2010-06-11 15:57:25 -07:00
unistd.h Public Release Prep 2010-05-17 15:18:00 -07:00
utsname.h Public Release Prep 2010-05-17 15:18:00 -07:00
va_list.h Public Release Prep 2010-05-17 15:18:00 -07:00
varargs.h Public Release Prep 2010-05-17 15:18:00 -07:00
vfs_opreg.h Public Release Prep 2010-05-17 15:18:00 -07:00
vfs.h Public Release Prep 2010-05-17 15:18:00 -07:00
vmsystm.h Public Release Prep 2010-05-17 15:18:00 -07:00
vnode.h Linux-2.6.33 compat, O_DSYNC flag added 2010-06-30 12:49:39 -07:00
zmod.h Public Release Prep 2010-05-17 15:18:00 -07:00
zone.h Public Release Prep 2010-05-17 15:18:00 -07:00