Commit 094ef1c9 authored by Chris Packham's avatar Chris Packham Committed by Jonathan Corbet

docs/core-api: memory-allocation: remove uses of c:func:

These are no longer needed as the documentation build will automatically
add the cross references.
Signed-off-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent ef8330fe
...@@ -88,10 +88,10 @@ Selecting memory allocator ...@@ -88,10 +88,10 @@ Selecting memory allocator
========================== ==========================
The most straightforward way to allocate memory is to use a function The most straightforward way to allocate memory is to use a function
from the :c:func:`kmalloc` family. And, to be on the safe side it's from the kmalloc() family. And, to be on the safe side it's best to use
best to use routines that set memory to zero, like routines that set memory to zero, like kzalloc(). If you need to
:c:func:`kzalloc`. If you need to allocate memory for an array, there allocate memory for an array, there are kmalloc_array() and kcalloc()
are :c:func:`kmalloc_array` and :c:func:`kcalloc` helpers. helpers.
The maximal size of a chunk that can be allocated with `kmalloc` is The maximal size of a chunk that can be allocated with `kmalloc` is
limited. The actual limit depends on the hardware and the kernel limited. The actual limit depends on the hardware and the kernel
...@@ -102,29 +102,26 @@ The address of a chunk allocated with `kmalloc` is aligned to at least ...@@ -102,29 +102,26 @@ The address of a chunk allocated with `kmalloc` is aligned to at least
ARCH_KMALLOC_MINALIGN bytes. For sizes which are a power of two, the ARCH_KMALLOC_MINALIGN bytes. For sizes which are a power of two, the
alignment is also guaranteed to be at least the respective size. alignment is also guaranteed to be at least the respective size.
For large allocations you can use :c:func:`vmalloc` and For large allocations you can use vmalloc() and vzalloc(), or directly
:c:func:`vzalloc`, or directly request pages from the page request pages from the page allocator. The memory allocated by `vmalloc`
allocator. The memory allocated by `vmalloc` and related functions is and related functions is not physically contiguous.
not physically contiguous.
If you are not sure whether the allocation size is too large for If you are not sure whether the allocation size is too large for
`kmalloc`, it is possible to use :c:func:`kvmalloc` and its `kmalloc`, it is possible to use kvmalloc() and its derivatives. It will
derivatives. It will try to allocate memory with `kmalloc` and if the try to allocate memory with `kmalloc` and if the allocation fails it
allocation fails it will be retried with `vmalloc`. There are will be retried with `vmalloc`. There are restrictions on which GFP
restrictions on which GFP flags can be used with `kvmalloc`; please flags can be used with `kvmalloc`; please see kvmalloc_node() reference
see :c:func:`kvmalloc_node` reference documentation. Note that documentation. Note that `kvmalloc` may return memory that is not
`kvmalloc` may return memory that is not physically contiguous. physically contiguous.
If you need to allocate many identical objects you can use the slab If you need to allocate many identical objects you can use the slab
cache allocator. The cache should be set up with cache allocator. The cache should be set up with kmem_cache_create() or
:c:func:`kmem_cache_create` or :c:func:`kmem_cache_create_usercopy` kmem_cache_create_usercopy() before it can be used. The second function
before it can be used. The second function should be used if a part of should be used if a part of the cache might be copied to the userspace.
the cache might be copied to the userspace. After the cache is After the cache is created kmem_cache_alloc() and its convenience
created :c:func:`kmem_cache_alloc` and its convenience wrappers can wrappers can allocate memory from that cache.
allocate memory from that cache.
When the allocated memory is no longer needed it must be freed. You can
When the allocated memory is no longer needed it must be freed. You use kvfree() for the memory allocated with `kmalloc`, `vmalloc` and
can use :c:func:`kvfree` for the memory allocated with `kmalloc`, `kvmalloc`. The slab caches should be freed with kmem_cache_free(). And
`vmalloc` and `kvmalloc`. The slab caches should be freed with don't forget to destroy the cache with kmem_cache_destroy().
:c:func:`kmem_cache_free`. And don't forget to destroy the cache with
:c:func:`kmem_cache_destroy`.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment