Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2605690ybj; Mon, 23 Sep 2019 06:37:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmlh6CyWVh3AUISUR3MnN/E05H4pk9q7mGp25L4Z67CYq2X7xgbFd+ZCoZ1OaVITYrKF3U X-Received: by 2002:aa7:c616:: with SMTP id h22mr89347edq.96.1569245821013; Mon, 23 Sep 2019 06:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569245821; cv=none; d=google.com; s=arc-20160816; b=PHVqujYbl8ahf210GaduWIuTdA5wzk6HnIbSN0t5CRYRzWODv312tLfTcpsaJ+/gHn /LuldTxhqQyY9oiC3fm0TqVB+rgvAWLGd0CqDMY8p97aPD7dcozpK5l1uwTp+a0DWmb8 xTGPnni3kd1EbTPeqi3urAAv0DwykdwKuddmES/xpoBRdsN8/HLOaBQeGTlQ0K2wjmkx MtxR+cnEW2IhWlUXlvsJxG84NA4udFS0b1wb5xonWp/moxSKbwsMr+7ipZDj0sZQzAme fJc6a5VS1ymN9zyi79Xs1mtkI52PJTY2A3IV+M6CgNGGSAAfTl2ctK8AFpeQa4/7Znlv jrHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SfnM1kEHJB20PsJ9Y6PlF1EQF63o4NAR1hJNSU7CBGI=; b=q8Ks0iBMq4xHv97x5APz+O9wuZ+/YMukjqUkncFAcc1qBmRVg65O278JCRAe3aN/a8 NgARYDuDr+ENPioXtfGeE4t6jAyORiAXxTT4aa6F1FyyCOmdmALmrfCeVN9vWbv6zEOZ 4dAZQI9XY3pp5qldWtKZveje15tl+B2tbgbAtOw5+rC3bxkXvKLtSXp+lvyY5ZI1poVt B+Yzc7Rsnqv+1DxrB7ciUUN6S0nK8TV0QXsXNeWE3Bac+wp80MebxIQGIw8zQoYzG6Dx xnbAURK2cvX6TCIdEa+8onmhntcka+1GQ12VXvYYLnQWGkCGexhROqBM3FXkudxr/jb2 tguQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tkkE5RjY; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g31si6413563eda.399.2019.09.23.06.36.37; Mon, 23 Sep 2019 06:37:01 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tkkE5RjY; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730774AbfIUBrz (ORCPT + 99 others); Fri, 20 Sep 2019 21:47:55 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:38685 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730495AbfIUBry (ORCPT ); Fri, 20 Sep 2019 21:47:54 -0400 Received: by mail-qk1-f193.google.com with SMTP id u186so9255651qkc.5 for ; Fri, 20 Sep 2019 18:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SfnM1kEHJB20PsJ9Y6PlF1EQF63o4NAR1hJNSU7CBGI=; b=tkkE5RjYXLE5liJly0UZ1C2zR1unTObtqkwLG9O2vtHUo/FxtTrXn/I/XedWNWr3O+ SYH65W5DXjgHt0rw9dbx0r5XQubscRGBGWQTrS5f0NJMv5cJiXzD7KcbmylftW4bmr0x CNnXmPQIUftqYie7SHHeOC8VjlJvNVI5BSUcLqYfRHCsnmuiBMh7MlbmCI7HNi908SdO vr8ricHxIS3N/1Vp1WnSIsNOkEHhXpic9JWWn4qG5Vq2H9QQMP3b0DJTXabldr05l4Z5 3OzXUubbzV/pWKlg59pjmH/s04beFA+DWFsnmr62b9Y66RCjRruLBWdY8o062Z9x44LY BHxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SfnM1kEHJB20PsJ9Y6PlF1EQF63o4NAR1hJNSU7CBGI=; b=V5QlBgNarlG+1CAOWf+NcaaCJ6R1EJBD6jt8E0RpvFWB6o/zP3iEjzNBkpDOi0rtPY ki3Nz3TEBL36sWwPY6I4/BU8K6yUceFUg2mqo7SxjReKJIA1tXHCKRofyVFKc8sY9lR2 nh/XGcZF6WSzK6uQhFfJ90CSfP/pNQi7rQJP2sf90RP4qcp7kJftw9puMtObThUf75Xx tR4e0fum2VM0nVWXfWG0yAEwVAX21HHfismgh+lEggvDNrRYeJuVdWMCW/nHbye4QTau 959hN7Xq8HuByQVBGK+zoJWkl5tKQlKHp1Nz5KMgsvF6WJHk9UTm2OIqwB+dlaz0ZY5R Z6ew== X-Gm-Message-State: APjAAAV0xuhTosshp9t4ULzpUOpJ/rk77+ICG9Ew3btHpd7udeFsSST5 69X5JCpjBEIOnL7Tw9JJtgdbTJY5dAR5Ze0d7mg= X-Received: by 2002:ae9:eb8c:: with SMTP id b134mr6500884qkg.377.1569030473789; Fri, 20 Sep 2019 18:47:53 -0700 (PDT) MIME-Version: 1.0 References: <1568994684-1425-1-git-send-email-hqjagain@gmail.com> <1a162778-41b9-4428-1058-82aaf82314b1@nvidia.com> In-Reply-To: From: Qiujun Huang Date: Sat, 21 Sep 2019 09:47:42 +0800 Message-ID: Subject: Re: [PATCH 3/3] mm:fix gup_pud_range To: John Hubbard Cc: akpm@linux-foundation.org, ira.weiny@intel.com, jgg@ziepe.ca, dan.j.williams@intel.com, rppt@linux.ibm.com, "Aneesh Kumar K.V" , keith.busch@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 21, 2019 at 9:19 AM John Hubbard wrote: > > On 9/20/19 5:33 PM, Qiujun Huang wrote: > >> On 9/20/19 8:51 AM, Qiujun Huang wrote: > ... > >> It would be nice if this spelled out a little more clearly what's > >> wrong. I think you and Aneesh are saying that the entry is really > >> a swap entry, created by the MCE response to a bad page? > > do_machine_check-> > > do_memory_failure-> > > memory_failure-> > > hwpoison_user_mappings > > will updated PUD level PTE entry as a swap entry. > > > > static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, > > unsigned long address, void *arg) > > { > > ... > > if (PageHWPoison(page) && !(flags & TTU_IGNORE_HWPOISON)) { > > pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); > > OK, that helps. Let's add something approximately like this to the > commit description: > > do_machine_check() > do_memory_failure() > memory_failure() > hw_poison_user_mappings() > try_to_unmap() > pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); > > ...and now we have a swap entry that indicates that the page entry > refers to a bad (and poisoned) page of memory, but gup_fast() at this > level of the page table was ignoring swap entries, and incorrectly > assuming that "!pxd_none() == valid and present". > > And this was not just a poisoned page problem, but a generaly swap entry > problem. So, any swap entry type (device memory migration, numa migration, > or just regular swapping) could lead to the same problem. > > Fix this by checking for pxd_present(), instead of pxd_none(). > > > > ... > >> > >>> > >>> Signed-off-by: Qiujun Huang > >>> --- > >>> mm/gup.c | 2 ++ > >>> 1 file changed, 2 insertions(+) > >>> > >>> diff --git a/mm/gup.c b/mm/gup.c > >>> index 98f13ab..6157ed9 100644 > >>> --- a/mm/gup.c > >>> +++ b/mm/gup.c > >>> @@ -2230,6 +2230,8 @@ static int gup_pud_range(p4d_t p4d, unsigned long addr, unsigned long end, > >>> next = pud_addr_end(addr, end); > >>> if (pud_none(pud)) > >>> return 0; > >>> + if (unlikely(!pud_present(pud))) > >>> + return 0; > >> > >> If the MCE hwpoison behavior puts in swap entries, then it seems like all > >> page table walkers would need to check for p*d_present(), and maybe at all > >> levels too, right? > > I think so > >> > > Should those changes be part of this fix, do you think? Yes, please.Thanks > > thanks, > -- > John Hubbard > NVIDIA