From patchwork Wed Jun 24 15:01:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14C5E912 for ; Wed, 24 Jun 2020 15:04:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CC555206C0 for ; Wed, 24 Jun 2020 15:04:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W+u5EdOV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC555206C0 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 C18846B0031; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BEE7E6B0033; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B041A6B0036; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id 96ECB6B0031 for ; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 569E052B0 for ; Wed, 24 Jun 2020 15:04:39 +0000 (UTC) X-FDA: 76964427078.25.sleet31_2b17cd926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id EE8EE18024AE7 for ; Wed, 24 Jun 2020 15:02:15 +0000 (UTC) X-Spam-Summary: 1,0,0,e5e90fb9923f1898,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2693:2899:3138:3139:3140:3141:3142:3353:3865:3866:3868:3870:3872:3874:4321:5007:6119:6120:6261:6653:7576:7901:7903:8957:9413:10004:11026:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:14110:14181:14394:14721:21060:21080:21444:21627:21666:21990:22119:30012:30054,0,RBL:209.85.210.195:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y89ugnop3zt5hgxtw84dx5imgiiycwjrruke9i1pnp3ghmwbmgg6ng74acuhz.sirwfnw53onwodczxjyznpf8q9qs4nwzibzd673c3cdp3zx643ss5zkr8uwo8gg.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: sleet31_2b17cd926e45 X-Filterd-Recvd-Size: 5805 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:14 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id b5so1270200pfp.9 for ; Wed, 24 Jun 2020 08:02:14 -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:in-reply-to:references; bh=joeQ3SaeYT7GDsb9cUatgWWRJkFAFZeG8Ak2AOs52Qk=; b=W+u5EdOVfTsbqirIRrlaAE605oWdqSInb8/ROWc9uVHpy8/ZacyCg8Cvx1/hmSHNe1 3t51LQ0cHlHri3xOg02J38+lDjmHh3wBw+foyeO/wqb7929YCVjbddys+s8+dI/LS4PF Sxzxf7Hvc2UfpdsS/ehNrjqX3Ph4Hd7h7xsGsSHcfMvWKYD4GpjEA7zaZ9nlGM5Akg3O 6AoX+kE0TccktjuQ7LhdFewIo+XHlINyZtQLSBwnBBCsiqP2M/uf5J+HSW4MHyciDwnx wYGY1PXBe/Snv92WcoAbx1wMStUJ9ssnqFHSnEd6DMBPvYVhD1BoaWW6rUThQAGdqPXA 0bvw== 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:in-reply-to :references; bh=joeQ3SaeYT7GDsb9cUatgWWRJkFAFZeG8Ak2AOs52Qk=; b=M6SFZvHP+VPb/drHF6Dgk+nz8XOtr7vDxUXB6KUP6CkYtmHmjMFCAAAROaNTYK7xg3 yaqyfjl91NBytH6LMt/BCH3+eyRnUox42eu/TB7OAOOsiucImkw6dVs/1rIQ45m+vJ5B 84aZjpdkm94FjK9eUsorkGI7L15Ycq08WFHwX4uODW3UBWPcNdXiodcijV/pTemI0Y1Q o93/dBE6umLSbe/ilVusz1ApIo0afZ0Du79/Zk/BMNdEbCqfG+8EYaHc4kBAq/v4fBOa EWGoG9HG3lLo0m31E2aYSnUzbeL3UFXwNQ7omBnNEucMWCn6J/j74IJS9NSyxrLRVR4I mldA== X-Gm-Message-State: AOAM533qrFsMggbc5pYixJCM5JQUfhoSEmExz0ywAkcHr/6qSQ+DTqvR UDQ/N8lEaxo2XEBR62hjpwSgAYd/IQ== X-Google-Smtp-Source: ABdhPJztXHW2r62m+tAG4OOCPW60g7TBHFl5rgmkuHiE/2l+QSOogErW+UJQ+iv40PhXFbMvLae0OA== X-Received: by 2002:a62:1716:: with SMTP id 22mr2825390pfx.99.1593010933234; Wed, 24 Jun 2020 08:02:13 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:12 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/15] mm,hwpoison: Unify THP handling for hard and soft offline Date: Wed, 24 Jun 2020 15:01:32 +0000 Message-Id: <20200624150137.7052-11-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: EE8EE18024AE7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Oscar Salvador Place the THP's page handling in a helper and use it from both hard and soft-offline machinery, so we get rid of some duplicated code. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 48 +++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 03d3aae77f89..2e244d5b83e0 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1103,6 +1103,25 @@ static int identify_page_state(unsigned long pfn, struct page *p, return page_action(ps, p, pfn); } +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; + } + unlock_page(page); + + return 0; +} + static int memory_failure_hugetlb(unsigned long pfn, int flags) { struct page *p = pfn_to_page(pfn); @@ -1325,21 +1344,8 @@ int memory_failure(unsigned long pfn, int flags) } if (PageTransHuge(hpage)) { - lock_page(p); - if (!PageAnon(p) || unlikely(split_huge_page(p))) { - unlock_page(p); - if (!PageAnon(p)) - pr_err("Memory failure: %#lx: non anonymous thp\n", - pfn); - else - pr_err("Memory failure: %#lx: thp split failed\n", - pfn); - if (TestClearPageHWPoison(p)) - num_poisoned_pages_dec(); - put_page(p); + if (try_to_split_thp_page(p, "Memory Failure") < 0) return -EBUSY; - } - unlock_page(p); VM_BUG_ON_PAGE(!page_count(p), p); } @@ -1847,19 +1853,9 @@ static int soft_offline_in_use_page(struct page *page) int mt; struct page *hpage = compound_head(page); - if (!PageHuge(page) && PageTransHuge(hpage)) { - lock_page(page); - if (!PageAnon(page) || unlikely(split_huge_page(page))) { - unlock_page(page); - if (!PageAnon(page)) - pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); - else - pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); - put_page(page); + if (!PageHuge(page) && PageTransHuge(hpage)) + if (try_to_split_thp_page(page, "soft offline") < 0) return -EBUSY; - } - unlock_page(page); - } /* * Setting MIGRATE_ISOLATE here ensures that the page will be linked