【发布时间】:2020-12-29 19:51:41
【问题描述】:
阅读Mel Gorman的书Understanding the Linux Virtual Memory Manager后,我有几个问题。 4.3 Process Address Space Descriptor 部分说 kernel threads never page fault or access the user space portion. The only exception is page faulting within the vmalloc space 。以下是我的问题。
-
kenrel 线程从不缺页:这是否意味着只有用户空间代码会触发缺页?如果调用了
kmalloc()或vmalloc(),会不会出现页面错误?我相信内核必须将这些映射到匿名页面。当执行对这些页面的写入时,会发生页面错误。我的理解正确吗? -
为什么内核线程不能访问用户空间?
copy_to_user()或copy_from_user()不这样做吗? -
Exception is page faulting within vmalloc space:这是否意味着vmalloc()会触发页面错误而kmalloc()不会?为什么kmalloc()不会出现页面错误?内核虚拟地址的物理帧不需要作为页表项保存吗?
【问题讨论】:
-
内核代码被锁定在内存中,所以不会出错。错误发生在页面被使用时,而不是在分配时。
标签: memory-management linux-kernel kernel page-fault