Linux内存从0到1学习笔记(8.5,CMA内存分配)
Posted 高桐@BILL
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux内存从0到1学习笔记(8.5,CMA内存分配)相关的知识,希望对你有一定的参考价值。
CMA是通过cma_alloc分配的。cma_alloc() --> alloc_contig_range(..., MIGRATE_CMA,...),向刚才释放给buddy system的MIGRATE_CMA类型页面,重新“收集”过来。
linux_mainline-5.17.0/mm/cma.c
416 /**
417 * cma_alloc() - allocate pages from contiguous area
418 * @cma: Contiguous memory region for which the allocation is performed.
419 * @count: Requested number of pages.
420 * @align: Requested alignment of pages (in PAGE_SIZE order).
421 * @no_warn: Avoid printing message about failed allocation
422 *
423 * This function allocates part of contiguous memory on specific
424 * contiguous memory area.
425 */
426 struct page *cma_alloc(struct cma *cma, unsigned long count,
427 unsigned int align, bool no_warn)
428
429 unsigned long mask, offset;
430 unsigned long pfn = -1;
431 unsigned long start = 0;
432 unsigned long bitmap_maxno, bitmap_no, bitmap_count;
433 unsigned long i;
434 struct page *page = N
以上是关于Linux内存从0到1学习笔记(8.5,CMA内存分配)的主要内容,如果未能解决你的问题,请参考以下文章
Linux内存从0到1学习笔记(10.1 BugsShooter之cma配置过小导致页迁移繁忙而内存申请失败)
Linux内存从0到1学习笔记(6.4,物理内存初始化之预留内存)