除了linux中的buddy allocator,是否有不同的内存分配路径?

Is there a different memory allocation path other than the buddy allocator in linux?

我正在了解 Linux 中的内存分配,并为我的实验对伙伴分配器 (__alloc_pages_nodemask) 进行了一些更改。我在 struct page->flags 中创建了一个新标志(通过在 page-flags.h 中的 enum pageflags 中添加一个新标志。我在 __alloc_pages_nodemask 中永久设置了这个位(一旦设置就不会被清除并且在所有进一步的分配和释放中幸存下来。我修改 PAGE_FLAGS_CHECK_AT_PREP 以确保它)。但是我看不到预期的行为。

我猜这是因为 Linux 也使用了一些不同的路径来分配内存(可能在引导期间)。我的假设是否正确?

除了buddy allocator还有其他内存分配路径吗?我在哪里可以找到它?

我在内核邮件列表上问过这个问题。 David / dhildenb replied 他的回答很有帮助。

memblock is the early memory allocator during boot, before the buddy is up and running. The range allocator (e.g., alloc_contig_range()) is some kind of mechanism that builds up on top of the buddy. Other allcoators (hugetlb, slab, ...) might cache some pages, but effectively get "physical memory" either via memblock or the buddy.

CMA is another special-purpose allocator which reserves physical memory areas via memblock and then uses the range allocator to actually allocate memory inside these reserved regions at runtime.

可以在 mm/memblock.c 中找到 memblock 的完整文档和 API。