在内核启动时分配(静态)内存 [英] Allocating (statically) memory at kernel boot time

查看:115
本文介绍了在内核启动时分配(静态)内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与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缓冲区需要一个大尺寸,各为例的 jazzdma 模块和<一个href=\"https://github.com/dh-electronics/linux-imx6qdl/blob/a81067a2ce978f88e63b69d18b0d14a5b962be34/arch/mips/netlogic/common/nlm-dma.c\"相对=nofollow> 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

这篇关于在内核启动时分配(静态)内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆