Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2796872pxb; Sat, 26 Mar 2022 04:42:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg7uma+MFheBZs5+PYcc3AbSjsoOeINY9BrjyQdx3O4OSReV6bBOG6ho792SS2GA5A9gd+ X-Received: by 2002:a17:907:da7:b0:6df:9ff4:10c7 with SMTP id go39-20020a1709070da700b006df9ff410c7mr16551882ejc.106.1648294935875; Sat, 26 Mar 2022 04:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648294935; cv=none; d=google.com; s=arc-20160816; b=moq6gnxdK4InmoY/Omkg2hOp1uxWJE2BeLH1D76W4qSvn42SyGz69fNkrxyaWIZCIM 5EmQcFe95DHS2l2HQqEIJBez28GWfmRhpKzcyK7NR6LuINvQ/x4COEmclV9rTwsd+8um vT8D8Snk5sEzpB2tfyWw+i0yMSGp2WbgF1PbkNhtgtguhTrPoCd6PIgj5Ub1E10ToW/S iZj1Y+1mBWcrB0YrgeawrOI0q+65iO+U+UPZJo4WFMxqRHFYRZy2HHoRPtnlCvBR9AxP 98BalMXRpeyiPVW9xCtX4POVLzAaXr2xWwgD9PEhq9IulEaQ5IIds3N2YWgyc0RJHYRN 2B+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Kru9IYA43DoKwx0YYOyONvnD8CliGGHhdhOW76rJ8LI=; b=hSx/C7iUhB+EGCqrwt6WvKPq9qg6haTenV2r8+2o88DYg9XC07+Y1V/dDYRPZW+gXm zTSzVIZLXq+mfuCcZEGXY3Z7Wd4IpitXY0mTYtV3/JKS7YpWegoJ2ZbRz5n/Kh60hUAi 3YfkIrscIgcQdlNTVoq9nesdcCszdzlJdxF/4hv4WZV6bpPYKKsHlI+6VlaX9Mornw2/ nrPm+Qjt3+ggAhjuoupNEsApBteRwmFCJz6pZ64/AwM3cwy/HNf8ZW44RpG8NbkAywow SWKrIasxHiTEt+OlrQiBt7y3dw6tOqUBJ7xlELwJwIR//Uxpp+jVFclNOk/IfZenW4qU l56w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020a509b46000000b00418c2b5be72si6144449edj.340.2022.03.26.04.41.29; Sat, 26 Mar 2022 04:42:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231891AbiCZHuf (ORCPT + 99 others); Sat, 26 Mar 2022 03:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbiCZHue (ORCPT ); Sat, 26 Mar 2022 03:50:34 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CEFE3E5D8; Sat, 26 Mar 2022 00:48:56 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KQWFg0ZySz9swd; Sat, 26 Mar 2022 15:44:55 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 26 Mar 2022 15:48:53 +0800 Subject: Re: [PATCH] mm,hwpoison: unmap poisoned page before invalidation To: Rik van Riel CC: , , Oscar Salvador , Naoya Horiguchi , Mel Gorman , Johannes Weiner , Andrew Morton , , linux-kernel References: <20220325161428.5068d97e@imladris.surriel.com> From: Miaohe Lin Message-ID: Date: Sat, 26 Mar 2022 15:48:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220325161428.5068d97e@imladris.surriel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/3/26 4:14, Rik van Riel wrote: > In some cases it appears the invalidation of a hwpoisoned page > fails because the page is still mapped in another process. This > can cause a program to be continuously restarted and die when > it page faults on the page that was not invalidated. Avoid that > problem by unmapping the hwpoisoned page when we find it. > > Another issue is that sometimes we end up oopsing in finish_fault, > if the code tries to do something with the now-NULL vmf->page. > I did not hit this error when submitting the previous patch because > there are several opportunities for alloc_set_pte to bail out before > accessing vmf->page, and that apparently happened on those systems, > and most of the time on other systems, too. > > However, across several million systems that error does occur a > handful of times a day. It can be avoided by returning VM_FAULT_NOPAGE > which will cause do_read_fault to return before calling finish_fault. > > Fixes: e53ac7374e64 ("mm: invalidate hwpoison page cache page in fault path") > Cc: Oscar Salvador > Cc: Miaohe Lin > Cc: Naoya Horiguchi > Cc: Mel Gorman > Cc: Johannes Weiner > Cc: Andrew Morton > Cc: stable@vger.kernel.org > --- > mm/memory.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index be44d0b36b18..76e3af9639d9 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -3918,14 +3918,18 @@ static vm_fault_t __do_fault(struct vm_fault *vmf) > return ret; > > if (unlikely(PageHWPoison(vmf->page))) { > + struct page *page = vmf->page; > vm_fault_t poisonret = VM_FAULT_HWPOISON; > if (ret & VM_FAULT_LOCKED) { > + if (page_mapped(page)) > + unmap_mapping_pages(page_mapping(page), > + page->index, 1, false); It seems this unmap_mapping_pages also helps the success rate of the below invalidate_inode_page. > /* Retry if a clean page was removed from the cache. */ > - if (invalidate_inode_page(vmf->page)) > - poisonret = 0; > - unlock_page(vmf->page); > + if (invalidate_inode_page(page)) > + poisonret = VM_FAULT_NOPAGE; > + unlock_page(page); > } > - put_page(vmf->page); > + put_page(page); Do we use page instead of vmf->page just for simplicity? Or there is some other concern? > vmf->page = NULL; We return either VM_FAULT_NOPAGE or VM_FAULT_HWPOISON with vmf->page = NULL. If any case, finish_fault won't be called later. So I think your fix is right. > return poisonret; > } > Many thanks for your patch.