Quick Reference
The functions and symbols related to memory allocation follow.
-
#include <linux/malloc.h>,void *kmalloc(size_t size, int flags);,void kfree(void *obj); The most frequently used interface to memory allocation.
-
#include <linux/mm.h>,GFP_KERNEL,GFP_ATOMIC,__GFP_DMA,__GFP_HIGHMEM kmalloc flags.
__GFP_DMAand__GFP_HIGHMEMare flags that can be OR’d to eitherGFP_KERNELorGFP_ATOMIC.-
#include <linux/malloc.h>,kmem_cache_t *kmem_cache_create(char *name, size_t size, size_t offset, unsigned long flags, constructor(), destructor());,int kmem_cache_destroy(kmem_cache_t *cache); Create and destroy a slab cache. The cache can be used to allocate several objects of the same size.
-
SLAB_NO_REAP,SLAB_HWCACHE_ALIGN,SLAB_CACHE_DMA Flags that can be specified while creating a cache.
-
SLAB_CTOR_ATOMIC,SLAB_CTOR_CONSTRUCTOR Flags that the allocator can pass to the constructor and the destructor functions.
-
void *kmem_cache_alloc(kmem_cache_t *cache, int flags);,void kmem_cache_free(kmem_cache_t *cache, const void *obj); Allocate and release a single object from the cache.
-
unsigned long get_zeroed_page(int flags);,unsigned long __get_free_page(int flags);,unsigned long __get_free_pages(int flags, unsigned long order);,unsigned long __get_dma_pages(int flags, unsigned long order); The page-oriented allocation functions. get_zeroed_page returns a single, zero-filled page. All the other versions of the call ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access