From patchwork Tue Feb 9 06:21:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12077183 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 206D2C433E0 for ; Tue, 9 Feb 2021 06:21:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB21164E54 for ; Tue, 9 Feb 2021 06:21:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB21164E54 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 244C76B006E; Tue, 9 Feb 2021 01:21:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F4426B0070; Tue, 9 Feb 2021 01:21:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BE468D0001; Tue, 9 Feb 2021 01:21:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id EABA66B006E for ; Tue, 9 Feb 2021 01:21:56 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B8FB6182BF2CD for ; Tue, 9 Feb 2021 06:21:56 +0000 (UTC) X-FDA: 77797733832.10.smell05_3b042bf27605 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 9829316A4D3 for ; Tue, 9 Feb 2021 06:21:56 +0000 (UTC) X-HE-Tag: smell05_3b042bf27605 X-Filterd-Recvd-Size: 5438 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 06:21:56 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id 8so9151017plc.10 for ; Mon, 08 Feb 2021 22:21:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Vd+xhAcgBsLbPJd1UskDha5fm3PtDxfa+KAFetZcNso=; b=lC+QJpnFvcu1PQ/kXnWXGbYmb9EJpF9dQkoSCvfumVwfLMQjHaH5hvybL17OvbRHAv YLfKD5xyj6NMpQqusqOosayNQ8h8G8sJbeM2xyEa7k7k54gjil9e7jj1R2a0OmpAdaXh NN0jFKOmMlBdBNAt04PdLeoByhgzRfxh0F/kkwech4UtjlndJh7x+f/yMUh4U9l/RkE5 iLxuEahMp+t7pHy1QbHNCc9iF3cL2jFy70j0hMHgTNeRfU/ng47wIZd4Dpwg1dJs+Qc5 VTAfROE2zB4iK9/KyXYjryjPjSdcJ0BB2E+x6gIRccNvCrF5jhwCvZLojikHjt7rpqwn +UjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Vd+xhAcgBsLbPJd1UskDha5fm3PtDxfa+KAFetZcNso=; b=dWEOpSBDpGNxWH0/JtuSBPKZJzf3/950b89YWecA4nEy89exWRlOb5jqlrk+Npn/6w XqzrsSyUtbVWBP1919CQAQmyhD6mh9LLPLI3XN9tb0PuN7WRYR2Uhv65Vt1D3Y3AN4RA Szuo4cEeUynF0HSo5eganNYHq2ip4a7JaeYdPq9DJiQ5S1F5jitUl4ZpW2enW5jMkf8T M/ysGzqDHXDD7TGd/6PaChD2S6Au4mL0EUwqKgqFPseeLHFUzVlzHz9GqW8zMRWl+ycr /fraUV+fTiGMPTRDofCVSs8IYhiZ1/+uFc/dYaPQlyKJvo9l3m1JusfA5Gk3G3bsnc+y tYkg== X-Gm-Message-State: AOAM530s56xUIbkAXhxQQ12HZlbFErmttheANZwn/P7y6f2tldJl1ekk CKDWq6cTgeeYLvKCXt23iryww16bvw== X-Google-Smtp-Source: ABdhPJzVXN9g1S2bv3NJQKxCF8BVat+WlAZomggEOZ4GPOqbopf6tq7zJolHSseP/aDLcJC7bJqxkQ== X-Received: by 2002:a17:902:309:b029:e1:536b:4ab with SMTP id 9-20020a1709020309b02900e1536b04abmr20067016pld.65.1612851715076; Mon, 08 Feb 2021 22:21:55 -0800 (PST) Received: from localhost.localdomain (h175-177-040-128.catv02.itscom.jp. [175.177.40.128]) by smtp.gmail.com with ESMTPSA id r15sm21663826pgh.39.2021.02.08.22.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 22:21:53 -0800 (PST) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Michal Hocko , Oscar Salvador , Tony Luck , Matthew Wilcox , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1] mm, hwpoison: enable error handling on shmem thp Date: Tue, 9 Feb 2021 15:21:28 +0900 Message-Id: <20210209062128.453814-1-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: From: Naoya Horiguchi Currently hwpoison code checks PageAnon() for thp and refuses to handle errors on non-anonymous thps (just for historical reason). We now support non-anonymou thp like shmem one, so this patch suggests to enable to handle shmem thps. Fortunately, we already have can_split_huge_page() to check if a give thp is splittable, so this patch relies on it. Signed-off-by: Naoya Horiguchi Reviewed-by: Oscar Salvador Signed-off-by: Jue Wang Signed-off-by: Hugh Dickins --- mm/memory-failure.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git v5.11-rc6/mm/memory-failure.c v5.11-rc6_patched/mm/memory-failure.c index e9481632fcd1..8c1575de0507 100644 --- v5.11-rc6/mm/memory-failure.c +++ v5.11-rc6_patched/mm/memory-failure.c @@ -956,20 +956,6 @@ static int __get_hwpoison_page(struct page *page) { struct page *head = compound_head(page); - if (!PageHuge(head) && 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. - */ - if (!PageAnon(head)) { - pr_err("Memory failure: %#lx: non anonymous thp\n", - page_to_pfn(page)); - return 0; - } - } - if (get_page_unless_zero(head)) { if (head == compound_head(page)) return 1; @@ -1197,21 +1183,19 @@ 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))) { - unsigned long pfn = page_to_pfn(page); + struct page *head; + lock_page(page); + head = compound_head(page); + if (PageTransHuge(head) && can_split_huge_page(head, NULL) && + !split_huge_page(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; + return 0; } + pr_info("%s: %#lx: thp split failed\n", msg, page_to_pfn(page)); unlock_page(page); - - return 0; + put_page(page); + return -EBUSY; } static int memory_failure_hugetlb(unsigned long pfn, int flags)