Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp34293imm; Thu, 30 Aug 2018 07:43:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZhroNdxy3UyNw+/ow/q5ah3txPorRU+XfTDQVqWDSVFo9o4nMOkpLtZRG76FKRxFwFNBhY X-Received: by 2002:a17:902:246a:: with SMTP id m39-v6mr10375674plg.57.1535640239038; Thu, 30 Aug 2018 07:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640239; cv=none; d=google.com; s=arc-20160816; b=P7qLl16BgcPajQJjc5JtJ+6aVkKYj7oux406bB3SMv6YvKKIUX0WaTxJwGZ3N5BJHW TBkKygRcFK6Mb+ndAdroooqeqv0ItYrfp58St7d4eID2Dv65qnyLqI1eBat+PjDZQHo7 HVSlV6xH1VDefXQ7/X7BpOjXHCZd3LNwvyOFn9c6r3bZl8t3RMIMWJljEHOlCZoV8ud0 e4YMNI4eO3eKtxwtutpdoTdsEuH39kvY4Iz10S/l90Ft5bc+zTeDj2zCJOduNKo5ZBol V6OutgCWxbewRtO4ISxwbztJTVoYhVe8IhqulR2dsf0KE93hB+ymSRcF7PVSKAUdjhDC 7R3Q== 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:in-reply-to :mime-version:message-id:date:subject:cc:to:from :arc-authentication-results; bh=DNnpXUMHGO6m89bCBNJdoSesqnROUJ+nhYDh1sv7Kko=; b=CvkKWkvQBDlQAH+jfE5rjDHz55xk1ZVnD/5G6Fi90AqMArYlyhYyZOsD0zn9tedAfc p0Hf01ZZQQ/0wSNuRRB1ym84O70xj62byiJVKlpIggbpn7lYp8w4Yo72Y+axNWRVj+Sg FzB1lMUa5Vt7brK0Lcn8LYdXpM69Z7yc0mWJ4+Q8vuzcXRmMygXvqfwKcxD/qWkgbV1/ zqBoLt6kgKUrYpr5jBZXsuJD9ElkkzcQtuyDUfmSb0E3/ots8RhKGWyDg6CA/i4DvrXc JlVmd/L8p5RBqmANgZPcBq3wmZFVUb6yZHWn1qhwyn45wCFGiQ/awA+sSjUgocAyyTyW p38Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc3-v6si6131886plb.214.2018.08.30.07.43.35; Thu, 30 Aug 2018 07:43:58 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729446AbeH3Soa (ORCPT + 99 others); Thu, 30 Aug 2018 14:44:30 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50828 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729048AbeH3So3 (ORCPT ); Thu, 30 Aug 2018 14:44:29 -0400 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?q?J=C3=A9r=C3=B4me=20Glisse?= , "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 Content-Type: text/plain; charset=UTF-8 In-Reply-To: <20180824192549.30844-3-jglisse@redhat.com> Content-Transfer-Encoding: 8bit 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:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } } -- 2.17.1