Re: usage of the dirty bit in the pte

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

 



On Thu, Jan 30, 2003 at 10:08:43AM +0530, MAASK Group wrote:
>   From what knowledge I have, the dirty bit in the page table entry of a 
> page is used to indicate whether the page has been modified. I suppose its 
> usage is for knowing if this page has been written to the buffer cache (to 
> be written to the disk later), before swapping it out. But this is in case 
> of pages to be read/written to the I/O. What is the use of the dirty bit in 
> case of shared memory? I saw that the swapper wont swap out dirty pages and 
> thus doesnt swap out the shared memory pages which is needed. Is there any 
> other use pf the dirty buit in case shared memory pages? Correct me if I am 
> wrong anywhere here!!

Generaly speaking, buffer cache is specific to block device access and
other filesystems (eq. network) do without it. It does not matter from
the perspective of the page cache. A page in page cache either belongs
to a file or is anonymous (and thus belongs to swap). If it belongs to
a file and is dirty too long, it's writepage method is called to flush
it to disk. If some pages are needed, the least recently used page is
taken and if it's dirty, it's writepage method is called. Then is
cleaned and reused - that is, if it's clean, it's simply forgoten,
because it exists somewhere.

As for not swaping used pages, another technique is used. Kernel walks
the pages, copies dirty bits to page structs (not all pages in page
cache have PTE - only those mmaped) and marks the pages unmapped. When
such a page is accessed, a minor page fault occurs and it's simply
marked mapped again. When it's not accessed for some time, it's swapped
out (by the rule above - if it's dirty, it's writen, else simply
discarded). Some architectures have an access bit in addition to dirty
bit, so unmaping is not needed - kernel just checks if the accessed bit
wasn't set within some period of time.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
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