kmalloc family allocation

kmalloc is a kernel memory allocation function, such as malloc() in user space. Memory returned by kmalloc is contiguous in physical memory and in virtual memory:

The kmalloc allocator is the general and higher-level memory allocator in the kernel, which relies on the SLAB allocator. Memory returned from kmalloc has a kernel logical address because it is allocated from the LOW_MEM region, unless HIGH_MEM is specified. It is declared in <linux/slab.h>, which is the header to include when using kmalloc in your driver. The following is the prototype:

void *kmalloc(size_t size, int flags); 

size specifies the size of ...

Get Linux Device Drivers Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.