Commit 60bfa4f3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix YA bug in __page_cache_release

__page_cache_release() needs to check PG_lru inside the lock, because
page reclaim may have taken the page off the LRU while this CPU waits
on the lock.

That's three bugs in a single twenty-line function.  So far.
parent 0bf7d47d
......@@ -76,21 +76,19 @@ void lru_add_drain(void)
*/
void __page_cache_release(struct page *page)
{
unsigned long flags;
BUG_ON(page_count(page) != 0);
if (PageLRU(page)) {
unsigned long flags;
spin_lock_irqsave(&_pagemap_lru_lock, flags);
if (TestClearPageLRU(page)) {
if (PageActive(page))
del_page_from_active_list(page);
else
del_page_from_inactive_list(page);
}
if (page_count(page) != 0)
page = NULL;
spin_unlock_irqrestore(&_pagemap_lru_lock, flags);
spin_lock_irqsave(&_pagemap_lru_lock, flags);
if (TestClearPageLRU(page)) {
if (PageActive(page))
del_page_from_active_list(page);
else
del_page_from_inactive_list(page);
}
if (page_count(page) != 0)
page = NULL;
spin_unlock_irqrestore(&_pagemap_lru_lock, flags);
if (page)
__free_pages_ok(page, 0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment