From patchwork Fri Oct 30 16:32:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11870197 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 52AEE921 for ; Fri, 30 Oct 2020 16:32:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E9FF520727 for ; Fri, 30 Oct 2020 16:32:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="B295DElX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9FF520727 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 097276B007B; Fri, 30 Oct 2020 12:32:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 01F796B007D; Fri, 30 Oct 2020 12:32:37 -0400 (EDT) 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 E018F6B007E; Fri, 30 Oct 2020 12:32:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A7ED16B007B for ; Fri, 30 Oct 2020 12:32:37 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 51DE98249980 for ; Fri, 30 Oct 2020 16:32:37 +0000 (UTC) X-FDA: 77429135154.28.meat39_1507b9e27297 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 1B4836D73 for ; Fri, 30 Oct 2020 16:32:37 +0000 (UTC) X-Spam-Summary: 1,0,0,09e66472f1e3a147,d41d8cd98f00b204,jgg@nvidia.com,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1431:1437:1513:1515:1516:1518:1521:1535:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3870:3871:4250:4321:5007:6261:6653:7903:9010:10004:10400:11026:11473:11658:11914:12043:12114:12296:12297:12438:12519:12521:12555:12679:12895:12986:13069:13311:13357:14181:14394:14721:21067:21080:21220:21444:21451:21627:30045:30054:30064:30070:30090,0,RBL:216.228.121.143:@nvidia.com:.lbl8.mailshell.net-64.201.201.201 62.22.0.100;04y89ibbq5yjyd93f71eb9xm7kg83yppn3xsis9853inagubswijys53i3mfymn.4a6rm9jg6m9hmjjuk14zucos4qa8g14pwb591hy7u6b65dtgcgx643ocrm7x1p4.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:67,LUA_SUMMARY:none X-HE-Tag: meat39_1507b9e27297 X-Filterd-Recvd-Size: 5566 Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 30 Oct 2020 16:32:36 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 30 Oct 2020 09:32:39 -0700 Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 30 Oct 2020 16:32:33 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 30 Oct 2020 16:32:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IALgoFUeNSLDUVSqf3SHCyXggBwnNRSpngjBC96OD8HMKkLEDIJyo0jWlq+DGUIExgygQyP+5egLtlFsiE8jGYd34k2BIWes+hDzLQWCHDiSUH3UGZVAA+rV3PpFrWcCataXZu8t4gRA3Tq4zGADFHyzBGYzKozLMouGYLKJCP6Oic4ovS+4GD2Khq5BKfaUvKXBdFaMTn0HEDARJ4erV9SFH3foWhVXaiWmzApISehncB9Gt29ZZhHJEVZK/sKDoF2DAV25DhiPyg8nCz08q/K45IJreP2B8o23KXskGRhCCLGGH6uMbnf0a//xNmMBXVFa4L+xmnaibdXHWzobTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4PoRW6xf6lwp9tKRb6oFnFAGP538jgmsr2DSR+a1aAU=; b=XpTFb+aurCqabgNdANEtEj032Htfx+sy2nYyTqjUR9H7A6CvpTVhEfJh7pZofb8Y00hKKsDlY6p8sih9LMANdJLMdA8Ki9Ld8kDVe9TmAK70gqa+cFmZi7MJJPMnsryGGcPTy1GsQdOGBCFKD1tqqM9EVkU5Ow1TdW6GmbEGNjHWcEFObZJndGgzr1vUby/dZ909zInpKZonQ9DV7V9vlsWBgj/8e21UtnatpsS5gO06inKXcYsfeHuRZYzeDZzUpYVs6HVCRL8iLRroo8gvmqMw3DfSi9Ow9t2vRxJbHIEXLa7lnLb3BDcKsShn9JGCNOs4VfoFNXtQTA9l2Ud3pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.24; Fri, 30 Oct 2020 16:32:30 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::cdbe:f274:ad65:9a78]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::cdbe:f274:ad65:9a78%7]) with mapi id 15.20.3499.027; Fri, 30 Oct 2020 16:32:30 +0000 From: Jason Gunthorpe To: Andrew Morton , CC: Aneesh Kumar K.V , Claudio Imbrenda , Ira Weiny , Jan Kara , John Hubbard Subject: [PATCH rc] mm/gup: use unpin_user_pages() in check_and_migrate_cma_pages() Date: Fri, 30 Oct 2020 13:32:28 -0300 Message-ID: <0-v1-976effcd4468+d4-gup_cma_fix_jgg@nvidia.com> X-ClientProxiedBy: BL0PR1501CA0031.namprd15.prod.outlook.com (2603:10b6:207:17::44) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (156.34.48.30) by BL0PR1501CA0031.namprd15.prod.outlook.com (2603:10b6:207:17::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 30 Oct 2020 16:32:30 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kYXKG-00DPcr-VR; Fri, 30 Oct 2020 13:32:28 -0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1604075560; bh=nYcREqpD2wX2KOFwYSudOuML9t73Cg4fe5g0E4bSzdQ=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: CC:Subject:Date:Message-ID:Content-Transfer-Encoding:Content-Type: X-ClientProxiedBy:MIME-Version: X-MS-Exchange-MessageSentRepresentingType; b=B295DElX8Tr5TI9NJJM75EXU32H1RddI760NcFVOC/5QXA/6iQKHQQzAOStXEJ8mZ j8Civyd8YJD2lC8eZQas+HyJL9dDzbpifb0Q5L3jtndKswy/nm8qpBHek260ejk5co 7ooKU773jdrlnAcQeiDLcDebp1md6S383BqfWdo5evJsWr3jgs6kg5/S8MLn6xyCkz mwBbeG2Fd+zUuyJz/H2zZZ3NNPEmV3MHMnnMCQj9dmBfPs8pGkt6zaGDP0aJfyE7TG AHNWcuIxUWAHc8QVDlrQ4M0bDm0Q31HQDomtNEKv46cNHZU5EWkw9J0yWpfsn2ciY/ gL8LGMDMNDQ2A== 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: When FOLL_PIN is passed to __get_user_pages() the page list must be put back using unpin_user_pages() otherwise the page pin reference persists in a corrupted state. Cc: Cc: Aneesh Kumar K.V Fixes: 3faa52c03f44 ("mm/gup: track FOLL_PIN pages") Signed-off-by: Jason Gunthorpe --- mm/gup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) I don't have any way to test CMA stuff, this was noticed by inspection. diff --git a/mm/gup.c b/mm/gup.c index 1bb349e5ed212a..2e26757f3c9276 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1630,8 +1630,11 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm, /* * drop the above get_user_pages reference. */ - for (i = 0; i < nr_pages; i++) - put_page(pages[i]); + if (gup_flags & FOLL_PIN) + unpin_user_pages(pages, nr_pages); + else + for (i = 0; i < nr_pages; i++) + put_page(pages[i]); if (migrate_pages(&cma_page_list, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_CONTIG_RANGE)) {