From patchwork Tue Aug 30 10:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 12959080 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF7A9C0502A for ; Tue, 30 Aug 2022 10:42:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34A2D6B0073; Tue, 30 Aug 2022 06:42:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F9F0940007; Tue, 30 Aug 2022 06:42:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C0DB6B0075; Tue, 30 Aug 2022 06:42:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 09FED6B0073 for ; Tue, 30 Aug 2022 06:42:00 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D39ECA7337 for ; Tue, 30 Aug 2022 10:41:59 +0000 (UTC) X-FDA: 79855918758.17.0045D79 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf09.hostedemail.com (Postfix) with ESMTP id D195714003E for ; Tue, 30 Aug 2022 10:41:58 +0000 (UTC) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MH3gD6QBkzkWng; Tue, 30 Aug 2022 18:38:16 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 30 Aug 2022 18:41:55 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 30 Aug 2022 18:41:54 +0800 From: Kefeng Wang To: Andrew Morton , CC: , Kefeng Wang , Miaohe Lin , Naoya Horiguchi Subject: [PATCH v2] mm: memory-failure: kill __soft_offline_page() Date: Tue, 30 Aug 2022 18:46:54 +0800 Message-ID: <20220830104654.28234-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 Reply-To: <20220830071514.GA1106752@hori.linux.bs1.fc.nec.co.jp> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661856119; a=rsa-sha256; cv=none; b=BqpnMMbHX5vbiBbnZ9OBbGo6PdO3bT5AVr8j5OUuummD74B+U/SRILnAtrlhEO11Mq+N3z 29yxB+2++1s83qc4iQtz2CPEBoH6TVUB8rROfxamBbC6sNdXp6Bra6jqmabuXjI4Z1+oNN uhPuiSJKxlRSCpqRktqQuj2muBMi9Dw= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661856119; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=ycWpjMKbjko+SO7tF0aZ9jIaqgoIuxLm60+HU9G7fVY=; b=vpfXfDNBTlZ4YCcCpYAJ5unokxY7ZWEQRfh5EYrRecX7JmNBvnYGLUPPIr2Y5CW2tzliCq XIQYdAvWRukaMALc9/Iy0qJsYFgmu+YcwV0wH859Vuz/UJkD39dyKqMwMQ2843RL83y6af TYQkflI3RJsXUVZzQNULmOt7GYUp/M8= Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: hahhxx98kdp458o7kggtdqok13knjimi X-Rspamd-Queue-Id: D195714003E X-HE-Tag: 1661856118-975184 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: Squash the __soft_offline_page() into soft_offline_in_use_page() and kill __soft_offline_page(). Signed-off-by: Kefeng Wang Reviewed-by: Miaohe Lin Acked-by: Naoya Horiguchi Reviewed-by: David Hildenbrand Reviewed-by: Anshuman Khandual --- v2: update hpage when try_to_split_thp_page() success mm/memory-failure.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b61f2de9f2a1..df54a6bc9bef 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2434,11 +2434,11 @@ static bool isolate_page(struct page *page, struct list_head *pagelist) } /* - * __soft_offline_page handles hugetlb-pages and non-hugetlb pages. + * soft_offline_in_use_page handles hugetlb-pages and non-hugetlb pages. * If the page is a non-dirty unmapped page-cache page, it simply invalidates. * If the page is mapped, it migrates the contents over. */ -static int __soft_offline_page(struct page *page) +static int soft_offline_in_use_page(struct page *page) { long ret = 0; unsigned long pfn = page_to_pfn(page); @@ -2451,6 +2451,14 @@ static int __soft_offline_page(struct page *page) .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, }; + if (!huge && PageTransHuge(hpage)) { + if (try_to_split_thp_page(page)) { + pr_info("soft offline: %#lx: thp split failed\n", pfn); + return -EBUSY; + } + hpage = page; + } + lock_page(page); if (!PageHuge(page)) wait_on_page_writeback(page); @@ -2500,19 +2508,6 @@ static int __soft_offline_page(struct page *page) return ret; } -static int soft_offline_in_use_page(struct page *page) -{ - struct page *hpage = compound_head(page); - - if (!PageHuge(page) && PageTransHuge(hpage)) - if (try_to_split_thp_page(page) < 0) { - pr_info("soft offline: %#lx: thp split failed\n", - page_to_pfn(page)); - return -EBUSY; - } - return __soft_offline_page(page); -} - static void put_ref_page(struct page *page) { if (page)