检查内存页是否加载到内存中

check if a memory page is loaded into memory

给定一个虚拟地址,我想知道映射到这个虚拟地址的内存页是否已经加载到内存或磁盘中。无论如何要在用户级程序中进行检查?我正在使用 CentOS 7。

您可以为此使用 mincore 系统调用。

mincore - determine whether pages are resident in memory

它会告诉您某个范围内的哪些页面在内存中,并且在访问时不需要磁盘 I/O。请注意,页面可能会在 mincore 返回和您访问它们之间被换出。