Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp694195pxb; Tue, 5 Apr 2022 19:04:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz+ArrjcDWl2EeK8dMsiXOJpUjwxwPo+VkPdyLyLUQeyhgch/e4vBiljYBC9XFL1PfRk/s X-Received: by 2002:a05:6a00:2887:b0:4fa:e10c:7ca with SMTP id ch7-20020a056a00288700b004fae10c07camr6577639pfb.9.1649210590874; Tue, 05 Apr 2022 19:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210590; cv=none; d=google.com; s=arc-20160816; b=I9Kq4s6mhQkwE71ZsvGuhtSq42KSBx6SljbgUpAFkLi/dj00BAmO61sk4IyrKMU6Kt lPWVsS0Px3QVE+So6ZURFfm37XtmTryZJJPwcZ95kQ1Br591N63A4h9Hun25EWojsblK 8v8KqruS6tvZncT80gK1K5sc7NaJI/Hblwa01DPsTGD8yIKR/w0LUB3q9hc2XrVYlysq +lEVTHQccZiGVBHwgldzm67VncKsGQbmyKubo/Cfn9WxTEzMUicJ9JZh6LVfhPdnxAJP 5i6G/HYHbG1SNEvM86z5SV0Z7ITLIJVHvr7/qKL+R+j4BXtXG5au9XDFHthC8XhNLRAd Yoow== 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=Rs8lgvzBtuhjlqAPnCeocFe6dmrurJfrroAhA4WcGgE=; b=L0Lpbp6yOV3PU6dTqpwio4XF0hsPU9uwHnxqOkO6I749WGNbHCVLiprAooLo2c1RDr kYZfnK3IeGsWO7DaHMU7WH8VQN3N2hOibvL81P54drVyiDTgxpsYj9e0tkNukLie/MMR 5N/GfC1PEC6Pv0uze8YgmolhUTa+mArL4ksB9z15O94C1oN9N9CYuGiAdIlIoxWX8omO 4sOEVVuUkj1lNqZRffgSEwt86JkA5Fo61UYWKepvBMAmeJz/1u9CQkEE7A5ivgkwi1oH CqoxEOGu9ecUWC4Vn452lfnreR81ULtavt3jFRTX1GxQNPc/oumT1USNGSwUFi0JsmiD MAjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kupnPU5+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d24-20020a631d18000000b003816043ef2asi14208946pgd.287.2022.04.05.19.02.53; Tue, 05 Apr 2022 19:03:10 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kupnPU5+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbiDEHuE (ORCPT + 99 others); Tue, 5 Apr 2022 03:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232429AbiDEHqe (ORCPT ); Tue, 5 Apr 2022 03:46:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F3293186; Tue, 5 Apr 2022 00:42:17 -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 2A8E2B81B18; Tue, 5 Apr 2022 07:42:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48E57C3410F; Tue, 5 Apr 2022 07:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144534; bh=XamnRL9+WDS32nCTYYt9TqlmML6yO8Co3rb5YczgAAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kupnPU5+wMNsHUiCa2ATzrXJLYxdoQthca9POXwnxfmHR3S/Ihl/fwDcwCjqk3Pl0 iYG1dzlRaAZfeKMFex937zFxLvIQuXwMegzCTO8B0vOJJlLWAucdjbkSUx9Mn0PMV1 99CqzfYfgRkjMDTQAQK7lUmQteB4ufEx/1N7UK90= 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 , John Hubbard , Mel Gorman , Johannes Weiner , Matthew Wilcox , Andrew Morton , Linus Torvalds Subject: [PATCH 5.17 0079/1126] mm: invalidate hwpoison page cache page in fault path Date: Tue, 5 Apr 2022 09:13:46 +0200 Message-Id: <20220405070409.888284953@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Rik van Riel commit e53ac7374e64dede04d745ff0e70ff5048378d1f upstream. Sometimes the page offlining code can leave behind a hwpoisoned clean page cache page. This can lead to programs being killed over and over and over again as they fault in the hwpoisoned page, get killed, and then get re-spawned by whatever wanted to run them. This is particularly embarrassing when the page was offlined due to having too many corrected memory errors. Now we are killing tasks due to them trying to access memory that probably isn't even corrupted. This problem can be avoided by invalidating the page from the page fault handler, which already has a branch for dealing with these kinds of pages. With this patch we simply pretend the page fault was successful if the page was invalidated, return to userspace, incur another page fault, read in the file from disk (to a new memory page), and then everything works again. Link: https://lkml.kernel.org/r/20220212213740.423efcea@imladris.surriel.com Signed-off-by: Rik van Riel Reviewed-by: Miaohe Lin Acked-by: Naoya Horiguchi Reviewed-by: Oscar Salvador Cc: John Hubbard Cc: Mel Gorman Cc: Johannes Weiner Cc: Matthew Wilcox Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/mm/memory.c +++ b/mm/memory.c @@ -3893,11 +3893,16 @@ static vm_fault_t __do_fault(struct vm_f return ret; if (unlikely(PageHWPoison(vmf->page))) { - if (ret & VM_FAULT_LOCKED) + vm_fault_t poisonret = VM_FAULT_HWPOISON; + if (ret & VM_FAULT_LOCKED) { + /* Retry if a clean page was removed from the cache. */ + if (invalidate_inode_page(vmf->page)) + poisonret = 0; unlock_page(vmf->page); + } put_page(vmf->page); vmf->page = NULL; - return VM_FAULT_HWPOISON; + return poisonret; } if (unlikely(!(ret & VM_FAULT_LOCKED)))