Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp18190ybl; Tue, 7 Jan 2020 13:13:36 -0800 (PST) X-Google-Smtp-Source: APXvYqz8XHASYYuMCTBzOSOYqAtJt7m12dofgMexEc5upcQEZIR9XLBIRzyFL7db4kB6JUWAiqne X-Received: by 2002:a9d:ee2:: with SMTP id 89mr1630809otj.270.1578431616258; Tue, 07 Jan 2020 13:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578431616; cv=none; d=google.com; s=arc-20160816; b=IcUgJ9Qvt1UdMRrIoOJHR0BekucgcjR7h9oo03zQnX2tJ9kh8cEQmwP+lCy8JE8cvp seR0D28SWEBnsWmcMJP7d4hl9DsigyuUwDaZP0nW79QNSUehNsCVvkA+b+QzYZE6Yfq2 kf+niB2vjXIbXSsx8CCVnJTMNgYSGOK5F0Q5EP3NOtT0IVmz8a+MYq1E7ch6umZ2ZOmG btVN8DbkYGvQPmGAtZ9ujZnHWlt4J6LNy6M4hH1+zgf7H/QaEMoZYDJmR0OTuLmkKGEe 3ZiZkp8isUCD6aORPav8MpQ+ZmkEYLSaPJ+AdgoC8uiOHIZ4+e0bHV83fKFeCeimcMGI /okw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=SbysyzJHnYBvqFHWxRtcz1aHTD46JJxOWAetcbRONGU=; b=v4TD/A/BVry6Dey1/4jCq5QZS6OCxocWFkdKHN2QQvhXwZz+tDMz3zgQQ4Zd+DALDV j/D4LzlzcfYRLOHNPikaDhYG0lqA/sgr/AcLzY0PhE302jLpiRAqs8iwo3U9Goec23qi CQbhWQI5vrNiq8A9oqbJDc2R2WpXjpmil7RJ9QeRsPqfi5hryhvcnRjlw5MGQMkiAkeb O/TdqqjfEX+TQTSVb7sHyGNDZrd0G0TFlFHclypYXSkicM6KUtJX13ZrRP5FvRkZdK1A k/QjFmgq3NfosvFseO7w8TxeK3dZgc+Tvf9qMsF/dW/gusAMTDdu4EREKF3dxpGN43Dq PNaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=JqxCSusY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20si573545otk.73.2020.01.07.13.13.23; Tue, 07 Jan 2020 13:13:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=JqxCSusY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730178AbgAGVMn (ORCPT + 99 others); Tue, 7 Jan 2020 16:12:43 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:18236 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730090AbgAGVMk (ORCPT ); Tue, 7 Jan 2020 16:12:40 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 07 Jan 2020 13:12:22 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 07 Jan 2020 13:12:40 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 07 Jan 2020 13:12:40 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 7 Jan 2020 21:12:39 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 7 Jan 2020 21:12:35 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 7 Jan 2020 21:12:35 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 07 Jan 2020 13:12:35 -0800 From: Ralph Campbell To: , CC: Jerome Glisse , John Hubbard , Christoph Hellwig , Jason Gunthorpe , "Bharata B Rao" , Michal Hocko , "Andrew Morton" , Ralph Campbell Subject: [PATCH 3/3] mm/migrate: add stable check in migrate_vma_insert_page() Date: Tue, 7 Jan 2020 13:12:08 -0800 Message-ID: <20200107211208.24595-4-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200107211208.24595-1-rcampbell@nvidia.com> References: <20200107211208.24595-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1578431542; bh=SbysyzJHnYBvqFHWxRtcz1aHTD46JJxOWAetcbRONGU=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=JqxCSusYZbOZF5MLOWLYoXTPFeP6maiJmWNu4RrJ42Y9os0rSCKYCZgIVPcHSrkmE sB9qsLaXQXzMz6fJU6HhUSDOKHhmKvJDaO6J0xMQBm5muZ607NdXMWqR9jp20Y8gI4 V0mElE1/R4U7WMt/yHJIup4YHVnMpF3fDBqwv9csVsU/i9XVpTKRhRpdgyxBl10foh bCYR5ceFbh/DX1HukDYdNZOjJRPUikhnNq9c9mS1hDnxGF9qltbXAB6cmcKZ3ETNDJ OAvVXcXts/W8TkveXGbps1SKzxw/82idlXa/Y1H6/zWmgaR3XNu3KUDj1Xk50NSo9r u3PiLRW9bDAXA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org migrate_vma_insert_page() closely follows the code in: __handle_mm_fault() handle_pte_fault() do_anonymous_page() Add a call to check_stable_address_space() after locking the page table entry before inserting a ZONE_DEVICE private zero page mapping similar to page faulting a new anonymous page. Signed-off-by: Ralph Campbell --- mm/migrate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 4b1a6d69afb5..403b82472d24 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -48,6 +48,7 @@ #include #include #include +#include =20 #include =20 @@ -2675,6 +2676,14 @@ int migrate_vma_setup(struct migrate_vma *args) } EXPORT_SYMBOL(migrate_vma_setup); =20 +/* + * This code closely matches the code in: + * __handle_mm_fault() + * handle_pte_fault() + * do_anonymous_page() + * to map in an anonymous zero page but the struct page will be a ZONE_DEV= ICE + * private page. + */ static void migrate_vma_insert_page(struct migrate_vma *migrate, unsigned long addr, struct page *page, @@ -2755,6 +2764,9 @@ static void migrate_vma_insert_page(struct migrate_vm= a *migrate, =20 ptep =3D pte_offset_map_lock(mm, pmdp, addr, &ptl); =20 + if (check_stable_address_space(mm)) + goto unlock_abort; + if (pte_present(*ptep)) { unsigned long pfn =3D pte_pfn(*ptep); =20 --=20 2.20.1