From patchwork Fri Jul 31 12:21:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11694845 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 522241392 for ; Fri, 31 Jul 2020 12:21:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1EB282087C for ; Fri, 31 Jul 2020 12:21:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XsLxJoNa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EB282087C 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 C43248D0037; Fri, 31 Jul 2020 08:21:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD09F8D0036; Fri, 31 Jul 2020 08:21:50 -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 A47EB8D0037; Fri, 31 Jul 2020 08:21:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 87C598D0036 for ; Fri, 31 Jul 2020 08:21:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4D6AB8248047 for ; Fri, 31 Jul 2020 12:21:50 +0000 (UTC) X-FDA: 77098282380.09.drain96_621158926f83 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 24176180AD802 for ; Fri, 31 Jul 2020 12:21:50 +0000 (UTC) X-Spam-Summary: 1,0,0,fcdad90314e4fe49,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:6742:7576:7901:7903:8957:9413:10004:11026:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:12986:14110:14181:14394:14721:21060:21080:21444:21627:21666:21990:22119:30012:30054,0,RBL:209.85.214.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y83oagm3j1kwc3oz5atoy9s84fwocwjrruke9i1pnp3ghmwbn4a1ze9gbge51.164c5bwowsdcyqitcx3d58k9i8qs4nwzibz9ar1d6tacm4ghk9buprxcc57kdyd.o-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:25,LUA_SUMMARY:none X-HE-Tag: drain96_621158926f83 X-Filterd-Recvd-Size: 5829 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 12:21:49 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id d1so17218229plr.8 for ; Fri, 31 Jul 2020 05:21:49 -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=xft2h5FohjfWqnBcTKXmA02wYQ8Sl17A7am29j5Mcz4=; b=XsLxJoNaCXyJMenZtH47jIDCecoY0NPI+oIT8mRxAwzFTQwvpVYtgrQmDqoCxZQS2j OkQkZGa3bB3lohBRuKB4KlRF1cx/nqhc0jF/j4qh/VIokvCJE/16aoZ5M9AZTi0NuXX3 ZVZOFHbJ9fQLxe5QccT/2LDXZuD33zVxYF4GPW5RRutWLf5Q9SES9ZTablJGOKNbEa0G 4rfMnwIjlYFSHvnXE10SIrnzcMOPyUJxusBJGs9YEXWBYjVEt0pfqwuMxr4KYzzUtQ3M n78Up05OOiIafcJ4Nm6qBQV/6LafOamSVbp03LF4yxx8MKuKXcUS6Bwsjbvhu0uaPTeD jhFA== 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=xft2h5FohjfWqnBcTKXmA02wYQ8Sl17A7am29j5Mcz4=; b=mA6wST391Mv9AnHBQyrSGXKTNwFDFWrD7zoRkz6Kum6oECUyNj+UmsnkEK8+NZ0dhX 7OhIdjLkEIxGWqWBk0zNcAbmwmvU8RY1req8ioJcYnSOiaNe702lN2Djz9lM89mGGlWY AsKBM1NXI14mfbAhuuLugQebcjmd4q53IoiTFJEcLprZ0ZLfXBPFxybmeMU80P0NDXox A0hDFjKn5IfYxaO4MDV/F6lo1+HpLTKZqKVuNMybtxi3j7Y+0sBbLPtNRTPO4Oq9NQnj e86cJq99bShXaivx7Fyd2YZtETRg/IjN6W2U6HiNeILUH6C3ItyKVRp6qi91p5wGWjnG AP/Q== X-Gm-Message-State: AOAM530Vt0O8phrSDoXUMKTcRS1gA7PU8m2nAHpqPeNuSuAsETrG/ypu VatZA/7WBP+bH6sYEs635XhOf2y2sQ== X-Google-Smtp-Source: ABdhPJyyOpZYacooGR5RU61olGUZyx0GrN1JXL6Y1g3Sx4pMqV32qBOed44LN62ckgW/2WaK7H+Lcw== X-Received: by 2002:a17:90b:4d0f:: with SMTP id mw15mr3787072pjb.174.1596198108893; Fri, 31 Jul 2020 05:21:48 -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 m19sm3675692pjv.34.2020.07.31.05.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 05:21:48 -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, cai@lca.pw, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v5 10/16] mm,hwpoison: Unify THP handling for hard and soft offline Date: Fri, 31 Jul 2020 12:21:06 +0000 Message-Id: <20200731122112.11263-11-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731122112.11263-1-nao.horiguchi@gmail.com> References: <20200731122112.11263-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 24176180AD802 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: 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-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c v5.8-rc7-mmotm-2020-07-27-18-18_patched/mm/memory-failure.c index 7c0a2f8cfe0c..803f4b2ac510 100644 --- v5.8-rc7-mmotm-2020-07-27-18-18/mm/memory-failure.c +++ v5.8-rc7-mmotm-2020-07-27-18-18_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); } @@ -1844,19 +1850,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