Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1009838pxb; Wed, 6 Apr 2022 06:38:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2zZfoU+drJQoPQhsRQi/k1Ydu/OrjDat3Fa9Z2c5HzSTcIAX5N81ZSna5eWpDT0+Mlvzp X-Received: by 2002:a17:90b:1c8f:b0:1b8:c6dc:ca61 with SMTP id oo15-20020a17090b1c8f00b001b8c6dcca61mr9869635pjb.13.1649252306897; Wed, 06 Apr 2022 06:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252306; cv=none; d=google.com; s=arc-20160816; b=b4dZrdUNJUv9viH9ufVKxQDjLwzdxfBgOCz27ivvquDblcYHdN5GUGzD5CE9XeW9nk yoguI0POQslHs2fuxgSK3IlQkZcDmOFql8Z0X4P7WU+mC+NmGl45yaP6eyzQlnzhnfTC pT2Ya5dUdUGfcwLddi/mCNebmEvPV+lIcDoMXd/6Ur2AzsOUaGQ/RCY9E+FtUAWHzwSD p2OFg97DBKku6Z777uzmEQX5XMcZAI9BlioLW4Sh4ku5JiWhGyHEIHCT5czgzj/q69od fcL+yuXet9hBfKLjqhR1SxtTGKZiu5Hc8SIJkZA7JYIprDZQ0uqHIU0Vyhc3kajaieSx P+UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1MFAyWmoU4AUND6nFvioK7xc/rUuCp3pq4NtY7TvBRM=; b=FcnIIYtIXLYgaJMLpuPzZ4m8fJpWY7jgD2ol+TggSOQrxsy/fqCfhhXOTr+QAJsZ1u vAhqdDwaC5jNdcq8E65eZ6DO0yDsUXiboFcsg62iFBGf8gB1vpYflJe/M/i0UJZZNkjp EmWeAd/+KXkGXH4vx5rpLRausoCAztKnpfI86hLfRMQgA+TuEElspH2MeSypUpoFgaEO +kIj5j45v4hBN4yaL0/ggVbx5IyBrBBpYmJVNZBxGrfe7mpjEngQxuyPnc3jdnjLvLMB xz8Sz9EGgTitWcC93In/TG9XSYduFX7AoXaD0HTbnmrNQN9l9tS7wt9tGqpzBU3KzTJ4 dm9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lPjcY0BM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 19-20020a170902c21300b001541561fef7si4866808pll.41.2022.04.06.06.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:38:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lPjcY0BM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4FF4552418; Wed, 6 Apr 2022 04:22:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385290AbiDEVt1 (ORCPT + 99 others); Tue, 5 Apr 2022 17:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355358AbiDEKTZ (ORCPT ); Tue, 5 Apr 2022 06:19:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B926D13F4F; Tue, 5 Apr 2022 03:04:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2621BB81BC0; Tue, 5 Apr 2022 10:04:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ED03C385A1; Tue, 5 Apr 2022 10:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649153078; bh=eIHtbjrdsYsyO9vjQmEJzlYHgDTIqtUdRD6j/Q59o9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lPjcY0BM4ZDsw+RrJ+nCdbXd0iRmhmK3j6QGDYSq9RbDkUUBVkdB6B52X1YwL11uJ vjbKDM5D2ouKFM6/xBto6hQq+uv8UHB6wNd4LOEF+ZgNFRyw27oISPJzz5of6nP0DL WVxNRn+d/8Jo6vf3WD9A8vxuMcmG9uTWQH5ov7qY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rik van Riel , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Mel Gorman , Johannes Weiner , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 077/599] mm,hwpoison: unmap poisoned page before invalidation Date: Tue, 5 Apr 2022 09:26:11 +0200 Message-Id: <20220405070301.117379793@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Rik van Riel commit 3149c79f3cb0e2e3bafb7cfadacec090cbd250d3 upstream. 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. Link: https://lkml.kernel.org/r/20220325161428.5068d97e@imladris.surriel.com Fixes: e53ac7374e64 ("mm: invalidate hwpoison page cache page in fault path") Signed-off-by: Rik van Riel Reviewed-by: Miaohe Lin Tested-by: Naoya Horiguchi Reviewed-by: Oscar Salvador Cc: Mel Gorman Cc: Johannes Weiner Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/mm/memory.c +++ b/mm/memory.c @@ -3676,14 +3676,18 @@ static vm_fault_t __do_fault(struct vm_f 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); /* 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); vmf->page = NULL; return poisonret; }