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,9 +76,8 @@ void lru_add_drain(void) ...@@ -76,9 +76,8 @@ void lru_add_drain(void)
*/ */
void __page_cache_release(struct page *page) void __page_cache_release(struct page *page)
{ {
BUG_ON(page_count(page) != 0);
if (PageLRU(page)) {
unsigned long flags; unsigned long flags;
BUG_ON(page_count(page) != 0);
spin_lock_irqsave(&_pagemap_lru_lock, flags); spin_lock_irqsave(&_pagemap_lru_lock, flags);
if (TestClearPageLRU(page)) { if (TestClearPageLRU(page)) {
...@@ -90,7 +89,6 @@ void __page_cache_release(struct page *page) ...@@ -90,7 +89,6 @@ void __page_cache_release(struct page *page)
if (page_count(page) != 0) if (page_count(page) != 0)
page = NULL; page = NULL;
spin_unlock_irqrestore(&_pagemap_lru_lock, flags); spin_unlock_irqrestore(&_pagemap_lru_lock, flags);
}
if (page) if (page)
__free_pages_ok(page, 0); __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