Pages that are only on the lru but not reference by anyone are of no
use and we want to free them immediatly. If we leave them on the lru
list with a page count of 1, someone else will have to walk the lru
list and remove pages that are only on the lru. One could argue that
try_to_free_pages could do this but try_to_free_pages will process the
pages in lru order and push out other pages first.
The next suggestion that comes to mind is: Let's have some magic in
page_cache_release that will remove the page from the lru list if
it is actually dead. However, this raises the question: How do we detect
that a page is now dead? The answer is something along the lines of
if (put_page_testzero ()) {
__free_pages_ok (page);
return
}
spin_lock_irq(pagemap_lru_lock);
if (PageLRU(page) && (page_count(page) == 1)) {
lru_cache_del (page);
spin_unlock_irq(pagemap_lru_lock);
page_cache_release (page);
return;
}
spin_unlock_irq(pagemap_lru_lock);
return;
The sad truth is, that this solution has all the same races that
we have now, plus it makes the fast path (decreasing page count
to something not zero) slower. One problem in the above would be
that the last reference might as well not be due the the lru
cache, i.e at the time we call PageLRU(page) the page might
have been freed by another processor.
I know the idea is appealing (see one of my earlier Mails on the
subject ;-) ) but it doesn't solve the Problem.
regards Christian Ehrhardt
-- THAT'S ALL FOLKS! - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/