The following conceptual diagram shows us the Linux kernel's memory allocation layers as well as the prominent APIs within them; note the following:
- Here we only show the (typically used) APIs exposed by the kernel to module/driver authors (with the exception being the one that ultimately performs the allocations – the __alloc_pages_nodemask() API right at the bottom!).
- For brevity, we haven't shown the corresponding memory-freeing APIs.
The following is a diagram showing several of the (exposed to module / driver authors) kernel memory allocation APIs:
Figure 9.6 – Conceptual diagram showing the kernel's memory allocation API set (for module / driver authors)
Now that you have seen the wealth of (exposed) memory allocation APIs available, the following sections delve into helping you make the right decision as to which to use under what circumstances.