From patchwork Mon Feb 24 20:30:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11401501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73C9014BC for ; Mon, 24 Feb 2020 20:31:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3740320675 for ; Mon, 24 Feb 2020 20:31:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QMfYuCn7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3740320675 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E72236B0087; Mon, 24 Feb 2020 15:31:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFAF16B0089; Mon, 24 Feb 2020 15:31:23 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC1326B0088; Mon, 24 Feb 2020 15:31:23 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id B27B06B0085 for ; Mon, 24 Feb 2020 15:31:23 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 66A5A2C1F for ; Mon, 24 Feb 2020 20:31:23 +0000 (UTC) X-FDA: 76526165646.01.magic32_29297c6abe342 X-Spam-Summary: 2,0,0,4126785ebc6e7385,d41d8cd98f00b204,3mtjuxgykceg6kvuoxqyyqvo.mywvsx47-wwu5kmu.y1q@flex--walken.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3152:3353:3865:3868:3870:3874:4321:4605:5007:6120:6261:6653:7875:9969:10004:10400:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:14096:14097:14181:14659:14721:21080:21324:21444:21451:21627:21987:21990:30054:30070,0,RBL:209.85.210.201:@flex--walken.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: magic32_29297c6abe342 X-Filterd-Recvd-Size: 5720 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 20:31:22 +0000 (UTC) Received: by mail-pf1-f201.google.com with SMTP id e62so7348085pfh.14 for ; Mon, 24 Feb 2020 12:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+JA2qwc0R/ciNtk09Rc6YopHqSf0rXHoT6sEXSMUQlE=; b=QMfYuCn7zNIzjwufOIljrq4tEKi2/zfJm3JlWhDXcAf5xL94ObUCxaWwfsZk1UsrCW lja3zlVxLKMzBcTm6iod0nGE0ijWTAJsU1xNGnNjd44dGurYrgSyeSRHwclk7k4anLYc NU2o1F73xcdxi8yVchGrDhrADdmuxLvdj9OsHVYUIq7dyaUllX9AAkQ1coojElxMUfCb 5KXXCkA/imiCXeUoJ+a/fFrijYp6xCH5m3bKtStiRO7j8IjJoJYecbKt7opzAEBx2+e9 T+ttdjt+lT/PJ24rbkUofYdmfgsfz3kEpjJxetUdVIv1VBmAUM88AYEMpYC5YpG8AzO+ sIYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+JA2qwc0R/ciNtk09Rc6YopHqSf0rXHoT6sEXSMUQlE=; b=VuuSGF93xvAqYd6FaLN1utgDDmWQe/8E0x8eOEjDNocnzmBxBscaNd9QsYUicBbNSH B1e90aEa7UFMauRHzsu3+M6E9No7vRZeX4NQD4YGKnJfIPiGa5QDrgwIX+Nu2pMhQ/a1 /YPO87bBtLXYb5snaxVXr65YD2ALdBlv7CpA2zOdpuQHTaRhhGQHxSDxGoAxH9QA9dJI 6vu1yinQOx8fKRFZfI8mecygEHio+Cb7MROOl2nEH8b5eXjGdSQz0JFs80IfQvMXC4NU GnLv7PVYjGOBRovKc8wsFLfy+/hWSWg04120on9wYWSkDZDS9G82brDhEagYKiJyxq8e 4w7g== X-Gm-Message-State: APjAAAX6ghEeeM8xmbaT2dQfNtXexziUfLo6g6Sv2I/2+3pmGKgXXO7N RngpUgDzAuNnWkQ1oY1/ZHN1OXH5p2c= X-Google-Smtp-Source: APXvYqz9z3aNu18q330XbChmm/61WU7pOIGBqex1ElbGzXJwB2V7s1EZ7nA4A6HQ0V7XygMh998rviIgA2A= X-Received: by 2002:a63:d94d:: with SMTP id e13mr53390723pgj.240.1582576281731; Mon, 24 Feb 2020 12:31:21 -0800 (PST) Date: Mon, 24 Feb 2020 12:30:42 -0800 In-Reply-To: <20200224203057.162467-1-walken@google.com> Message-Id: <20200224203057.162467-10-walken@google.com> Mime-Version: 1.0 References: <20200224203057.162467-1-walken@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [RFC PATCH 09/24] do_swap_page: use the vmf->range field when dropping mmap_sem From: Michel Lespinasse To: Peter Zijlstra , Andrew Morton , Laurent Dufour , Vlastimil Babka , Matthew Wilcox , "Liam R . Howlett" , Jerome Glisse , Davidlohr Bueso , David Rientjes Cc: linux-mm , Michel Lespinasse X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Change do_swap_page() and lock_page_or_retry() so that the proper range will be released when swapping in. Signed-off-by: Michel Lespinasse --- include/linux/pagemap.h | 7 ++++--- mm/filemap.c | 6 +++--- mm/memory.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git include/linux/pagemap.h include/linux/pagemap.h index 37a4d9e32cd3..93520477c481 100644 --- include/linux/pagemap.h +++ include/linux/pagemap.h @@ -458,7 +458,7 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma, extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); extern int __lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags); + unsigned int flags, struct mm_lock_range *range); extern void unlock_page(struct page *page); /* @@ -501,10 +501,11 @@ static inline int lock_page_killable(struct page *page) * __lock_page_or_retry(). */ static inline int lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags) + unsigned int flags, struct mm_lock_range *range) { might_sleep(); - return trylock_page(page) || __lock_page_or_retry(page, mm, flags); + return trylock_page(page) || __lock_page_or_retry(page, mm, flags, + range); } /* diff --git mm/filemap.c mm/filemap.c index eb6487065ca0..3afb5a3f0b9c 100644 --- mm/filemap.c +++ mm/filemap.c @@ -1406,7 +1406,7 @@ EXPORT_SYMBOL_GPL(__lock_page_killable); * with the page locked and the mmap_sem unperturbed. */ int __lock_page_or_retry(struct page *page, struct mm_struct *mm, - unsigned int flags) + unsigned int flags, struct mm_lock_range *range) { if (flags & FAULT_FLAG_ALLOW_RETRY) { /* @@ -1416,7 +1416,7 @@ int __lock_page_or_retry(struct page *page, struct mm_struct *mm, if (flags & FAULT_FLAG_RETRY_NOWAIT) return 0; - mm_read_unlock(mm); + mm_read_range_unlock(mm, range); if (flags & FAULT_FLAG_KILLABLE) wait_on_page_locked_killable(page); else @@ -1428,7 +1428,7 @@ int __lock_page_or_retry(struct page *page, struct mm_struct *mm, ret = __lock_page_killable(page); if (ret) { - mm_read_unlock(mm); + mm_read_range_unlock(mm, range); return 0; } } else diff --git mm/memory.c mm/memory.c index bc24a6bdaa06..3da4ae504957 100644 --- mm/memory.c +++ mm/memory.c @@ -2964,7 +2964,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) goto out_release; } - locked = lock_page_or_retry(page, vma->vm_mm, vmf->flags); + locked = lock_page_or_retry(page, vma->vm_mm, vmf->flags, vmf->range); delayacct_clear_flag(DELAYACCT_PF_SWAPIN); if (!locked) {