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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F985C433EF for ; Wed, 6 Oct 2021 23:57:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 277196113A for ; Wed, 6 Oct 2021 23:57:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 277196113A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7284C900002; Wed, 6 Oct 2021 19:57:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D7E46B0071; Wed, 6 Oct 2021 19:57:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C5D7900002; Wed, 6 Oct 2021 19:57:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 4CA406B006C for ; Wed, 6 Oct 2021 19:57:52 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 03499183E905E for ; Wed, 6 Oct 2021 23:57:52 +0000 (UTC) X-FDA: 78667677984.10.539857E Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf19.hostedemail.com (Postfix) with ESMTP id AC767B001566 for ; Wed, 6 Oct 2021 23:57:51 +0000 (UTC) Received: by mail-ed1-f49.google.com with SMTP id g10so15645828edj.1 for ; Wed, 06 Oct 2021 16:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H3kwNDEY68OIwU8Je8RDowqnTfHPIHgvZzXHiiUTic4=; b=d/kT/ON2cmX4+vA2KqMxHsfjLTtYnJwPqvnfOukGEPxSSZ/GvLYKK8ZqBbxX6/uNRN gX4mSv7tqBcRrv4xthfBorbjKb1F7KThxFM55jvVHjfCIzhbkTY73sAjSXhWNB/qUgxP drtgusD6XAFCdTj0bBWvcER1gw0Q4r+8UBz23u0kYEZtZPSpTGET8E5O1llXAKk5DBxh MT+1EECqLY+IbKScKWrL+bF3HqmiXcamInnjYdDpu7GR0Y4Q5feYToEN5fHIFyG6Hlej MIYR9IMn1pjUbR5iUMnHeZZAjFGTc0wuVsVmRVhhIfyJbyIe0QRmx1+n6pc/XsJvmj9+ aCHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H3kwNDEY68OIwU8Je8RDowqnTfHPIHgvZzXHiiUTic4=; b=D/ngQDst6rH5xFh8kVaFSTKWFYI6w1sWeyF+8JyEgHlTqp8K9SbLsSU3eLeyy0qq4D ljpzNQt3TNllqaOoAPz8IkAlKIXU8k3ZSI+0k556e+X87Paexby64w5UsyvCDig3XYID QdPPf4DLcN+h+r6eV5veliA9TCMcey4hk5TBnR8F+ynrpbYzu8Psahaf+zNfWgjENICm qb8pwH6TZhoRcjNzifd4CH9jIDtNNIzgHxcXfClyhDorP2MQNcAdC84tQNMPFDCPSugL 5eZgV8ySeBiGF5qefgXx3BYWVBkyD9MuVW7vqSY4vuoXCjUwlZQ7h6GFvmOqms2mNrIC 5l7A== X-Gm-Message-State: AOAM5314OSJRWLm7E5zkVy6Lcv5yM97cNOfLRUhPbZp+lhKB4GeDZW6y sbeBbfM7MtJKBfxUBBa+gmC70rMp9CU+kS8S6i0= X-Google-Smtp-Source: ABdhPJwVIbepnjWWz19zXaJafbtP/dZf6+Rn+UlMzvQw55V7S7jLI+XUI3omHo4rLNzH0BN5KP/IIYvljuQdhR1vZjI= X-Received: by 2002:a17:906:c7d0:: with SMTP id dc16mr1495026ejb.555.1633564670339; Wed, 06 Oct 2021 16:57:50 -0700 (PDT) MIME-Version: 1.0 References: <20210930215311.240774-1-shy828301@gmail.com> <20210930215311.240774-3-shy828301@gmail.com> In-Reply-To: From: Yang Shi Date: Wed, 6 Oct 2021 16:57:38 -0700 Message-ID: Subject: Re: [v3 PATCH 2/5] mm: filemap: check if THP has hwpoisoned subpage for PMD page fault To: Peter Xu Cc: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oscar Salvador , Andrew Morton , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: AC767B001566 X-Stat-Signature: cy1greaw95x58p943re5u6zph45zq1ia Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="d/kT/ON2"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-HE-Tag: 1633564671-639648 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 Wed, Oct 6, 2021 at 1:15 PM Peter Xu wrote: > > On Thu, Sep 30, 2021 at 02:53:08PM -0700, Yang Shi wrote: > > @@ -1148,8 +1148,12 @@ static int __get_hwpoison_page(struct page *page) > > return -EBUSY; > > > > if (get_page_unless_zero(head)) { > > - if (head == compound_head(page)) > > + if (head == compound_head(page)) { > > + if (PageTransHuge(head)) > > + SetPageHasHWPoisoned(head); > > + > > return 1; > > + } > > > > pr_info("Memory failure: %#lx cannot catch tail\n", > > page_to_pfn(page)); > > Sorry for the late comments. > > I'm wondering whether it's ideal to set this bit here, as get_hwpoison_page() > sounds like a pure helper to get a refcount out of a sane hwpoisoned page. I'm > afraid there can be side effect that we set this without being noticed, so I'm > also wondering we should keep it in memory_failure(). > > Quotting comments for get_hwpoison_page(): > > * get_hwpoison_page() takes a page refcount of an error page to handle memory > * error on it, after checking that the error page is in a well-defined state > * (defined as a page-type we can successfully handle the memor error on it, > * such as LRU page and hugetlb page). > > For example, I see that both unpoison_memory() and soft_offline_page() will > call it too, does it mean that we'll also set the bits e.g. even when we want > to inject an unpoison event too? unpoison_memory() should be not a problem since it will just bail out once THP is met as the comment says: /* * unpoison_memory() can encounter thp only when the thp is being * worked by memory_failure() and the page lock is not held yet. * In such case, we yield to memory_failure() and make unpoison fail. */ And I think we should set the flag for soft offline too, right? The soft offline does set the hwpoison flag for the corrupted sub page and doesn't split file THP, so it should be captured by page fault as well. And yes for poison injection. But your comment reminds me that get_hwpoison_page() is just called when !MF_COUNT_INCREASED, so it means MADV_HWPOISON still could escape. This needs to be covered too. BTW, I did the test with MADV_HWPOISON, but I didn't test this change (moving flag set after get_page_unless_zero()) since I thought it was just a trivial change and did overlook this case. > > Thanks, > > -- > Peter Xu >