diff options
author | Michel Lespinasse <walken@google.com> | 2010-10-26 17:21:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:09 -0400 |
commit | d065bd810b6deb67d4897a14bfe21f8eb526ba99 (patch) | |
tree | f58c59075732ec4ccba336278c9bdc7ff61bef94 /include/linux/pagemap.h | |
parent | b522c94da5d9cbc73f708be5e530ebc3bbd4a031 (diff) |
mm: retry page fault when blocking on disk transfer
This change reduces mmap_sem hold times that are caused by waiting for
disk transfers when accessing file mapped VMAs.
It introduces the VM_FAULT_ALLOW_RETRY flag, which indicates that the call
site wants mmap_sem to be released if blocking on a pending disk transfer.
In that case, filemap_fault() returns the VM_FAULT_RETRY status bit and
do_page_fault() will then re-acquire mmap_sem and retry the page fault.
It is expected that the retry will hit the same page which will now be
cached, and thus it will complete with a low mmap_sem hold time.
Tests:
- microbenchmark: thread A mmaps a large file and does random read accesses
to the mmaped area - achieves about 55 iterations/s. Thread B does
mmap/munmap in a loop at a separate location - achieves 55 iterations/s
before, 15000 iterations/s after.
- We are seeing related effects in some applications in house, which show
significant performance regressions when running without this change.
[akpm@linux-foundation.org: fix warning & crash]
Signed-off-by: Michel Lespinasse <walken@google.com>
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Cc: Ying Han <yinghan@google.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: "H. Peter Anvin" <hpa@zytor.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/pagemap.h')
-rw-r--r-- | include/linux/pagemap.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index e12cdc6d79ee..2d1ffe3cf1ee 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
@@ -299,6 +299,8 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma, | |||
299 | extern void __lock_page(struct page *page); | 299 | extern void __lock_page(struct page *page); |
300 | extern int __lock_page_killable(struct page *page); | 300 | extern int __lock_page_killable(struct page *page); |
301 | extern void __lock_page_nosync(struct page *page); | 301 | extern void __lock_page_nosync(struct page *page); |
302 | extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, | ||
303 | unsigned int flags); | ||
302 | extern void unlock_page(struct page *page); | 304 | extern void unlock_page(struct page *page); |
303 | 305 | ||
304 | static inline void __set_page_locked(struct page *page) | 306 | static inline void __set_page_locked(struct page *page) |
@@ -351,6 +353,17 @@ static inline void lock_page_nosync(struct page *page) | |||
351 | } | 353 | } |
352 | 354 | ||
353 | /* | 355 | /* |
356 | * lock_page_or_retry - Lock the page, unless this would block and the | ||
357 | * caller indicated that it can handle a retry. | ||
358 | */ | ||
359 | static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm, | ||
360 | unsigned int flags) | ||
361 | { | ||
362 | might_sleep(); | ||
363 | return trylock_page(page) || __lock_page_or_retry(page, mm, flags); | ||
364 | } | ||
365 | |||
366 | /* | ||
354 | * This is exported only for wait_on_page_locked/wait_on_page_writeback. | 367 | * This is exported only for wait_on_page_locked/wait_on_page_writeback. |
355 | * Never use this directly! | 368 | * Never use this directly! |
356 | */ | 369 | */ |