Добрый день.
Имеется Debian 10.1
С ядром 4.19.1
Собрал с
CONFIG_CMA=y
В аргументах ядра прописал
GRUB_CMDLINE_LINUX="cma=128MB"
Вывод dmesg | grep cma говорит что память зарезервирована
Но при вызове
__get_free_pages(GFP_KERNEL, 12)
возвращается 0.
Подскажите пожалуйста, что я мог упустить.
Здравствуйте, reider, Вы писали:
R>Но при вызове
R>R> __get_free_pages(GFP_KERNEL, 12)
R>
R> возвращается 0.
R>Подскажите пожалуйста, что я мог упустить.
https://www.oreilly.com/library/view/linux-device-drivers/0596000081/ch07s03.html
The flags argument works in the same way as with kmalloc; usually either GFP_KERNEL or GFP_ATOMIC is used, perhaps with the addition of the __GFP_DMA flag (for memory that can be used for direct memory access operations) or __GFP_HIGHMEM when high memory can be used. order is the base-two logarithm of the number of pages you are requesting or freeing (i.e., log2 N). For example, order is 0 if you want one page and 3 if you request eight pages. If order is too big (no contiguous area of that size is available), the page allocation will fail. The maximum value of order was 5 in Linux 2.0 (corresponding to 32 pages) and 9 with later versions (corresponding to 512 pages: 2 MB on most platforms). Anyway, the bigger order is, the more likely it is that the allocation will fail.
Сейчас, кажется, 10 (
MAX_PAGE_ORDER). Но может зависеть от архитектуры, лень проверять.
Но есть вот такая статья:
https://lkml.org/lkml/2011/7/20/45
И кажется, правильная функция называется
alloc_contig_pages().
Но дальше уж сам