简体   繁体   English

在Linux内核中取消映射“两次”映射的页面

[英]Unmapping a “twicely” mapped page in the Linux Kernel

I use kmap to get the first virtual address of a low-memory page, inside a Linux Kernel module. 我使用kmap获取Linux内核模块中低内存页面的第一个虚拟地址。

What happens if I call kunmap after that mapping? 如果在映射后调用kunmap会怎样? Is the persistent page mapping totally deleted or just some mapping counter is decreased? 永久页面映射是否已全部删除,或者只是减少了一些映射计数器? (should be 2 before the unmapping) (取消映射前应为2)

There is no mapping done by kmap if page belongs to low memory and hence there is no action done by kunmap too, but calling them is harmless as these checks are handled in there implementation. 如果页面属于低内存,则kmap不会执行任何映射,因此kunmap也不会执行任何操作,但是调用它们是无害的,因为这些检查在该实现中进行处理。

First about kmap 首先关于kmap

kmap checks if page is below highmem_start_page(ie lowmemory page) as pages from lowmem are already visible and do not need to be mapped. kmap检查页面是否低于highmem_start_page(即lowmemory页面),因为lowmem中的页面已经可见并且不需要映射。 If the page is already in low memory kmap simply returns the address of it. 如果页面已经在内存不足的地方,则kmap只需返回其地址即可。

Now about kunmap 现在关于坤图

kunmap checks if page is below highmem_start_page. kunmap检查页面是否低于highmem_start_page。 If it is, the page already exists in low memory and needs no further handling, hence nop. 如果是这样,则该页面已经存在于内存不足的情况下,不需要进一步处理,因此为nop。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM