gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 03:34:02 24 4
gpt4 key购买 nike

我正在了解 Linux 中的内存分配,并为我的实验对伙伴分配器 (__alloc_pages_nodemask) 进行了一些更改。我在 struct page->flags 中创建了一个新标志(通过在 page-flags.henum 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 buddyis up and running. The range allocator (e.g., alloc_contig_range()) issome kind of mechanism that builds up on top of the buddy. Otherallcoators (hugetlb, slab, ...) might cache some pages, buteffectively get "physical memory" either via memblock or the buddy.

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

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

关于c - 除了 linux 中的 buddy allocator 之外,是否有不同的内存分配路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67295524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com