Commit bbfbb7ce authored by Nikita Danilov's avatar Nikita Danilov Committed by Linus Torvalds

[PATCH] find_lock_page(): call __lock_page() directly.

As find_lock_page() already checks with TestSetPageLocked() that page is
locked, there is no need to call lock_page() that will try-lock page again
(chances of page being unlocked in between are small).  Call __lock_page()
directly, this saves one atomic operation.

Also, mark truncate-while-slept path as unlikely while we are here.

(akpm: ug.  But this is actually a common path for normal old read()s against
a page which is under readahead I/O so ho-hum.)
Signed-off-by: default avatarNikita Danilov <danilov@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a226f6c8
...@@ -555,11 +555,12 @@ struct page *find_lock_page(struct address_space *mapping, ...@@ -555,11 +555,12 @@ struct page *find_lock_page(struct address_space *mapping,
page_cache_get(page); page_cache_get(page);
if (TestSetPageLocked(page)) { if (TestSetPageLocked(page)) {
read_unlock_irq(&mapping->tree_lock); read_unlock_irq(&mapping->tree_lock);
lock_page(page); __lock_page(page);
read_lock_irq(&mapping->tree_lock); read_lock_irq(&mapping->tree_lock);
/* Has the page been truncated while we slept? */ /* Has the page been truncated while we slept? */
if (page->mapping != mapping || page->index != offset) { if (unlikely(page->mapping != mapping ||
page->index != offset)) {
unlock_page(page); unlock_page(page);
page_cache_release(page); page_cache_release(page);
goto repeat; goto repeat;
......
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