Re: Question on swapping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin Maletinsky wrote:
Hello,

I am looking at the swapping mechanism in Linux. I have read the relevant chapter 16 in 'Understanding the Linux Kernel' from Bovet&Cesati, and looked at the 2.2.18 kernel
source code. I still have the follwing question:

Function try_to_swap_out() [p. 481 in 'Understanding the Linux Kernel']:
If the page in question already belongs to the swap cache, the function performs no data transfer to the swap space on the disk (but only marks the page as swapped out).
The corresponding comment in the try_to_swap_out() functions states 'Is the page already in the swap cache? If so, ..... - it is already up-to-date on disk.
Understanding the Linux Kernel states on p. 482 'If the page belongs to the swap cache .... no memory transfer is performed'.
Now my question is, couldn't the page have been modified since it was added to the swap cache (and written to disk), and thus differ from the data in the swap space? In
this case shouldn't the page be written to disk (again)?
If the page is in the swap cache, it's *effectively* up to date on disk,
because the swap cache page is *the* authoritative image of the page.
If it's dirty it will get written out by page_launder() in short
order, because whomever dirtied it set the page_dirty bit in the
page struct. That issue is unimportant to the process doing the
swap_out, though - all it cares about is that the page is going
to be taken care of by the cache machinery.

Cheers,

-- Joe

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux