{"id":461,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:40","modified_gmt":"2020-08-22T20:26:40","slug":"this-is-the-page-title-toplevel-294","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=461","title":{"rendered":"The Swap Cache"},"content":{"rendered":"\n<title>The Swap Cache<\/title>\n<p>\nWhen swapping pages out to the swap files, Linux avoids writing pages if it does not have to.\nThere are times when a page is both in a swap file and in physical memory.\nThis happens when a page that was swapped out of memory was then brought back into memory when it was\nagain accessed by a process.\nSo long as the page in memory is not written to, the copy in the swap file remains valid.\n<p>\nLinux uses the swap cache to track these pages.\nThe swap cache is a list of page table entries, one per physical page in the system.\nThis is a page table entry for a swapped out page and describes which swap file the page is being\nheld in together with its location in the swap file.\nIf a swap cache entry is non-zero, it represents a page which is being held in  a swap\nfile that has not been modified.\nIf the page is subsequently modified (by being written to), its entry is removed from the swap cache.\n<p>\nWhen Linux needs to swap a physical page out to a swap file it consults the swap cache and,\nif there is a valid entry for this page, it does not need to write the page out to the\nswap file.\nThis is because the page in memory has not been modified since it was last read from the\nswap file.\n<p>\nThe entries in the swap cache are page table entries for swapped out pages.\nThey are marked as invalid but contain information which allow Linux to find the right\nswap file and the right page within that swap file.\n<p>\n","protected":false},"excerpt":{"rendered":"<p>The Swap Cache When swapping pages out to the swap files, Linux avoids writing pages if it does not have to. There are times when a page is both in a swap file and in physical memory. This happens when &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=461\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-461","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=461"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/461\/revisions"}],"predecessor-version":[{"id":758,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/461\/revisions\/758"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}