From patchwork Tue Aug 20 03:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13769275 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 4D727C3DA4A for ; Tue, 20 Aug 2024 03:27:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B90826B007B; Mon, 19 Aug 2024 23:27:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B40C36B0082; Mon, 19 Aug 2024 23:27:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2FDE6B0083; Mon, 19 Aug 2024 23:27:18 -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 836066B007B for ; Mon, 19 Aug 2024 23:27:18 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 28B1C12170E for ; Tue, 20 Aug 2024 03:27:18 +0000 (UTC) X-FDA: 82471188156.11.2AD6BC4 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf01.hostedemail.com (Postfix) with ESMTP id 5128140002 for ; Tue, 20 Aug 2024 03:27:14 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724124421; 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=dxX7Ptos2Au1FL7A2ZO5dkJywWMbIr8R++41sigROhY=; b=ingyjcpf45CRQWtavf0Sm22OYpVfEtYrAgZ5HfYVSyLj01RijtezfDINmsEoi5Te7orBHm Z7rfxgaBWfsGxm7FikB91/ppYGZGTbODJyUe2f8Pedw6FPSVajY6GXz3mBAu6GD6JCxBUK TbRtzYk8s3PLkbcc5eOHMQ88A5ZvqDA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1724124421; a=rsa-sha256; cv=none; b=tdja64BCK8Vx+xLi74iLYbmLVGfZajTSSpIsimpWadaBjTa2wMBTM80Cw+gkoDrYvz0rGB YkhCXM2IJMviGXt+o6MYbbOrNLYALnCvW3f/5pedN/LrM0tLga5dsdXc37/m5jzQabTssX jEDBlYe542iyzFN8NeUzj5afvB0Ir3A= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WnvsD5yHbz2Cn00; Tue, 20 Aug 2024 11:22:08 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 2CBFC1402CC; Tue, 20 Aug 2024 11:27:08 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 20 Aug 2024 11:27:07 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , Zi Yan CC: , Matthew Wilcox , Kefeng Wang Subject: [PATCH v2] mm: remove migration for HugePage in isolate_single_pageblock() Date: Tue, 20 Aug 2024 11:26:30 +0800 Message-ID: <20240820032630.1894770-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspam-User: X-Stat-Signature: moqeoy9fqkhqumrjrnrt9hjd4tqyoip9 X-Rspamd-Queue-Id: 5128140002 X-Rspamd-Server: rspam11 X-HE-Tag: 1724124434-333974 X-HE-Meta: U2FsdGVkX18PIQ1RLDV+cJwGeWuz4EiD0lTMqx0x+3nbjWDfrMNcSQjNhppWguXcyfDzdhnabLWQFmSiazofyQsDAz4lKmCi1Sed8APYMBFXTxcTxjJVZ7zF1NdcRIFqgvs4iZjSAuZv/2OCxKCvWQBBfm5cv/rj64wUQeZSTys30XdbXmpJD2/83oKW2TrlCcueoTVEJvS5KG1sMycnCnP4iW60ZFTa7ExHt7St1RVRHthF4IpSrvGgIkuZIAK9NouA8W1hhpvKu5eYKbT3sX5k4HrZXeZjgPqlL2J58OBzF9tkQ32L8gN9Ft+9VD7hxz2qjyqEX/kg41m53Sk1xeys9BA2vqELswRumRlhB9pU93cdcJSl/YDx6673/vx2Of1YfPhbjbuC74BqRKARgS5IX6arHsPiW6Tb1yfy/GAKa2Y45I+cDjdCL/HJFTG8TYTK8dZFShT2fFolCeAQFD1g2FCx+iCu5k08HUPu475mDsJrFpOlnxsolx+DLvIibKakIoYf0UWH86pv74P1uNxYfWu7+Xj9Y28NgYWDrQVf26tj9Kt2Pc1BM7lrGbLdk/x3S+WxK3IOA/QuOYlE7/BKFy3PBwgdft1J5+QTPcew1Du6+tdt9eUQkLsZFEjPJRm87JvvTuHpGzyOU+trKPeNzrKAnGJ/nQJgGaM0+BFG2K+YA3kB4oAEBanvUeUe6RxNSvf+R+Hx0Bqd2oBQAoCbKv9WP9UPIQbL4qkhRnEukaeOct64rWGy8WfbXdppKmO9QzhltmzOkY5uGUWwmjSgRRvoqafwt3lvHDM6FIZX5GGFpRQRZqT3KTEbwLdh9EyhlJSaK5t3iqzU83PeX3tOu//fuos7cjx0lPlMLReZN838Wto816j4eTl0aAAN7W8C6Xzh5PvuYDw8C/+eY4UhWHM6Hfp80R5hNGy352+1LhWZ7PTSydYoADWzEQwBlKmxCfYT5tAwMy6bcKM dSnmaiTa ywxqyxB4qVc++nUEzb6ZPbwm9lcc2qLUx0F0Hnu/tbEDc3b05sfiBw8IXSA62Enb2wJ+8QGLLaDgNLEll0ClxQz4npN71foc6/yxyoODSDVg4DhnkJZ0ZVpN0sJQ5PU6CBY3r/xJM9+QysjZzxK2hLHSOKRoNZ4ct4lO7zU+E48qRzqCvXsEhrUcQwUx5JgdUEq9X 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: List-Subscribe: List-Unsubscribe: The gigantic page size may larger than memory block size, so memory offline always fails in this case after commit b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity"), offline_pages start_isolate_page_range start_isolate_page_range(isolate_before=true) isolate [isolate_start, isolate_start + pageblock_nr_pages) start_isolate_page_range(isolate_before=false) isolate [isolate_end - pageblock_nr_pages, isolate_end) pageblock __alloc_contig_migrate_range isolate_migratepages_range isolate_migratepages_block isolate_or_dissolve_huge_page if (hstate_is_gigantic(h)) return -ENOMEM; [ 15.815756] memory offlining [mem 0x3c0000000-0x3c7ffffff] failed due to failure to isolate range Gigantic PageHuge is bigger than a pageblock, but since it is freed as order-0 pages, its pageblocks after being freed will get to the right free list. There is no need to have special handling code for them in start_isolate_page_range(). For both alloc_contig_range() and memory offline cases, the migration code after start_isolate_page_range() will be able to migrate gigantic PageHuge when possible. Let's clean up start_isolate_page_range() and fix the aforementioned memory offline failure issue all together. Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity") Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand Acked-by: Zi Yan --- v2: - update changelog, thanks Zi, David mm/page_isolation.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/mm/page_isolation.c b/mm/page_isolation.c index 39fb8c07aeb7..7e04047977cf 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -403,30 +403,8 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, unsigned long head_pfn = page_to_pfn(head); unsigned long nr_pages = compound_nr(head); - if (head_pfn + nr_pages <= boundary_pfn) { - pfn = head_pfn + nr_pages; - continue; - } - -#if defined CONFIG_COMPACTION || defined CONFIG_CMA - if (PageHuge(page)) { - int page_mt = get_pageblock_migratetype(page); - struct compact_control cc = { - .nr_migratepages = 0, - .order = -1, - .zone = page_zone(pfn_to_page(head_pfn)), - .mode = MIGRATE_SYNC, - .ignore_skip_hint = true, - .no_set_skip_hint = true, - .gfp_mask = gfp_flags, - .alloc_contig = true, - }; - INIT_LIST_HEAD(&cc.migratepages); - - ret = __alloc_contig_migrate_range(&cc, head_pfn, - head_pfn + nr_pages, page_mt); - if (ret) - goto failed; + if (head_pfn + nr_pages <= boundary_pfn || + PageHuge(page)) { pfn = head_pfn + nr_pages; continue; } @@ -440,7 +418,7 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, */ VM_WARN_ON_ONCE_PAGE(PageLRU(page), page); VM_WARN_ON_ONCE_PAGE(__PageMovable(page), page); -#endif + goto failed; }