问题描述
我与Linux内核工作,想静在启动时(在内核空间),这将在稍后由内核调度目的使用分配的子页面大小的数组。任何人都可以请点我最好的方式做到这一点?
I am working with the Linux kernel and would like allocate an array of sub page size statically at boot time (in kernel space), which will later be used by the kernel for scheduling purposes. Could anyone please point me in the best manner to do this?
此存储器从未被明确除了隐含在端(停机)操作系统的正常执行期间释放
This memory is never to be explicitly freed during the normal execution of the operating system except implicitly at the end (shutdown).
我已经知道 alloc_bootmem()
,但我想知道的/探索其他可能性为好。这将是真正伟大的,如果有人可以点我的code的一个片段,它使用内存已经存在于Linux内核类似的方式。
I am already aware of alloc_bootmem()
but I would like to know of/explore other possibilities as well. It would be really great if someone could point me to a snippet of code which uses memory in a similar manner that already exists in the Linux kernel.
推荐答案
一些内核模块都使用这种技术来分配DMA缓冲区需要一个大尺寸,各为例的模块和 NLM-DMA模块
Some kernel modules are using this technique to allocate DMA Buffer when a large size is needed, for exemple jazzdma module and nlm-dma module
请注意,如果您使用的是启动时的内存分配器为DMA目的,你必须用
Note that if you are using boot time memory allocator for dma purpose you must use
void *alloc_bootmem_low_pages(unsigned long size);
而不是
无效* alloc_bootmem_pages(无符号长大小);
由于DMA可以存取权限只有低内存类型
because DMA can acces only low memory type
这篇关于在内核启动时分配(静态)内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!