From: Hugh Dickins <hughd@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>,
Alistair Popple <apopple@nvidia.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Ralph Campbell <rcampbell@nvidia.com>,
Christoph Hellwig <hch@lst.de>, Yang Shi <shy828301@gmail.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Shakeel Butt <shakeelb@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 3/4] mm/rmap: fix new bug: premature return from page_mlock_one()
Date: Wed, 7 Jul 2021 13:11:24 -0700 (PDT) [thread overview]
Message-ID: <f71f8523-cba7-3342-40a7-114abc5d1f51@google.com> (raw)
In-Reply-To: <563ce5b2-7a44-5b4d-1dfd-59a0e65932a9@google.com>
In the unlikely race case that page_mlock_one() finds VM_LOCKED has been
cleared by the time it got page table lock, page_vma_mapped_walk_done()
must be called before returning, either explicitly, or by a final call
to page_vma_mapped_walk() - otherwise the page table remains locked.
Fixes: cd62734ca60d ("mm/rmap: split try_to_munlock from try_to_unmap")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/rmap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 0e83c3be8568..1235368f0628 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1990,14 +1990,13 @@ static bool page_mlock_one(struct page *page, struct vm_area_struct *vma,
* this function is never called when PageDoubleMap().
*/
mlock_vma_page(page);
+ /*
+ * No need to scan further once the page is marked
+ * as mlocked.
+ */
page_vma_mapped_walk_done(&pvmw);
+ return false;
}
-
- /*
- * no need to continue scanning other vma's if the page has
- * been locked.
- */
- return false;
}
return true;
--
2.26.2
next prev parent reply other threads:[~2021-07-07 20:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 20:06 [PATCH 1/4] mm/rmap: fix comments left over from recent changes Hugh Dickins
2021-07-07 20:08 ` [PATCH 2/4] mm/rmap: fix old bug: munlocking THP missed other mlocks Hugh Dickins
2021-07-07 20:53 ` Shakeel Butt
2021-07-08 13:58 ` Kirill A. Shutemov
2021-07-09 2:50 ` Hugh Dickins
2021-07-09 10:56 ` Kirill A. Shutemov
2021-07-07 20:11 ` Hugh Dickins [this message]
2021-07-07 20:22 ` [PATCH 3/4] mm/rmap: fix new bug: premature return from page_mlock_one() Shakeel Butt
2021-07-07 23:14 ` Alistair Popple
2021-07-07 20:13 ` [PATCH 4/4] mm/rmap: try_to_migrate() skip zone_device !device_private Hugh Dickins
2021-07-07 20:54 ` Shakeel Butt
2021-07-07 23:25 ` Alistair Popple
2021-07-07 20:22 ` [PATCH 1/4] mm/rmap: fix comments left over from recent changes Shakeel Butt
2021-07-07 21:26 ` Yang Shi
2021-07-07 21:29 ` Yang Shi
2021-07-07 23:34 ` Alistair Popple
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f71f8523-cba7-3342-40a7-114abc5d1f51@google.com \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=hch@lst.de \
--cc=jgg@nvidia.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rcampbell@nvidia.com \
--cc=shakeelb@google.com \
--cc=shy828301@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox