Get the latest tech news
Looking at kmalloc() and the SLUB Memory Allocator (2019)
Recently I was asked to do some homework to prepare for an interview on Linux kernel internals, and I was given the following to analyse: Specifically, we would like you to study and be able to discuss the code path that is exercised when a kernel caller allocates an object from the kernel memory allocator using a call of the form: object = kmalloc(sizeof(*object), GFP_KERNEL); For this discussion, assume that (a) sizeof(*object) is 128, (b) there is no process context associated with the allocation, and (c) we’re referencing an Ubuntu 4.4 series kernel, as found at git://kernel.ubuntu.com/ubuntu/ubuntu-xenial.git In addition, we will discuss the overall architecture of the SLUB allocator and memory management in the kernel, and the specifics of the slab_alloc_node() function in mm/slub.c. I spent quite a lot of time, maybe 8-10 hours, studying how the SLUB memory allocator functions, and looking at the implementation of kmalloc().
None
Or read this on Hacker News