Re: page_launder() bug

Mikulas Patocka
2001-05-08T12:34:35Z

> > My point is that its _ok_ for us to check if the page is a dead swap cache
> > page _without_ the lock since writepage() will recheck again with the page
> > _locked_. Quoting you two messages back:
> >
> > "But it is important to re-calculate the deadness after getting the lock.
> > Before, it was just an informed guess. After the lock, it is knowledge."
> >
> > See ?
>
> In fact my patch isn't changing writepage behavior wrt. that page, it
> is changing behavior with respect to laundering policy for that page.
>
> Here, let's talk code a little bit so there are no misunderstandings,
> I really want to put this to rest:
>
> + int dead_swap_page;
> +
> page = list_entry(page_lru, struct page, lru);
>
> + dead_swap_page =
> + (PageSwapCache(page) &&
> + page_count(page) == (1 + !!page->buffers));
> +
>
> Calculate dead_swap_page outside of lock.
>
> /* Page is or was in use? Move it to the active list. */
> - if (PageTestandClearReferenced(page) || page->age > 0 ||
> - (!page->buffers && page_count(page) > 1) ||
> - page_ramdisk(page)) {
^^^^^^^^^^^^^^^^^
> + if (!dead_swap_page &&
> + (PageTestandClearReferenced(page) || page->age > 0 ||
> + (!page->buffers && page_count(page) > 1) ||
> + page_ramdisk(page))) {
^^^^^^^^^^^^^^^^^^^^^^
> del_page_from_inactive_dirty_list(page);
> add_page_to_active_list(page);
> continue;

#define page_ramdisk(page) \
(page->buffers && (MAJOR(page->buffers->b_dev) == RAMDISK_MAJOR))

Are you sure that no one will release buffers under your hands?

Mikulas