From 403d0082901ced8df24a09383ab45a0476264118 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 15 Mar 2019 11:26:07 -0700 Subject: [PATCH] UPSTREAM: filemap: add a comment about FAULT_FLAG_RETRY_NOWAIT behavior I thought Josef Bacik's patch to drop the mmap_sem was buggy, because when looking at the error cases, there was one case where we returned VM_FAULT_RETRY without actually dropping the mmap_sem. Josef had to explain to me (using small words) that yes, that's actually what we're supposed to do, and his patch was correct. Which not only convinced me he knew what he was doing and I should stop arguing with him, but also that I should add a comment to the case I was confused about. Bug: 124328118 Change-Id: I968005b3673da3adad843c2660111e9a70f98c26 Patiently-pointed-out-by: Josef Bacik Signed-off-by: Linus Torvalds (cherry picked from commit 8b0f9fa2e02dc95216577c3387b0707c5f60fbaf) Signed-off-by: Minchan Kim --- mm/filemap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 8364c77ea8fe..d290da2f6af0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2331,6 +2331,11 @@ static int lock_page_maybe_drop_mmap(struct vm_fault *vmf, struct page *page, if (trylock_page(page)) return 1; + /* + * NOTE! This will make us return with VM_FAULT_RETRY, but with + * the mmap_sem still held. That's how FAULT_FLAG_RETRY_NOWAIT + * is supposed to work. We have way too many special cases.. + */ if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT) return 0; -- 2.20.1