Waiting on Pages

The kernel often needs to wait on pages until their status has changed to some desired value. The synchronization implementation, for instance, sometimes wants to ensure that writing back a page has been finished and the contents in memory are identical with the data on the underlying block device. Pages under writeback have the PG_writeback bit set.

The function wait_on_page_writeback is provided to wait until the bit disappears: <pagemap.h>

static inline void wait_on_page_writeback(struct page *page) {

if (PageWriteback(page))

wait_on_page_bit(page, PG_writeback);

wait_on_page_bit installs a wait queue on which the process can sleep until the PG_writeback bit is removed from the page flags.

Likewise, the need to wait for a page to become unlocked can arise. wait_on_page_locked is responsible to handle this case.

Continue reading here: Operations with Whole Pages

Was this article helpful?

0 0