From patchwork Thu Jun 17 09:26:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12327099 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,USER_AGENT_GIT autolearn=unavailable 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 66B68C49EA2 for ; Thu, 17 Jun 2021 09:26:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F62A61185 for ; Thu, 17 Jun 2021 09:26:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F62A61185 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 9E7436B0070; Thu, 17 Jun 2021 05:26:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BE026B0071; Thu, 17 Jun 2021 05:26:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85F006B0072; Thu, 17 Jun 2021 05:26:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id 562A36B0070 for ; Thu, 17 Jun 2021 05:26:41 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 565F01263B for ; Thu, 17 Jun 2021 09:26:39 +0000 (UTC) X-FDA: 78262685718.40.33D7C77 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf02.hostedemail.com (Postfix) with ESMTP id EB3814202A14 for ; Thu, 17 Jun 2021 09:26:32 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id m2so4467245pgk.7 for ; Thu, 17 Jun 2021 02:26:38 -0700 (PDT) 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=KryS05F8yykdJ8/Bn8WDRh+2BxDJ+KUha/fXyOsgM+k=; b=mwkZAfu8nN4ynVz14N+KSOMx2lFJa0zpV6jz3LMyfqwWkVuUXcNe0X4Fmgf6P8LnWp nfVYEamHkpIyn9n5G4puh42hw9uY3AKFIf7j+C1OoVpJC7RRJ0L2g5+QDEgFTrBJcoDl bhZiSiNwD/KckITc8WjOyzFTtEXQlf2uH/GyT+4R4Qju7yKFVxqOlX+8CRTWJ+K1EVV1 olMd3mcghY9eIKCe6rOBwZVjOcrv76f0C/qizyrWw2kx36yLLSoBMZZb7zMr1hI3CAu/ rHoLsuKfIwf4FrRVutQH41m4bF2WT5kZcKb3HdHmK9bwJ+QPjUbf5HRbZK0a9EYjeVIZ t4gw== 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=KryS05F8yykdJ8/Bn8WDRh+2BxDJ+KUha/fXyOsgM+k=; b=cef0Xw7r2JXb1lRud6LnCOUJMulc9vlN9RAhvMkmf6gtTN0D9hrsiUM05SvGdCCXUg OwcvB9m9jIVb7neKDOUSxbrB4bioWmduLW5LapkLznWoQXL7uFG3itJvNCNFCpbYWCC9 JhFmFEyhtCbeRQ4EeLQZ5EM58hCHPAl+wZIZ0DrToF2sT7BGwVcrIalSS6u6vLGMwQEK Xgq9Zff5UKX/zC8TiAsoWsYeSKsaF5mCsSRK2EdPiJWFKEqKqj5AyEXlBdWppRlwTYmo mp2UdCbkWYelfFIYSXAIoC9XlShVEDHmIUDAnfN3GsQvIvF/Frgu5MIt8AHX4+2d8+Fj Er2g== X-Gm-Message-State: AOAM533wrMVQ9GmC5LDdaX8WQK5vmBhhd7iqWc2aoRA6dvONyEkNTYMs C/ZOVJ2GQxD1EZuZIaSFdviURmPMnSH+ X-Google-Smtp-Source: ABdhPJwGLC8Fu6UDSezxtpMdxDFypGbC7quTIZJN3STK+uD+rnZ1Wpq13LqooTXVoT7ko+VN42dZfQ== X-Received: by 2002:a05:6a00:bc7:b029:2f5:7bdb:f694 with SMTP id x7-20020a056a000bc7b02902f57bdbf694mr4355722pfu.41.1623921997787; Thu, 17 Jun 2021 02:26:37 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id b65sm4635030pfa.32.2021.06.17.02.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 02:26:37 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Mel Gorman , Mike Kravetz , David Hildenbrand , Oscar Salvador , Michal Hocko , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH mmotm v1] mm/hwpoison: disable pcp for page_handle_poison() Date: Thu, 17 Jun 2021 18:26:26 +0900 Message-Id: <20210617092626.291006-1-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mwkZAfu8; spf=pass (imf02.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EB3814202A14 X-Stat-Signature: wghefotw9rhfenqqq63tj1wn8sb7f86y X-HE-Tag: 1623921992-248968 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 Recent changes by patch "mm/page_alloc: allow high-order pages to be stored on the per-cpu lists" makes kernels determine whether to use pcp by pcp_allowed_order(), which breaks soft-offline for hugetlb pages. Soft-offline dissolves a migration source page, then removes it from buddy free list, so it's assumed that any subpage of the soft-offlined hugepage are recognized as a buddy page just after returning from dissolve_free_huge_page(). pcp_allowed_order() returns true for hugetlb, so this assumption is no longer true. So disable pcp during dissolve_free_huge_page() and take_page_off_buddy() to prevent soft-offlined hugepages from linking to pcp lists. Soft-offline should not be common events so the impact on performance should be minimal. And I think that the optimization of Mel's patch could benefit to hugetlb so zone_pcp_disable() is called only in hwpoison context. Signed-off-by: Naoya Horiguchi Acked-by: Mel Gorman --- mm/memory-failure.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git v5.13-rc6-mmotm-2021-06-15-20-24/mm/memory-failure.c v5.13-rc6-mmotm-2021-06-15-20-24_patched/mm/memory-failure.c index 1842822a10da..593079766655 100644 --- v5.13-rc6-mmotm-2021-06-15-20-24/mm/memory-failure.c +++ v5.13-rc6-mmotm-2021-06-15-20-24_patched/mm/memory-failure.c @@ -66,6 +66,19 @@ int sysctl_memory_failure_recovery __read_mostly = 1; atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); +static bool __page_handle_poison(struct page *page) +{ + bool ret; + + zone_pcp_disable(page_zone(page)); + ret = dissolve_free_huge_page(page); + if (!ret) + ret = take_page_off_buddy(page); + zone_pcp_enable(page_zone(page)); + + return ret; +} + static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, bool release) { if (hugepage_or_freepage) { @@ -73,7 +86,7 @@ static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, boo * Doing this check for free pages is also fine since dissolve_free_huge_page * returns 0 for non-hugetlb pages as well. */ - if (dissolve_free_huge_page(page) || !take_page_off_buddy(page)) + if (!__page_handle_poison(page)) /* * We could fail to take off the target page from buddy * for example due to racy page allocation, but that's @@ -986,7 +999,7 @@ static int me_huge_page(struct page *p, unsigned long pfn) */ if (PageAnon(hpage)) put_page(hpage); - if (!dissolve_free_huge_page(p) && take_page_off_buddy(p)) { + if (__page_handle_poison(p)) { page_ref_inc(p); res = MF_RECOVERED; } @@ -1441,7 +1454,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) res = get_hwpoison_page(p, flags); if (!res) { res = MF_FAILED; - if (!dissolve_free_huge_page(p) && take_page_off_buddy(p)) { + if (__page_handle_poison(p)) { page_ref_inc(p); res = MF_RECOVERED; }