Forced Writeback

The above mechanisms for writing back pages as a background activity function very well when system load is not too high. The kernel is able to ensure that the number of dirty pages never gets out of hand and that there is an adequate exchange of data between RAM and the underlying block devices. However, this situation changes when the cached data of one or two processes quickly become dirty, thus necessitating more synchronization operations than can be handled by normal methods.

When the kernel receives an urgent request for memory and cannot satisfy it because of the very large number of dirty pages, it must try to transfer the page contents to the block device as quickly as possible to free RAM for other purposes. The same methods are used as for flushing data in the background, but in this case, synchronization is not initiated by periodic processes but is triggered explicitly by the kernel — in other words, writeback is ''forced.''

The request for immediate synchronization may originate not only from the kernel but also from userspace. The familiar sync command (and the corresponding sync system call) instructs the kernel to flush all dirty data to the block devices. Other system calls also provided by the kernel for this purpose are described in Section 17.14.

Synchronization is based on wakeup_pdflush, which is implemented in mm/page-writeback.c. The number of pages to be flushed is passed as a parameter:

Continue reading here: Mmpagewritebackc

Was this article helpful?

0 0