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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 36EF0C433F5 for ; Tue, 21 Sep 2021 19:46:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC9DC61090 for ; Tue, 21 Sep 2021 19:46:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BC9DC61090 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 58AA86B006C; Tue, 21 Sep 2021 15:46:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 539226B0071; Tue, 21 Sep 2021 15:46:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 427876B0072; Tue, 21 Sep 2021 15:46:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id 342F76B006C for ; Tue, 21 Sep 2021 15:46:42 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E121D1820C7BC for ; Tue, 21 Sep 2021 19:46:41 +0000 (UTC) X-FDA: 78612613002.26.CA8E0B2 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf02.hostedemail.com (Postfix) with ESMTP id 9CD637001A0A for ; Tue, 21 Sep 2021 19:46:41 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id u27so657650edi.9 for ; Tue, 21 Sep 2021 12:46:41 -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=iJYskgs7jeBr4yMPVcl+ZyAVeMfifuPZi0z0sZaJTaI=; b=H2Oqb28GkZUnJxi+XNxATp1ZwxbkFpy4WyVjIFkX0sLYvuKupaIJNp261NfGRwZHmx 8MHf+x8yc8WXIBhwlOqWrrTKmcYxdOzEm/J9A5TFjgDtDN3bOukLceGOb40pf6y5bskx WtSGJN4i6MSWXvDFH9Kja4qsmtmnDcexl1no/dRXRBhBnOgGlADwazB8LQaALoHH2xcJ lai+f/+gYK2PV7jrTw1gOsZJeT12TgHdnG3iWa5wZfygK3ab3LodG/WbvCgaIUedHWt1 PB3muu244Ka8GXz/D+I4e/EMxWBzEGuA+5EAl5N2wsrC/bUmob/YcB94fDQbi+T20B3Y P8rg== 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=iJYskgs7jeBr4yMPVcl+ZyAVeMfifuPZi0z0sZaJTaI=; b=AFucBb1gxFQQILFzKfQNdUZcoc2S9Mu87jYUMDP7rftevfq1G07K4rVZ78Q7PGQoBo CHWXRLM2PeJcnSmevUmrD6veJMeiFIPTtD4zxZwJrOu5Y4fQq6UDL7WeKUaO/b/8oQVV QKe/dvM7+D+0cj1qdqlKFDsbogGIaj5dsXg/HFsP9v92QCyC/vOrsQvte+fRlfHenMFj XdvtoXX8k3dmkCi8d0Ev6VxdIVlS0XFI6pOrR7m6twMblDCFSB5PcBKwF0abracwzpR1 bt2/qqq+TXA4zABalGsrpwhS8XsQ7NGEIlgOolUSZ8RNb8y0DbC2vCWx86gKvAcQjoY6 MBNA== X-Gm-Message-State: AOAM532jdF76XF3w5qO5CKR0hCt7fYFvLhp7GEuEA4jqISgMKdaRQBNA 9LgDvqbu9pd/Cg1qt/pdZ0FkYPg5RM1ngTwz9B8= X-Google-Smtp-Source: ABdhPJyKWqGxUmOiDPAkZaf9KvuoLiP56g2D3SFkjxBeNCn1yJ3WWxzbkc9x79vLsbjYIuduZTXEuqTyfGotjuGcUuk= X-Received: by 2002:a50:e044:: with SMTP id g4mr6460669edl.46.1632253600314; Tue, 21 Sep 2021 12:46:40 -0700 (PDT) MIME-Version: 1.0 References: <20210914183718.4236-1-shy828301@gmail.com> <20210914183718.4236-5-shy828301@gmail.com> <20210921095034.GB817765@u2004> In-Reply-To: <20210921095034.GB817765@u2004> From: Yang Shi Date: Tue, 21 Sep 2021 12:46:28 -0700 Message-ID: Subject: Re: [PATCH 4/4] mm: hwpoison: handle non-anonymous THP correctly To: Naoya Horiguchi 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: rspam04 X-Rspamd-Queue-Id: 9CD637001A0A X-Stat-Signature: dpi3556xcx188qq75pzorgqqgk5pkqbn Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=H2Oqb28G; spf=pass (imf02.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1632253601-987185 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, Sep 21, 2021 at 2:50 AM Naoya Horiguchi wrote: > > On Tue, Sep 14, 2021 at 11:37:18AM -0700, Yang Shi wrote: > > Currently hwpoison doesn't handle non-anonymous THP, but since v4.8 THP > > support for tmpfs and read-only file cache has been added. They could > > be offlined by split THP, just like anonymous THP. > > > > Signed-off-by: Yang Shi > > --- > > mm/memory-failure.c | 21 ++++++++++++--------- > > 1 file changed, 12 insertions(+), 9 deletions(-) > > > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > > index 3e06cb9d5121..6f72aab8ec4a 100644 > > --- a/mm/memory-failure.c > > +++ b/mm/memory-failure.c > > @@ -1150,13 +1150,16 @@ static int __get_hwpoison_page(struct page *page) > > > > if (PageTransHuge(head)) { > > /* > > - * Non anonymous thp exists only in allocation/free time. We > > - * can't handle such a case correctly, so let's give it up. > > - * This should be better than triggering BUG_ON when kernel > > - * tries to touch the "partially handled" page. > > + * We can't handle allocating or freeing THPs, so let's give > > + * it up. This should be better than triggering BUG_ON when > > + * kernel tries to touch the "partially handled" page. > > + * > > + * page->mapping won't be initialized until the page is added > > + * to rmap or page cache. Use this as an indicator for if > > + * this is an instantiated page. > > */ > > - if (!PageAnon(head)) { > > - pr_err("Memory failure: %#lx: non anonymous thp\n", > > + if (!head->mapping) { > > + pr_err("Memory failure: %#lx: non instantiated thp\n", > > page_to_pfn(page)); > > return 0; > > } > > How about cleaning up this whole "PageTransHuge()" block? As explained in > commit 415c64c1453a (mm/memory-failure: split thp earlier in memory error > handling), this check was introduced to avoid that non-anonymous thp is > considered as hugetlb and code for hugetlb is executed (resulting in crash). > > With recent improvement in __get_hwpoison_page(), this confusion never > happens (because hugetlb check is done before this check), so this check > seems to finish its role. I see. IIUC the !PageAnon check was used to prevent from mistreating the THP to hugetlb page. But it was actually solved by splitting THP earlier. If so this check definitely could go away since the worst case is split failure. Will fix it in the next version. > > Thanks, > Naoya Horiguchi > > > @@ -1415,12 +1418,12 @@ static int identify_page_state(unsigned long pfn, struct page *p, > > static int try_to_split_thp_page(struct page *page, const char *msg) > > { > > lock_page(page); > > - if (!PageAnon(page) || unlikely(split_huge_page(page))) { > > + if (!page->mapping || 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); > > + if (!page->mapping) > > + pr_info("%s: %#lx: not instantiated thp\n", msg, pfn); > > else > > pr_info("%s: %#lx: thp split failed\n", msg, pfn); > > put_page(page); > > -- > > 2.26.2 > >