diff options
Diffstat (limited to 'share/man/man9/malloc.9')
-rw-r--r-- | share/man/man9/malloc.9 | 62 |
1 files changed, 12 insertions, 50 deletions
diff --git a/share/man/man9/malloc.9 b/share/man/man9/malloc.9 index ee32f5b95e6b..bcb69bd53bec 100644 --- a/share/man/man9/malloc.9 +++ b/share/man/man9/malloc.9 @@ -85,7 +85,7 @@ the kernel version takes two more arguments. The argument further qualifies .Fn malloc No Ns 's operational characteristics as follows: -.Bl -tag -width indent +.Bl -tag -offset indent .It Dv M_NOWAIT Causes .Fn malloc @@ -95,45 +95,19 @@ if the request cannot be immediately fulfilled due to resource shortage. Otherwise, .Fn malloc may call sleep to wait for resources to be released by other processes. -If this flag is set, +If this flag is not set, .Fn malloc -will return -.Dv NULL -rather then block. Note that +will never return +.Dv NULL . +Note that .Dv M_WAITOK -is defined to be 0, meaning that blocking operation is the default. -.It Dv M_ASLEEP -Causes -.Fn malloc -to call -.Fn asleep -if the request cannot be immediately fulfilled due to a resource shortage. -M_ASLEEP is not useful alone and should always be or'd with M_NOWAIT to allow -malloc to call -.Fn asleep -and return -.Dv NULL -immediately. It is expected that the caller will at some point call -.Fn await -and then retry the allocation. Depending on the routine in question, the -caller may decide to propogate the temporary failure up the call chain -and actually have some other higher level routine block on the async wait -that -.Fn malloc -queued. -.It Dv M_WAITOK -indicates that it is Ok to wait for resources. It is unconveniently -defined as 0 so care should be taken never to compare against this value -directly or try to AND it as a flag. The default operation is to block -until the memory allocation succeeds. -.Fn malloc -can only return -.Dv NULL -if -.Dv M_NOWAIT -is specified. +is conveniently defined to be 0, and hence may be or'ed into the +.Fa flags +argument to indicate that it's Ok to wait for resources. .El .Pp +Currently, only one flag is defined. +.Pp The .Fa type argument is used to perform statistics on memory usage, and for @@ -163,23 +137,11 @@ malloc_type_t M_FOOBUF = { ... MALLOC(buf, struct foo_buf *, sizeof *buf, M_FOOBUF, M_NOWAIT); -.Ed +.Be .Sh RETURN VALUES .Fn malloc returns a kernel virtual address that is suitably aligned for storage of -any type of object, or -.Dv NULL -if the request could not be satisfied and -.Dv M_NOWAIT -was set. If -.Dv M_ASLEEP -was set and -.Fn malloc -returns -.Dv NULL , -it will call -.Fn asleep -as a side effect. +any type of object. .Sh SEE ALSO .Xr vmstat 8 .Sh DIAGNOSTICS |