svcadm(8)을 검색하려면 섹션에서 8 을 선택하고, 맨 페이지 이름에 svcadm을 입력하고 검색을 누른다.
ddi_umem_free(9f)
ddi_umem_alloc(9F) Kernel Functions ddi_umem_alloc(9F)
NAME
ddi_umem_alloc, ddi_umem_free, ddi_device_umem_alloc,
ddi_device_umem_free - allocate and free page-aligned kernel memory,
allocate user addressable memory
optimized for device and free memory allocated by
ddi_device_umem_alloc
SYNOPSIS
#include <sys/types.h>
#include <sys/sunddi.h>
void *ddi_umem_alloc(size_t size, int flag,
ddi_umem_cookie_t *cookiep);
void ddi_umem_free(ddi_umem_cookie_t cookie);
void *ddi_device_umem_alloc(dev_info_t *dip,
size_t size, int flags, ddi_umem_cookie_t *cookie);
void ddi_device_umem_free(dev_info_t *dip,
ddi_umem_cookie_t cookie);
INTERFACE LEVEL
Solaris DDI specific (Solaris DDI).
PARAMETERS
ddi_umem_alloc()
size Number of bytes to allocate.
flag Used to determine the sleep and pageable conditions.
Possible sleep flags are DDI_UMEM_SLEEP, which allows sleep‐
ing until memory is available, and DDI_UMEM_NOSLEEP, which
returns NULL immediately if memory is not available.
The default condition is to allocate locked memory; this can
be changed to allocate pageable memory using the
DDI_UMEM_PAGEABLE flag.
cookie Pointer to a kernel memory cookie.
ddi_umem_free()
cookie A kernel memory cookie allocated in ddi_umem_alloc().
ddi_device_umem_alloc()
dip Pointer to the devinfo structure of the device for which the
memory is being allocated.
size Number of bytes to allocate.
flags Used to determine the sleep and pageable conditions.
Possible sleep flags are DDI_UMEM_SLEEP, which allows sleep‐
ing until memory is available, and DDI_UMEM_NOSLEEP, which
returns NULL immediately if memory is not available.
The default condition is to allocate locked memory; this can
be changed to allocate pageable memory using the
DDI_UMEM_PAGEABLE flag.
cookie Pointer to a kernel memory cookie.
ddi_device_umem_free()
dip Pointer to the devinfo structure of the device from which the
memory is being freed.
cookie A kernel memory cookie allocated in ddi_device_umem_alloc().
DESCRIPTION
ddi_umem_alloc() and ddi_device_umem_alloc() allocate page-aligned ker‐
nel memory and return a pointer to the allocated memory. The number of
bytes allocated is a multiple of the system page size (roundup of
size). The allocated memory can be used in the kernel and can be
exported to user space.
ddi_device_umem_alloc() allocates memory optimized for I/O in a NUMA
system.
See devmap(9E) and devmap_umem_setup(9F) for further information.
flag determines whether the caller can sleep for memory and whether the
allocated memory is locked or not. DDI_UMEM_SLEEP allocations may sleep
but are guaranteed to succeed. DDI_UMEM_NOSLEEP allocations do not
sleep but may fail (return NULL) if memory is currently unavailable. If
DDI_UMEM_PAGEABLE is set, pageable memory will be allocated. These
pages can be swapped out to secondary memory devices. The initial con‐
tents of memory allocated using ddi_device_umem_alloc() and
ddi_umem_alloc() is zero-filled.
*cookie is a pointer to the kernel memory cookie that describes the
kernel memory being allocated. A typical use of cookie is in
devmap_umem_setup(9F) when the drivers want to export the kernel memory
to a user application.
To free the memory allocated in ddi_umem_alloc, a driver calls
ddi_umem_free() with the cookie obtained from ddi_umem_alloc().
ddi_umem_free() releases the entire buffer.
To free the memory allocated in ddi_device_umem_alloc, a driver calls
ddi_device_umem_free() with the cookie obtained from
ddi_device_umem_alloc(). ddi_device_umem_free() releases the entire
buffer.
RETURN VALUES
Non-null Successful completion. ddi_umem_alloc() and
ddi_device_umem_alloc() return a pointer to the allocated
memory.
NULL Memory cannot be allocated by ddi_umem_alloc() and
ddi_device_umem_alloc() because DDI_UMEM_NOSLEEP is set and
the system is out of resources.
CONTEXT
ddi_umem_alloc() and ddi_device_umem_alloc() can be called from any
context if flag is set to DDI_UMEM_NOSLEEP. If DDI_UMEM_SLEEP is set,
ddi_umem_alloc() or ddi_device_umem_alloc() can be called from user and
kernel context only. ddi_umem_free() and ddi_device_umem_free() can be
called from any context.
SEE ALSO
devmap(9E), condvar(9F), devmap_umem_setup(9F), kmem_alloc(9F),
mutex(9F), rwlock(9F), semaphore(9F)
Writing Device Drivers in Oracle Solaris 11.4
WARNINGS
Setting the DDI_UMEM_PAGEABLE flag in ddi_umem_alloc() and
ddi_device_umem_alloc() will result in an allocation of pageable mem‐
ory. Because these pages can be swapped out to secondary memory
devices, drivers should use this flag with care. This memory must not
be used for the following purposes:
o For synchronization objects such as locks and condition
variables. See mutex(9F), semaphore(9F), rwlock(9F), and
condvar(9F).
o For driver interrupt routines.
Memory allocated using ddi_umem_alloc() and ddi_device_umem_alloc()
without setting DDI_UMEM_PAGEABLE flag cannot be paged. Available mem‐
ory is therefore limited by the total physical memory on the system. It
is also limited by the available kernel virtual address space, which is
often the more restrictive constraint on large-memory configurations.
Excessive use of kernel memory is likely to effect overall system per‐
formance. Over-commitment of kernel memory may cause unpredictable con‐
sequences.
Misuse of the kernel memory allocator, such as writing past the end of
a buffer, using a buffer after freeing it, freeing a buffer twice, or
freeing an invalid pointer, will cause the system to corrupt data or
panic.
Do not call ddi_umem_alloc() and ddi_device_umem_alloc() within
DDI_SUSPEND and DDI_RESUME operations. Memory acquired at these times
is not reliable. In some cases, such a call can cause a system to hang.
NOTES
ddi_umem_alloc(0, flag, cookiep) always returns NULL.
ddi_umem_free(NULL) has no effects on system.
Oracle Solaris 11.4 18 Dec 2014 ddi_umem_alloc(9F)