Neh*_*ani 13 memory linux swap virtual-memory linux-kernel
请注意,此问题仅针对linux。而到swap space,我指的是专用的swap partition。
我google在这方面做了一点,发现了这些definitions:
Paging refers to writing portions, termed pages, of a process’ memory to disk.
Swapping, strictly speaking, refers to writing the entire process, not just part, to disk.
In Linux, true swapping is exceedingly rare, but the terms paging and swapping
often are used interchangeably.
Run Code Online (Sandbox Code Playgroud)
和
page-out: The system's free memory is less than a threshold "lotsfree" and unnused / least used pages are moved to the swap area.
page-in: One process which is running requested for a page that is not in the current memory (page-fault), it's pages are being brought back to memory.
swap-out: System is thrashing and has deactivated a process and it's memory pages are moved into the swap area.
swap-in: A deactivated process is back to work and it's pages are being brought into the memory.
Run Code Online (Sandbox Code Playgroud)
现在,您可能想与询问分页和交换之间差异的问题重复这个问题。但我寻求更多。在任何时候,这些计数器是否/proc/vmstat相互排斥?我的意思是,该参数是否pswpin包含一些计数,pgpgin反之亦然?当一个过程发生时究竟发生了deactivated什么?如果它的所有页面都移动到swap空间,那么它与 multiple 有什么不同pageouts?此外,如果pagein每当发生页面错误时都会发生 a,那么关于其他两个参数pgmajfault以及pgfault与此事件相关的内容可以说些什么?是不是每当apagefault (major? minor?)发生时,相应的pagein也发生?
如果建议使用一些示例程序/基准测试来测试这些单独的参数,将会很有帮助。
PS:我可能会继续添加/编辑问题:)
这么老的问题,到目前为止还没有正确的答案。
首先,内存被 CPU 和内核分割成所谓的页面。页面大小由 CPU 架构给出,许多架构支持多种不同的页面大小,但 x86_64 架构中最常见的页面大小为 4KB。您谈论的这些参数显示了有多少内存页面被读取/写入磁盘以及其中有多少是交换的。
请记住,page in是 Linux 内核中的正常活动,几乎每次当您将二进制文件(未缓存)从磁盘加载到操作内存中时都会发生这种情况 - 即每次启动任何应用程序时。
由于 pgin 和 pgout 操作并不总是您需要担心的事情,因此创建了仅包含交换信息的其他计数器 - 即 pswpin 和 pswpout 计数器 - 当内存页面写入交换或读取时,它们会增加交换。
同样 - 这也不表示有问题,它仅表示在某些情况下有问题 - 例如当您看到这些数字在短时间内发生很大变化时(通常是当您的系统内存不足时)。
所以简而言之:
小智 0