Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3472450imu; Sun, 11 Nov 2018 15:54:12 -0800 (PST) X-Google-Smtp-Source: AJdET5exqBovndtz0JoNaHni0nn40Dep9zKz/qYvLdmccHPl1vsB1XlZSiGuRJGggT1Ak/8zuuSq X-Received: by 2002:a63:a84a:: with SMTP id i10mr15675030pgp.263.1541980451977; Sun, 11 Nov 2018 15:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980451; cv=none; d=google.com; s=arc-20160816; b=xGTEwS7I/PKo4vazy6Ijp3yChc+LGCIkaJPjqPfwkZVtx3Gb5G2vrBuDDdEdckaRhs 2IuEBaXUuUoK7SN3rZTZNXPsRhE2rLoHvdSrn9nZcK9fjXZvEV7YQ5VoD4NIHj5yJ3++ x8GBBehVSgQIpJzFnWMifgUVjafr0eObhQcfivamNpbbVZcfg4HdlLAVrjYA84O5Sk/G 6a61jStCbBb2euWcSj6Hb2vPJUniegu306zLISAI6kxgYElrpC8LZOahXsSGtpoOBz2I /d+dxwV6gN+PffznlE3hTcQi9BE2Ext0SlmVKevK1BSN8bfYYvj8cs+LFjfvBcClI5m+ 1Z1g== 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=zsaGigKLBoOOUHt/in9BPc6xTqRR+0FMfuMu8k4B93I=; b=k2a8DrxVPJuQlK/8guLnxPGk8I2kZIGCe87PekQ2PUGWBSfzFUwkEqOC2Xx15hRaDe lBBw4/S86ei5fDjo5kcf334e6Yb9yIpT+fp+1gPrXt8c90B+/vgL4QFR+UXVsdA1wxPo WMZa027LyZyKoqJdJcnNpz/X/vjTNB1thLJG/s6vduWBgCJp6sh/lUCpyiQVTcfO/tQz laqzMC+JHyaelWwG3Dvci1T21NnvDpkb5MQacpSaW8O57OmSuiLiR9qx27vd+QE+Fzue K9QyrsXJQJ5gm/wukVBXRfqEKsi53Ea63GOQB3IdrO5fG5IAgwShRUhZHwLBJuweNakd e6MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qKrEMERx; 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 188-v6si15602737pfa.199.2018.11.11.15.53.56; Sun, 11 Nov 2018 15:54:11 -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=qKrEMERx; 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 S1732823AbeKLIS2 (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:37302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732647AbeKLISZ (ORCPT ); Mon, 12 Nov 2018 03:18:25 -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 E214C21707; Sun, 11 Nov 2018 22:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975310; bh=roPN1qjXR5r0ii4knkn98wx1D6rJ9gaNcb+5cVSMLk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qKrEMERxqBnbgSa0yJpGOvqP4FETv9Umu4051/UCnhVxdyrOYvLq+b9mxOHD5V2t1 w35wfcW+2iHjdLr3zk4HFi1cpPSitFgy3TBxI86qZmXW0dKYyGWGjzNG1Xo1BGgTxp nNV7IEjQCBVQ2UnIH7n0l7/7LVopHc6KV1ENgR8c= 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.19 253/361] mm/rmap: map_pte() was not handling private ZONE_DEVICE page properly Date: Sun, 11 Nov 2018 14:20:00 -0800 Message-Id: <20181111221653.349434356@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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; } }