Hi Matthew and Peter, I had a few questions to clarify my understanding of the page/swap cache. > There's a swap cache, but that's not the same thing as the page cache. My understanding of the swap cache comes from: 1) Understanding the Linux Kernel by Bovet and Cesati: “The swap cache is implemented by the page cache data structures and procedures ” and “Pages in the swap cache are stored as every other page in the page cache, with the following special treatment: • The mapping field of the page descriptor is set to NULL. • The PG_swapcache flag of the page descriptor is set. • The private field stores the swapped-out page identifier associated with the page” 2) Understanding the Linux Virtual Memory Manager by Mel Gorman: “The swap cache is purely conceptual because it is simply a specialization of the page cache. The first principal difference between pages in the swap cache rather than the page cache is that pages in the swap cache always use swapper space as their address space in page→mapping. The second difference is that pages are added to the swap cache with add to swap cache(), shown in Figure 11.3, instead of add to page cache().” I understand that those books are more than ten years old, but is what they write no longer the case? Is the swap cache mechanism not a specialization of the page cache, and, if not, how are they different? > Anonymous memory is not handled by the page cache. > Anonymous pages enter the storage stack via swap; they are > found in the page tables, sent to the swap cache and then written to > swap devices or swap files. This is for the case of swapping out anonymous memory, but what about anonymous memory that is allocated dynamically with malloc/mmap: where is this memory coming from? When mmap opens files, it maps a process address spaces to a region in the page cache for the file, does it not? Is this behavior not the same for allocating anonymous memory (minus dealing with a file)? I appreciate the help in clarifying this for me. wxz |