Let's make it interesting now by not using a convenient rounded power-of-2 size as the requirement. This time, let's say that the device driver requests a memory chunk of size 132 KB. What will the buddy system allocator do? As, of course, it cannot allocate less memory than requested, it allocates more – you guessed it (see Figure 8.2), the next available memory chunk is on order 7, of size 256 KB. But the consumer (the driver) is only going to see and use the first 132 KB of the 256 KB chunk allocated to it. The remaining (124 KB) is wasted (think about it, that's close to 50% wastage!). This is called internal fragmentation (or wastage) and is the critical failing of the binary buddy system!
You will learn, though, that there is indeed a mitigation to this: a patch was contributed to deal with similar scenarios (via the alloc_pages_exact() / free_pages_exact() APIs). We will cover the APIs to...