作者:沉沦850 | 来源:互联网 | 2023-05-29 21:36
根据mlock()手册页:Allpagesthatcontainapartofthespecifiedaddressrangeareguaranteedtoberesidentin
根据mlock()手册页:
All pages that contain a part of the specified address range are
guaranteed to be resident in RAM when the call returns successfully;
the pages are guaranteed to stay in RAM until later unlocked.
这是否也能保证这些页面的物理地址在其整个生命周期内保持不变,或者直到解锁?
如果不是(也就是说,如果它可以由内存管理器移动 – 但仍然保留在RAM中),是否有关于新位置或发生此类更改的事件可以说什么?
更新:
关于RAM中锁定页面的一致性,可以说些什么吗?如果CPU有缓存,那么mlocking是否保证RAM与缓存的一致性(假设回写缓存)?
解决方法:
否.已经冻结的页面使用内核的不可修复的LRU列表进行管理.顾名思义(和mlock()保证)这些页面不能从RAM中逐出.但是,页面可以从一个物理页面帧迁移到另一个.以下是Unevictable LRU Infrastructure的摘录(为清晰起见添加了格式):
MIGRATING MLOCKED PAGES
A page that is being migrated has been isolated from the LRU lists and is held locked across unmapping of the page, updating the page’s address space entry and copying the contents and state, until the page table entry has been replaced with an entry that refers to the new page. Linux supports migration of mlocked
pages and other unevictable pages. This involves simply moving the PG_mlocked
and PG_unevictable
states from the old page to the new page.