Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x86 dirty bit in page table entry

The Intel Architecture manual says when there is first write access against a memory page, the CPU sets the dirty bit of the page table entry. I have questions regarding this issue.

1. The 'dirty bit' in this context is used for guaranteeing the correctness of disk swapping in, out of memory pages. is this correct?
2. Is this automatically performed by the hardware? or is this an implementation of operating system?
3. If it is automatically performed by the hardware, is there any noteworthy difference compared to the usual memory updates which are performed by software instructions?

Thank you in advance.

like image 644
daehee Avatar asked Feb 04 '14 07:02

daehee


1 Answers

1 The 'dirty bit' in this context is used for guaranteeing the correctness of disk swapping in, out of memory pages. is this correct?

This hardware part of paging support. This bit helps OS determine in very fast and efficcient way to determine which page must be dumped to disk. Because if memory page will page out to disk and there is already allocated space in page file we can don`t dump this page to disk if this flag are cleared. This is just example of way how OS can use this flag in paging.

2 Is this automatically performed by the hardware? or is this an implementation of operating system?

Software clears this flag. Hardware sets this flag:

3.7.6 Page-Directory and Page-Table Entries

Dirty (D) flag, bit 6

Indicates whether a page has been written to when set. (This flag is not used in page-directory entries that point to page tables.) Memory management software typically clears this flag when a page is initially loaded into physical memory. The processor then sets this flag the first time a page is accessed for a write operation.

.

3 If it is automatically performed by the hardware, is there any noteworthy difference compared to the usual memory updates which are performed by software instructions?

They have LOCK semantics and atomic.

like image 133
Evgenii Gostiukhin Avatar answered Sep 26 '22 05:09

Evgenii Gostiukhin