我正在探索Linux操作系统中的内存管理。内存管理单元(MMU)如何通知操作系统页表已更新?
据我所知,MMU是一个集成在现代CPU中的硬件来处理地址转换。如果虚拟地址不在TLB中,则MMO将首先通过页表基址寄存器(PTBR)获取进程页表的地址,然后从位于物理内存中的页表中检索物理地址。
我的问题是:由于操作系统负责页面替换,MMU如何通知操作系统物理页面已被访问或修改?我在Linux/mm/swap.c中看到一个函数。但我不确定是否每次更新页表时都会调用此函数。
void mark_page_accessed(struct page *page)
{
if (!PageActive(page) && !PageUnevictable(page) && PageReferenced(page)) {
/*
* If the page is on the LRU, queue it for activation via
* activate_page_pvecs. Otherwise, assume the page is on a
* pagevec, mark it active and it'll be moved to the active
* LRU on the next drain.
*/
if (PageLRU(page))
activate_page(page);
else
__lru_cache_activate_page(page);
ClearPageReferenced(page);
if (page_is_file_cache(page))
workingset_activation(page);
} else if (!PageReferenced(page)) {
SetPageReferenced(page);
}
}
我想MMU可能会修改页表的PTE标志。但是操作系统只有在操作系统执行页表行走时才会知道,对吗?而页面替换是在物理页面上执行的,物理页面上是否还有一些标志?我必须失去了一些东西真的很重要..
感谢