Conversation
Edited 1 year ago
When there are no free pages in free list of the requested order, buddy allocator splits a larger page into smaller ones, and allocates a one of the split pages.

TIL: The way buddy splits large pages (and allocating first or last part of a large page) during the expand() function significantly impacts the mergability of the scatter-gather list for IO. The likeliness that pages are allocated in PFN order is important for mergability. This is so subtle and I didn't realize this :(

Consider a scenario where there is only an order 2 block, and four order 0 requests are served. In the diagram above, they are allocated in PFN order, while in the other diagram, they are allocated in the reverse order.

https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=c75b81a5da09be94099cf7b46bdb32fedc8ce71a

And in the history this thing has introduced a regression because the order was not preserved (by mistake) when pages are allocated from PCP lists with __GFP_COLD ;)

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e084b2d95e48b31aa45f9c49ffc6cdae8bdb21d4
0
0
1