mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
mm: allow GUP to fail instead of waiting on a page
GUP user may want to try to acquire a reference to a page if it is already in memory, but not if IO, to bring it in, is needed. For example KVM may tell vcpu to schedule another guest process if current one is trying to access swapped out page. Meanwhile, the page will be swapped in and the guest process, that depends on it, will be able to run again. This patch adds FAULT_FLAG_RETRY_NOWAIT (suggested by Linus) and FOLL_NOWAIT follow_page flags. FAULT_FLAG_RETRY_NOWAIT, when used in conjunction with VM_FAULT_ALLOW_RETRY, indicates to handle_mm_fault that it shouldn't drop mmap_sem and wait on a page, but return VM_FAULT_RETRY instead. [[email protected]: improve FOLL_NOWAIT comment] Signed-off-by: Gleb Natapov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Hugh Dickins <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: Michel Lespinasse <[email protected]> Cc: Avi Kivity <[email protected]> Cc: Marcelo Tosatti <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
5fda1bd5b8
commit
318b275fbc
3 changed files with 11 additions and 3 deletions
|
|
@ -621,8 +621,10 @@ int __lock_page_or_retry(struct page *page, struct mm_struct *mm,
|
|||
__lock_page(page);
|
||||
return 1;
|
||||
} else {
|
||||
up_read(&mm->mmap_sem);
|
||||
wait_on_page_locked(page);
|
||||
if (!(flags & FAULT_FLAG_RETRY_NOWAIT)) {
|
||||
up_read(&mm->mmap_sem);
|
||||
wait_on_page_locked(page);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue