Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Linux:</p> <p>When swap file is used the Page Table Entry gets updated with one marked as invalid and holding information about where it is saved in the swap file. That is: an index to the <code>swap_info</code> array and an offset within the <code>swap_map</code>.</p> <p>Example from (an a bit old) Page Table Entry type (<code>pte_t</code>) on a x86. Some of the bits are used as flags by the hardware:</p> <pre><code>Bit Function _PAGE_PRESENT Page is resident in memory and not swapped out _PAGE_PROTNONE Page is resident but not accessable _PAGE_RW Set if the page may be written to _PAGE_USER Set if the page is accessible from user space _PAGE_DIRTY Set if the page is written to _PAGE_ACCESSED Set if the page is accessed </code></pre> <p><sup><a href="https://www.kernel.org/doc/gorman/html/understand/understand006.html#toc19" rel="nofollow noreferrer">Table 3.1: Page Table Entry Protection and Status Bits</a></sup></p> <p>See also <a href="https://stackoverflow.com/questions/46509152/why-in-64bit-the-virtual-address-are-4-bits-short-48bit-long-compared-with-the/46510887#46510887">another SO answer</a> with a diagram of the x86-64 page table format. When the low bit = 0, the hardware ignores <em>all</em> the other bits, so the kernel can use them for anything. Even in a "present" entry, there are some guaranteed-ignored bits that aren't reserved for future hardware use, so the kernel can use them for its own purposes.</p> <p>Presumably other architectures are similar.</p> <hr> <p>In simple terms: A process points to a page, the page get updated. Thus the processes are, in effect, also updated. When the physical page get requested it is swapped in and thus all processes as well. The point being that the Page Table Entry is not removed when memory is swapped out.</p> <p>You might find some of this useful: </p> <ul> <li>Gustavo Duarte: <a href="http://duartes.org/gustavo/blog/post/how-the-kernel-manages-your-memory" rel="nofollow noreferrer">How The Kernel Manages Your Memory</a>.</li> </ul> <p>The <a href="https://www.kernel.org/doc/gorman/" rel="nofollow noreferrer">kernel documentation included book of Mel Gorman</a> (2007):</p> <ul> <li><a href="https://www.kernel.org/doc/gorman/html/understand/understand014.html#toc74" rel="nofollow noreferrer">11.2 Mapping Page Table Entries to Swap Entries</a></li> <li><p><a href="https://www.kernel.org/doc/gorman/html/understand/understand006.html#toc19" rel="nofollow noreferrer">3.2 Describing a Page Table Entry</a> </p></li> <li><p>Red Hat on VM's <a href="http://www.redhat.com/magazine/001nov04/features/vm/#life-page" rel="nofollow noreferrer">Life of a page</a>.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload