Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1685407pxb; Wed, 30 Mar 2022 08:19:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztP2Sah6okOL6RoLQcY9BuJz5rnOM462fLe3Mf9fMf9lkQwl1UC08CXaYQauHQCLDjT/Ti X-Received: by 2002:a05:6402:3495:b0:419:1ff6:95d9 with SMTP id v21-20020a056402349500b004191ff695d9mr11294617edc.249.1648653544195; Wed, 30 Mar 2022 08:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648653544; cv=none; d=google.com; s=arc-20160816; b=ZoGvaVp7bEBV6jQnITYyKNSzyJlq+HdkgWfBNhihS3Zxgmq4dVLFgsBT03n9vjrMGx +iM9o0FeHiUBoZ/2M71pHFPXxvmzEZnRm4Hbk3sHpZkiLcqyyVsuWwW0h+/PgncUCzCb sEAXQa7rCLOAA1vOa4V52NZ6ABBQOY+G5pPqsAmRatfnlqQ6/bj7zGAd543MtxE5w/we hUsL7ESZgO9loiNy+SwZA8dMkq832WUk1K/liY6t/WP/sZxeZwg3hBSGzUglfwB+tPrv Qh8PzICudDExRF3wZAVMDBmc1KnsXeekdE+P+2MwUYH7scAPdtr9JzfvTdLtlckuyMJR HPpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=8vITF4y5I3Qh2gV4oA1G6ENMes/c4yf/oaIqSyELU/A=; b=vwzRecxFfF+R7v55RTZyyC+n5kc6GS2bFaFEWyomC6LhGdI+xJZ2zloy8o5uaC8OMs qlNDSItjCgGxiwwcDxUPS8AMH/Zzimc5QaeXOSJywm4LWb5jfKyc8So5X9FNw17dWf6f GH25FTK3vxdGphzjSUPaVVcBMrkpCVCCuTjJsZxsZiPAAGCvqoSLX1XjsgrWgPvwdiau vmKmhZpSZO4XbtDjBnPF8Dffyj4/cSJXg3MIBvARiIzwFNRlaMyAB1Ijg1X4S8D2f01O Rj5YXELRHzDYWdi2/hp38UMdCZR/+U93Ngmx9Dwd2hbgg6CjKvVCNvJsJ117sqUlbIkF EMXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ck65D7u9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bh11-20020a170906a0cb00b006e0eb1b6f10si16511086ejb.202.2022.03.30.08.18.35; Wed, 30 Mar 2022 08:19:04 -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=@suse.de header.s=susede2_rsa header.b=ck65D7u9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240904AbiC2TPh (ORCPT + 99 others); Tue, 29 Mar 2022 15:15:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240899AbiC2TPe (ORCPT ); Tue, 29 Mar 2022 15:15:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65FDA24BC6; Tue, 29 Mar 2022 12:13:51 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2372421980; Tue, 29 Mar 2022 19:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1648581230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8vITF4y5I3Qh2gV4oA1G6ENMes/c4yf/oaIqSyELU/A=; b=ck65D7u93Kgsw+DJKq0LsvxejQOPTajh6zrG90DpA9EQ0RVdKIP7h7cZ3UXAOgNycSqrnJ tPbDwyldcWKsLH9w5HGRVvMWq/78FFfIg7g9nFhTLjIXOafVpxWDw2U54l3oZoy1B9zYvx VyAV7j9n8xo3o08As3ERBzoJipB8VcI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1648581230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8vITF4y5I3Qh2gV4oA1G6ENMes/c4yf/oaIqSyELU/A=; b=TqVsSeCz/588wD5Fm9vxZ4m41p58zhiATVblsqqooXov50DRQ0dIpT9mwtOqVZ15qVmmOK vfe9GHN0kqOBkbAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 66A3313A7E; Tue, 29 Mar 2022 19:13:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id t7ScFW1aQ2IOVQAAMHmgww (envelope-from ); Tue, 29 Mar 2022 19:13:49 +0000 Date: Tue, 29 Mar 2022 21:13:47 +0200 From: Oscar Salvador To: Rik van Riel Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@fb.com, Miaohe Lin , Naoya Horiguchi , Mel Gorman , Johannes Weiner , Andrew Morton , stable@vger.kernel.org Subject: Re: [PATCH] mm,hwpoison: unmap poisoned page before invalidation Message-ID: References: <20220325161428.5068d97e@imladris.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220325161428.5068d97e@imladris.surriel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Fri, Mar 25, 2022 at 04:14:28PM -0400, 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 Reviewed-by: Oscar Salvador > --- > 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); > /* 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; > } > -- > 2.35.1 > > > -- Oscar Salvador SUSE Labs