Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3430048imu; Sun, 11 Nov 2018 14:56:10 -0800 (PST) X-Google-Smtp-Source: AJdET5dh6/aXMB30/KZepYJASyhEl4BZpAPs8v2NN+XbDEMqQeuw8Aiepi2b7r5Z9nHni9cL1cTY X-Received: by 2002:a62:2f04:: with SMTP id v4-v6mr14282659pfv.2.1541976970745; Sun, 11 Nov 2018 14:56:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976970; cv=none; d=google.com; s=arc-20160816; b=IGcuzw0YUW3HBCwizH1DiWivEBXVus3VWKKsbZFoSchcFvUhmhONlf2Fi5rzV5WoiQ P0l3RmcsnAQx7p83EdSTaN+qC27iOHfODdSNd7naUsHnVD7rkijAN0ud/XsRFE7L+c+N LyWIOWLlCx92rcC+xh2AzzXEhNeqgvVISzr8n94ViJeoc6lnypc04sqtjxUs/wvK+psP 74UxKjGjrTZRm2c6aCICSKEZxkg7WV1uFi/qLBG2lTk8w3aWV9uQYadggS8Hzjul7yae B+YaRdDqUgbwJON1H879hpPt+mQB+R/r2KAgWnYk/7T/01kMIsojS10V+DRtXanfO3Vz dQIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UT27iN8zBB8J9pW82i2GaXAL+IqJvi7PZW5rqmTWOwY=; b=iQ6nccolCcc48ayWmuOILF/NgijoIOT+J0HuUf476i/KDtVyXGqqHAFLLQq9/qxOCN 5iDJRWitJ41DXp6FXyygomw/1UQFbJlmTbSdOhZAe+er9YrZK2NNL977+01ZuZVihui1 HC2Z4FYXUjDPXcmblz+lg+AzlXuY7sn70lpIWEQ3/eFXotGGH2urhbEy5KwBXthNhhLr nNRN+nVU7M/vJds8TCj+Qv5eD7gmM0t8dXF5g8hB2wI/WZVmEtFz8Urx4mvxMxNKuCrS /ZkV0EblcPc3Q1tF+UlY5jagil5tEjdSLPE8cujf7J2mZ5d64ZS/bvTunZ7Iv0kMorhH 3SUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UXskVdR5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si16365408pld.329.2018.11.11.14.55.56; Sun, 11 Nov 2018 14:56:10 -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=@kernel.org header.s=default header.b=UXskVdR5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403939AbeKLIWy (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:54772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403884AbeKLIWx (ORCPT ); Mon, 12 Nov 2018 03:22:53 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 56AC821780; Sun, 11 Nov 2018 22:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975575; bh=LxgBcRxwhHpzal2vTqrnvmBavYSkW7mvkOC9o3G3nFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UXskVdR5O+gjVtpeO4b4wInCVlrGj9hkAr79CGeifJ3DVb8CSs8RJCk8Od2G7vHon gIa/U/jDqpYt9YdsRnkxkFkvyI6Tx1G5NkIKKYSX22Dg7Q6ikXkiQtyemy1VxLwEzd AxlDd37TfN8zq1EyOCcRicWX3H1lhu58PV+PFT6s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ralph Campbell , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Balbir Singh , Andrew Morton , "Kirill A. Shutemov" , Linus Torvalds Subject: [PATCH 4.14 156/222] mm/rmap: map_pte() was not handling private ZONE_DEVICE page properly Date: Sun, 11 Nov 2018 14:24:13 -0800 Message-Id: <20181111221701.287312428@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ralph Campbell commit aab8d0520e6e7c2a61f71195e6ce7007a4843afb upstream. Private ZONE_DEVICE pages use a special pte entry and thus are not present. Properly handle this case in map_pte(), it is already handled in check_pte(), the map_pte() part was lost in some rebase most probably. Without this patch the slow migration path can not migrate back to any private ZONE_DEVICE memory to regular memory. This was found after stress testing migration back to system memory. This ultimatly can lead to the CPU constantly page fault looping on the special swap entry. Link: http://lkml.kernel.org/r/20181019160442.18723-3-jglisse@redhat.com Signed-off-by: Ralph Campbell Signed-off-by: Jérôme Glisse Reviewed-by: Balbir Singh Cc: Andrew Morton Cc: Kirill A. Shutemov Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/page_vma_mapped.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -21,7 +21,29 @@ static bool map_pte(struct page_vma_mapp if (!is_swap_pte(*pvmw->pte)) return false; } else { - if (!pte_present(*pvmw->pte)) + /* + * We get here when we are trying to unmap a private + * device page from the process address space. Such + * page is not CPU accessible and thus is mapped as + * a special swap entry, nonetheless it still does + * count as a valid regular mapping for the page (and + * is accounted as such in page maps count). + * + * So handle this special case as if it was a normal + * page mapping ie lock CPU page table and returns + * true. + * + * For more details on device private memory see HMM + * (include/linux/hmm.h or mm/hmm.c). + */ + if (is_swap_pte(*pvmw->pte)) { + swp_entry_t entry; + + /* Handle un-addressable ZONE_DEVICE memory */ + entry = pte_to_swp_entry(*pvmw->pte); + if (!is_device_private_entry(entry)) + return false; + } else if (!pte_present(*pvmw->pte)) return false; } }