From patchwork Thu Aug 30 14:41:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10581825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E97E5A4 for ; Thu, 30 Aug 2018 14:42:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DEB92BFD2 for ; Thu, 30 Aug 2018 14:42:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 217CD2BFDB; Thu, 30 Aug 2018 14:42:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B095D2BFD2 for ; Thu, 30 Aug 2018 14:42:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F3E16B5217; Thu, 30 Aug 2018 10:42:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9A43E6B5218; Thu, 30 Aug 2018 10:42:01 -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 893016B5219; Thu, 30 Aug 2018 10:42:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by kanga.kvack.org (Postfix) with ESMTP id 5ED826B5217 for ; Thu, 30 Aug 2018 10:42:01 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id l7-v6so8189801qte.2 for ; Thu, 30 Aug 2018 07:42:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:in-reply-to :content-transfer-encoding; bh=DNnpXUMHGO6m89bCBNJdoSesqnROUJ+nhYDh1sv7Kko=; b=c8xxELZdRAcqS7ukRVVboi6YtmmMwovXbe1qOTm/6etXqYAiWjLFq7L/BFr/L6E71L ynAUP+Fkx84OXNgPvF9mUrmGrxpGnXiRNg4DmioF+nsm/FZJG26Onl3vznjdfVDP4AwC ue+CPfasu1RLzw2uH40wRqzSAg5KhbAwTuOykXccJgNocENoQm2eTdTgU2CX2x+79Zwc hsGv3tlna6ARlacFiDlFKpAszDE56aeqwcgAWR4AyXQjYhy47O4N4XYf+++w1MWnOc8G OrlFbGc0XCm2shm5L7+3U+rGyX+gCEkj3LN4dn43xOAQ1/aNeaKsBN1bWSdaVAjAo6SZ OV3Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APzg51CqXsKhBCvJVkevArvgk0Z8cJAdNaMoAV+BccN9zw8IYijLgneN uhO3fVaxrhqjGKBiWXm7jy8zs0RI+E8IF3e4ieyNL9i1jHjStfuZxthGouS4jK4TzzHIZGoKYvS xWTdT0WCDjCyHuN5CVPMddT9H0xRFg0ozaZSQrmYdEEpCZ64RVurDBTLkuyh4NHdGjQ== X-Received: by 2002:ac8:3790:: with SMTP id d16-v6mr12380690qtc.128.1535640121188; Thu, 30 Aug 2018 07:42:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbG0z+0UBqm38Xc+jadR3sVmqnYDAZGipe9EcBl7EhznlGKTW99UyNoR0bcjXoxUW52xshy X-Received: by 2002:ac8:3790:: with SMTP id d16-v6mr12380648qtc.128.1535640120699; Thu, 30 Aug 2018 07:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640120; cv=none; d=google.com; s=arc-20160816; b=sSpleoZ9vQ4Ztstt0V88f47L71zPLkxnUW0FwfjtlVon7zVgvxqfXX/MLGhtRIbbXn e2Ke0jWL0fVu6KOh2r62mTnSe368Hw859ijUwEFS6odlCjMP6nKdPBZqEt+FfrpQF9CJ GSAlu8liYQgdwyh5waX8BgSWkIvi779vkspLuDTF5lcBN5Kw48BtfTsroMQXP4+qF+Sb H9rizhvCZqkxX+efo3HbqQM5MS7heX1ei6DS5KofOpsLztJcQN9Thc6Al/f7dDVa47Ce lYUClSTt5hRraWd2MX6mnjnEWTvQPHfOrvhTWbR12AKRRtMjvKTy1Y3ByPtv56wemY2S 7+/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:message-id:date :subject:cc:to:from:arc-authentication-results; bh=DNnpXUMHGO6m89bCBNJdoSesqnROUJ+nhYDh1sv7Kko=; b=YEJUtrhTMlpHsGg1PqEtb/wn8zldmI1S0AyQgkSnilFX7/OwSGCSMQ5cX3J0EjN/M/ nJesQZeRh4HEx6oby3/M2f8TvI+N2IdqsjA9Yta+tVHh8DFz8jl6DGrJ+PPwCjkkCrZ+ X3ifYt4wVFIkta6bn+76y9aO5hOGbtgSLmQXyu5HWIxZM79pc1h9Hmprfw64InplBmd9 Kx0C1RABy4/DvOFRXo2W/qXVOXlfNe0KadGOlatcEU0kml1X1V4AL25+Wpq2QQilFVTz w+dGnO3bag9P9PA3akrK5YifsOzfQ5DlrgRKalXIxVx6pzbAP4rYRu+6aKllaKHgRmey AqjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id d24-v6si3383018qkh.150.2018.08.30.07.42.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 07:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4259F804B9F4; Thu, 30 Aug 2018 14:42:00 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.20.6.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9C9563F25; Thu, 30 Aug 2018 14:41:59 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: Andrew Morton , linux-kernel@vger.kernel.org, Ralph Campbell , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "Kirill A . Shutemov" , Balbir Singh , stable@vger.kernel.org Subject: [PATCH 3/7] mm/rmap: map_pte() was not handling private ZONE_DEVICE page properly v2 Date: Thu, 30 Aug 2018 10:41:56 -0400 Message-Id: <20180830144156.7226-1-jglisse@redhat.com> MIME-Version: 1.0 In-Reply-To: <20180824192549.30844-3-jglisse@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 30 Aug 2018 14:42:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 30 Aug 2018 14:42:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jglisse@redhat.com' RCPT:'' 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Ralph Campbell 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 private ZONE_DEVICE memory to regular memory. This was found after stress testing migration back to system memory. This ultimatly can lead the CPU to an infinite page fault loop on the special swap entry. Changes since v1: - properly lock pte directory in map_pte() Signed-off-by: Ralph Campbell Signed-off-by: Jérôme Glisse Cc: Andrew Morton Cc: Kirill A. Shutemov Cc: Balbir Singh Cc: stable@vger.kernel.org Acked-by: Balbir Singh Reviewed-by: Balbir Singh --- mm/page_vma_mapped.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index ae3c2a35d61b..bd67e23dce33 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -21,7 +21,14 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw) if (!is_swap_pte(*pvmw->pte)) return false; } else { - if (!pte_present(*pvmw->pte)) + 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; } }