Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp4866866pxb; Mon, 28 Mar 2022 04:50:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXbMFtGCJD/k60DiLPMp8sYi+CZWcs7eepfLWqWFCKnjm7iSH4yFSTvT2fSH4MdJDTlDzs X-Received: by 2002:a17:907:1c19:b0:6dc:c19e:8cc5 with SMTP id nc25-20020a1709071c1900b006dcc19e8cc5mr27865003ejc.333.1648468230530; Mon, 28 Mar 2022 04:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648468230; cv=none; d=google.com; s=arc-20160816; b=O/s2P/l91/yaufuu/6mZpOI9YqnuklAh8h7u63NHbPZcMaMtWmG5opXcPwLkSFVyBX 9udgaXb7kVYTdfEmiS/Zd1EhnDPsZaUC7xp+gJKtnkfLhlXX4wcTcash82VXA9Dw0Mp8 kHoC1qyS/6y7tPsmNc4KLVNMm1MipGISq5RXcTD4p4PMJPMkKRfOShSiFrFLZN8GQT90 rUsNzaCvhE5hP1gJesuIgAjtdXADlEnZTfRIkTbjkGyBS5UN1Bplt0SAcHhPMFVCyh5A eOBB+9jnahvPc0Y2H7epTLFrpYVLUeI4RbMEhOmk2ByYzV88E7/baV19uBhPREBKluNq 5wow== 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=gP7jhsg7tAGvz7Qk+wRpmR700SCpfo3JdOZ4xioEwr8=; b=Pr4Tui7As2PNmtwPXgyfVQqtesd5qp54JWgGujiSJ3ZyRxYiyz9kEGNelnNosTgmBr QuCQEdE9vB0tCiq3Wpu+bv/V6+oAPkDwzoDf4A1LAdrm4ummk4LqfCIV+KQmqbaEwOwq sAZ1654CVZOjrXOqYNDJJjDbbOVfefhF1QnIbj3hVM9B7E8Mnz/nt6I1fDuj2guibMi+ ldJ1x/hfzVsEzV5EUBpdISXxV0XIK7TaJnF5tcEVppjBkzWhZA4u0wcm/iERVf+Jz5eS U/cIZxSzKUwzB0Aq8d2bWJIocGSoS2/Z7Qg1jkz7NL/k/ZCXmRJ7LBYrxHMWSChH0cFE x9JA== 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 h9-20020a170906590900b006df841b85a2si12283965ejq.911.2022.03.28.04.50.04; Mon, 28 Mar 2022 04:50:30 -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 S237506AbiC1CPt (ORCPT + 99 others); Sun, 27 Mar 2022 22:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231757AbiC1CPs (ORCPT ); Sun, 27 Mar 2022 22:15:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD5F2608; Sun, 27 Mar 2022 19:14:07 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KRbpl3yLXzcb5Z; Mon, 28 Mar 2022 10:13:51 +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; Mon, 28 Mar 2022 10:14:05 +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> <5b734809fef4d76944490d5ac3ea816f0756b90a.camel@surriel.com> From: Miaohe Lin Message-ID: Date: Mon, 28 Mar 2022 10:14:05 +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: <5b734809fef4d76944490d5ac3ea816f0756b90a.camel@surriel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.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/27 4:14, Rik van Riel wrote: > On Sat, 2022-03-26 at 15:48 +0800, Miaohe Lin wrote: >> On 2022/3/26 4:14, Rik van Riel wrote: >>> >>> +++ 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(pa >>> ge), >>> +                                                   page->index, 1, >>> false); >> >> It seems this unmap_mapping_pages also helps the success rate of the >> below invalidate_inode_page. >> > > That is indeed what it is supposed to do. > > It isn't fool proof, since you can still end up > with dirty pages that don't get cleaned immediately, > but it seems to turn infinite loops of a program > being killed every time it's started into a more > manageable situation where the task succeeds again > pretty quickly. Looks convincing to me. > >>>                         /* 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? >> > > Just a simplification, and not dereferencing the same thing > 6 times. > I see. :) >>>                 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. > > Want to send in a Reviewed-by or Acked-by? :) > Sure, but when I think more about this, it seems this fix isn't ideal: If VM_FAULT_NOPAGE is returned with page table unset, the process will re-trigger page fault again and again until invalidate_inode_page succeeds to evict the inode page. This might hang the process a really long time. Or am I miss something? Thanks.