From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C792C433E0 for ; Tue, 16 Mar 2021 14:10:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E2F5F65034 for ; Tue, 16 Mar 2021 14:10:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2F5F65034 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 119486B006C; Tue, 16 Mar 2021 10:10:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CA316B006E; Tue, 16 Mar 2021 10:10:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EABB76B0070; Tue, 16 Mar 2021 10:10:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id CC88D6B006C for ; Tue, 16 Mar 2021 10:10:22 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 87FBF18045E66 for ; Tue, 16 Mar 2021 14:10:22 +0000 (UTC) X-FDA: 77925922284.04.B6CA2D0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 8637840B8CFA for ; Tue, 16 Mar 2021 14:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=RpIzYsONZVEJZLE1jt7u+dlGaRCb33spy6BFUW0m45A=; b=XTlAihbEuYPcJMPno1pjx/UNST nE2yC70Hnu89nvgcvt+kucDbWqQfU4WTyyQCCL+w9YChO9DNYs8AbCj7bgLaz/+l6RZASve2JUiEl WlVV3ZJtTkFzc/ymkzSKJgeLRrrfAwZQ/UkRvpYxe12BEwvRoCZt+Qf1DCeNTI2Dco0iSll0oaT9S EU9gUtxJxEFdzs00LgWtvCf9eOQ6rqj5RZO2iUJtMN1wNLNeOH8PbZXz8GngkIV0O4csis3EAhGSL /Cg687F6vhfvZGOTXx8vaybqr/iJ0G07JzSqoJVAwT1Rq5Teapv2Z6qnbSXAspvP2FgrUETv/LBjM nLkr24Yg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lMAOJ-0009eK-W5; Tue, 16 Mar 2021 14:09:49 +0000 Date: Tue, 16 Mar 2021 14:09:47 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, "Kirill A. Shutemov" , Hugh Dickins , Andi Kleen Subject: File THP and HWPoison Message-ID: <20210316140947.GA3420@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Stat-Signature: j19r9d4k439euxiwci1oigwfrgp6ap1b X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8637840B8CFA Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615903808-16372 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If we get a memory failure in the middle of a file THP, I think we handle it poorly. int memory_failure(unsigned long pfn, int flags) ... if (TestSetPageHWPoison(p)) { ... orig_head = hpage = compound_head(p); ... if (PageTransHuge(hpage)) { if (try_to_split_thp_page(p, "Memory Failure") < 0) { action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); return -EBUSY; } static int try_to_split_thp_page(struct page *page, const char *msg) { lock_page(page); if (!PageAnon(page) || unlikely(split_huge_page(page))) { unsigned long pfn = page_to_pfn(page); unlock_page(page); if (!PageAnon(page)) pr_info("%s: %#lx: non anonymous thp\n", msg, pfn); else pr_info("%s: %#lx: thp split failed\n", msg, pfn); put_page(page); return -EBUSY; So (for some reason) we don't even try to split a file THP. But then, if we take a page fault on a file THP: static struct page *next_uptodate_page(struct page *page, ... if (PageHWPoison(page)) goto skip; (... but we're only testing the head page here, which isn't necessarily the one which got the error ...) if (pmd_none(*vmf->pmd) && PageTransHuge(page)) { vm_fault_t ret = do_set_pmd(vmf, page); So we now map the PMD-sized page into userspace, even though it has a HWPoison in it. I think there are two things that we should be doing: 1. Attempt to split THPs which are file-backed. That makes most of this problem disappear because there won't be THPs with HWPoison, mostly. 2. When the THP fails to split, use a spare page flag to indicate that the THP contains a HWPoison bit in one of its subpages. There are a lot of PF_SECOND flags available for this purpose. but I know almost nothing about the memory-failure subsystem and I'm still learning all the complexities of THPs, so it's entirely possible I've overlooked something important.