Re: [问题] 关于vmalloc的问题

楼主: leolarrel (真.粽子无双)   2015-04-01 12:25:27
※ 引述《popd (QQ)》之铭言:
: 小弟对于linux kernel算初心者,关于vmalloc的解释有些地方不懂,还请高手解释
: void * vmalloc(unsigned long size)
: The function returns a pointer to at least size bytes of virtually contiguous
: memory. On error, the function returns NULL. The function might sleep, and
: thus cannot be called from interrupt context or other situations where
: blocking is not permissible.
: 我的问题是
: 为什么这个function会sleep? 什么样的情况会导致vmalloc进行sleep?
: 谢谢!
替你翻了一下google ...
请看此网页的最后面有关KMALLOC PK VMALLOC 的叙述
关键字在于GFP_KERNEL旗标,所以在kernel 中任何内存配置函数有用到
GFP_KERNEL 旗标的,全都有可能休眠
这可能是因为,目前内存的配置无法满足呼叫者的空间需求,但kernel会使用一些手法
来尽量满足呼叫者(例如把某些内存页搬到硬盘去之类的),这些手法可能跑在另一个
执行绪,或可能是一些控制硬件的指令什么的,所以得要将目前呼叫者的行程送去休眠
作者: aweilin   2015-04-28 22:11:00
所以就是为了要取得内存,作业系统去取得的这个过程中有可能会去睡觉

Links booklink

Contact Us: admin [ a t ] ucptt.com