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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 27126C433E0 for ; Thu, 18 Mar 2021 14:08:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68B4564F24 for ; Thu, 18 Mar 2021 14:08:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68B4564F24 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E42FB6B0073; Thu, 18 Mar 2021 10:08:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF3496B0075; Thu, 18 Mar 2021 10:08:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6E266B0078; Thu, 18 Mar 2021 10:08:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id A6AD36B0073 for ; Thu, 18 Mar 2021 10:08:47 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 67C6282499A8 for ; Thu, 18 Mar 2021 14:08:47 +0000 (UTC) X-FDA: 77933175894.16.CEDDC11 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf24.hostedemail.com (Postfix) with ESMTP id C90EBA001A93 for ; Thu, 18 Mar 2021 14:08:45 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id a198so4802595lfd.7 for ; Thu, 18 Mar 2021 07:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=SAGMtQcyhaMI2BE9VR5ekDV7JyHhHXwMFSzlybUfSX8=; b=edC/lLlsNSmczr4ZBPlLOCDfKz0CZuZr9g3d2BWXCIqY196AYIYmpEtC6f5UoLJiQi Pe2Y7eSFP9T7Vx4+QHmQMSTLzqeoAaLGxubBPWjBB0MAzYnBvCRGEKSN3M29qBf3JPox 1YUNf8HGkJ+jVMRyRTlHYO+XXFBfS5M0reIKoJcziKbeTl4wQhzFUC32a40xdFit8JW/ e3MQvz/pRsKSIyAlLFhZNszbxcgpV+3030ec9cHu8lIavFDbgM+IcQcnEFhcAm/J1BPT dLhQR2uScRNf8VToR6ng0V/OnCqxiL7GwN622zIbhhEDHv90G653g0iTcjw1qEM1KSeQ i0Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SAGMtQcyhaMI2BE9VR5ekDV7JyHhHXwMFSzlybUfSX8=; b=ShFcpKDbVtQc1yymXaPgNGQhfWauhGjA1Teck+SrST9OBsivbZnM29AO2pbusLAOgi R9KWLCy+behV0Uo0tkmVWllSESigefFducBuuhNmulw4olQ47sr0niEBEjQgm2ss7vfl KYzpBOLYbzQ9w7ovopLrysWoM1O+w1QzQXB4uDkpmFNTq5qob1WJpdky1HHXW/HjQPf0 Qqlh+RZZ7O4Dj8Ew0vqcUIJ0SxGtlNIVJQgKacL6m8S+csrmRr9f94YS51KvYmUh54+E iaC7nosQPjb8IybPg+ZfbSFmmvI90ygDOinbzsI5oZtf1Cx7KkCDk/NkaesJs78yUHyM jkVQ== X-Gm-Message-State: AOAM533D5y/7EW8ghE7YQ8cZBcJcyRSjzBfJqytcsqpyeL86AKz93gix mazIwAS34Hl0u8dgwITHYcWW6A== X-Google-Smtp-Source: ABdhPJx+mm9FksNqMFJPLMLYOX9ncoTTfgo3TSXK2g0rA5zlWrMPm+Dsy87PFfOZANu6Lv9y3g168w== X-Received: by 2002:a05:6512:1054:: with SMTP id c20mr5481902lfb.170.1616076518959; Thu, 18 Mar 2021 07:08:38 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id 30sm241267lfr.200.2021.03.18.07.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:08:38 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id E0A08101A69; Thu, 18 Mar 2021 17:08:43 +0300 (+03) Date: Thu, 18 Mar 2021 17:08:43 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox , Naoya Horiguchi Cc: linux-mm@kvack.org, "Kirill A. Shutemov" , Hugh Dickins , Andi Kleen Subject: Re: File THP and HWPoison Message-ID: <20210318140843.7dv3wnxg4geplrjx@box> References: <20210316140947.GA3420@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210316140947.GA3420@casper.infradead.org> X-Stat-Signature: nn7mtjzztnosj1bnurhbzhoz7njg9cen X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C90EBA001A93 Received-SPF: none (shutemov.name>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-lf1-f44.google.com; client-ip=209.85.167.44 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616076525-619251 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: On Tue, Mar 16, 2021 at 02:09:47PM +0000, Matthew Wilcox wrote: > 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. +Naoya. Could you give more context here? > 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. I wounder if it would be cleaner to switch PG_hwpoison to PF_HEAD: if split failed we posion whole compound page. Yes, we will waste more memory, but it makes it much cleaner for user: just check if the page is poisoned. -- Kirill A. Shutemov