Skip to contentSkip to conversation

: find_lock_page(): call __lock_page() directly.

PATCH New Nikita Danilov 1 participant 1 message Nov 23, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : find_lock_page(): call __lock_page() directly.

Hello,

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.

Andrew, please apply.

Nikita.

 mm/filemap.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
mm/filemap.c renamed from mm/filemap.c~find_lock_page-use-__lock_page +3 -2
diff -puN mm/filemap.c~find_lock_page-use-__lock_page mm/filemap.c
@@ -555,11 +555,12 @@ repeat:
 		page_cache_get(page);
 		if (TestSetPageLocked(page)) {
 			read_unlock_irq(&mapping->tree_lock);
-			lock_page(page);
+			__lock_page(page);
 			read_lock_irq(&mapping->tree_lock);
 
 			/* 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);
 				page_cache_release(page);
 				goto repeat;

_