From patchwork Fri Aug 19 03:34:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 12948276 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 D8775C28B2B for ; Fri, 19 Aug 2022 03:28:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 899888D0002; Thu, 18 Aug 2022 23:28:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D8B58E0001; Thu, 18 Aug 2022 23:28:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ED1A8D0002; Thu, 18 Aug 2022 23:28:38 -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 309D38D0003 for ; Thu, 18 Aug 2022 23:28:38 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E1D4BC020B for ; Fri, 19 Aug 2022 03:28:37 +0000 (UTC) X-FDA: 79814909874.12.BE9F55E Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf22.hostedemail.com (Postfix) with ESMTP id F30EEC0078 for ; Fri, 19 Aug 2022 03:28:35 +0000 (UTC) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4M86ZZ3dCBz1N7SG; Fri, 19 Aug 2022 11:25:10 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 19 Aug 2022 11:28:33 +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; Fri, 19 Aug 2022 11:28:33 +0800 From: Kefeng Wang To: Naoya Horiguchi , Miaohe Lin , Andrew Morton CC: , , Kefeng Wang Subject: [PATCH 1/2] mm: memory-failure: kill soft_offline_free_page() Date: Fri, 19 Aug 2022 11:34:01 +0800 Message-ID: <20220819033402.156519-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660879716; a=rsa-sha256; cv=none; b=xNgLluD7N3VahxmubukWYBGuOv+CU8x/ABIpcBGt5HE+ZGVFFSKBTTERRZrOc1vj5laeDF OcqRgUbWqhIfSWGGrJb9fXMGHrfQBQ+Q93IbsYvBGerIDYWPRZQ6leJndOku3I6nvQ30M4 G6r515PpO6DcD7DSXKkv31Ks8mEOI8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660879716; h=from:from:sender: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=m3tbaSKRGMDglQppPfP65xQpGSp07VjZnTUTiU0mD0w=; b=mFXb7TRwvEm1pDdHWZUzMnv5Bup0BJtTwIA8QnkPkI/8L6pBcqu8AJkhVFsRlxeNHko8fb gXNVGwR6jQ1AmPIrnsx8uC7y8wn/G0O4FLI9gito6rh34w+PdA205NMlDGDRe1KkTAxhkj E8ogfD3FTEBbJjRWdvhHKyekAnTAiYc= X-Rspamd-Queue-Id: F30EEC0078 Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam01 X-Rspam-User: X-Stat-Signature: 6tkf64u9c1jjharwzgqipp53xgwwxchg X-HE-Tag: 1660879715-382575 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: Open-code the page_handle_poison() into soft_offline_page() and kill unneeded soft_offline_free_page(). Signed-off-by: Kefeng Wang Acked-by: Naoya Horiguchi Reviewed-by: Miaohe Lin --- mm/memory-failure.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e48f6f6a259d..1a7d6548ccb2 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2511,16 +2511,6 @@ static int soft_offline_in_use_page(struct page *page) return __soft_offline_page(page); } -static int soft_offline_free_page(struct page *page) -{ - int rc = 0; - - if (!page_handle_poison(page, true, false)) - rc = -EBUSY; - - return rc; -} - static void put_ref_page(struct page *page) { if (page) @@ -2598,7 +2588,7 @@ int soft_offline_page(unsigned long pfn, int flags) if (ret > 0) { ret = soft_offline_in_use_page(page); } else if (ret == 0) { - if (soft_offline_free_page(page) && try_again) { + if (!page_handle_poison(page, true, false) && try_again) { try_again = false; flags &= ~MF_COUNT_INCREASED; goto retry; From patchwork Fri Aug 19 03:34:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 12948275 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 09C08C00140 for ; Fri, 19 Aug 2022 03:28:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6010B8D0005; Thu, 18 Aug 2022 23:28:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58AF08D0003; Thu, 18 Aug 2022 23:28:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 402968D0005; Thu, 18 Aug 2022 23:28:38 -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 291088D0002 for ; Thu, 18 Aug 2022 23:28:38 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E9778140107 for ; Fri, 19 Aug 2022 03:28:37 +0000 (UTC) X-FDA: 79814909874.11.899ABCC Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf24.hostedemail.com (Postfix) with ESMTP id DD6BA180010 for ; Fri, 19 Aug 2022 03:28:36 +0000 (UTC) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M86bw2K4lznTcd; Fri, 19 Aug 2022 11:26:20 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 19 Aug 2022 11:28:33 +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; Fri, 19 Aug 2022 11:28:33 +0800 From: Kefeng Wang To: Naoya Horiguchi , Miaohe Lin , Andrew Morton CC: , , Kefeng Wang Subject: [PATCH 2/2] mm: memory-failure: kill __soft_offline_page() Date: Fri, 19 Aug 2022 11:34:02 +0800 Message-ID: <20220819033402.156519-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220819033402.156519-1-wangkefeng.wang@huawei.com> References: <20220819033402.156519-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660879716; a=rsa-sha256; cv=none; b=yFVzIik8MjT/5qPr1XNXYZci0y8HcIkYuYDGFPgJR4/VbEUYnI8vtXOsWkVwsfg1wZy2Mb cC8U4afvY9FPK/CEEgSehkTNw2YtIh6OgouQuvTidSjKMLfmk+9dVHigR6tbMaO12I4yNW YVtEZPUhJrt9U6lnJo31E7aJosQc6jY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.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=1660879716; h=from:from:sender: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:in-reply-to:references:references; bh=ni5gEAEVi2QJ/nGf471g6eZEEcUKTlkWML5dHT62uE0=; b=tk77dijHjfYgA7AxE5SYWgBaxlHtsc+uDdr1RIgtjWy6exyXprH5u9cQLwyzxYD7r8HeJ4 8mFNUmt5FyjH+7bqu6fXg46Gud5AasPqgqZANtFCcO6WEIVWtHyU2P/7//QEQj/h3DxfUi dblrGlKS/7El6fX5DoY/PxT0EvLOgIc= X-Stat-Signature: drupk7yd9skcaryzepb7geghqoh91ity X-Rspamd-Queue-Id: DD6BA180010 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Rspamd-Server: rspam11 X-HE-Tag: 1660879716-937684 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 Acked-by: Naoya Horiguchi Reviewed-by: Miaohe Lin --- mm/memory-failure.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 1a7d6548ccb2..5b368124956d 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2432,11 +2432,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); @@ -2449,6 +2449,13 @@ 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; + } + } + lock_page(page); if (!PageHuge(page)) wait_on_page_writeback(page); @@ -2498,19 +2505,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)