From patchwork Tue Aug 13 12:52:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13761991 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 6FD61C52D7C for ; Tue, 13 Aug 2024 12:53:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0CDD6B0098; Tue, 13 Aug 2024 08:53:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABD1C6B009A; Tue, 13 Aug 2024 08:53:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9850A6B009E; Tue, 13 Aug 2024 08:53:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 79BE26B0098 for ; Tue, 13 Aug 2024 08:53:12 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2410312085E for ; Tue, 13 Aug 2024 12:53:12 +0000 (UTC) X-FDA: 82447212624.16.15D08B0 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf16.hostedemail.com (Postfix) with ESMTP id 80ED218001A for ; Tue, 13 Aug 2024 12:53:09 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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=1723553555; 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=uvnH0RPrp2Xq/owDV/nzWLzsjpjdeGGkHkklOzF+XPI=; b=Q5ac4kQdtVna30m9oAhR8O8uE73zk+EXuDkr9WTJncNF9NJkar/U8UnFexs8mzTBvB9vO6 J1E5rNr+ZP4T17hKXU/VNdPtlvX9tZoGNeJKX/juJx0j4HLVOvQ3eGQ8K5Ar7UgvLCLZ1J 6q1qz4UsexXP64P/WmUfSXnuUScghlg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 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=1723553555; a=rsa-sha256; cv=none; b=1sWUTN36iX4zZYYKHD8ak2aWn5PWU88oiJ5IwLEi3adEy+nmeuwfWuL8UcMNFP/YvH2Zac lb430WpMfZw3i6WR5oiC+/tWkTWdEqAOoY4LrhqRjExNApMKEINyCe6xbAqVBHIjeUJiJr swc4G7G1qLsKXe2/MpQOU5AClzz1jfc= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Wjrlg044Vz1j6R4; Tue, 13 Aug 2024 20:48:15 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id A49871A0188; Tue, 13 Aug 2024 20:53:05 +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, 13 Aug 2024 20:53:05 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , Zi Yan CC: , Kefeng Wang Subject: [PATCH RFC] mm: skip gigantic pages in isolate_single_pageblock() when mem offline Date: Tue, 13 Aug 2024 20:52:26 +0800 Message-ID: <20240813125226.1478800-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-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 80ED218001A X-Stat-Signature: akc39jghfynuqy78ge4fiii9y3w6p467 X-HE-Tag: 1723553589-796096 X-HE-Meta: U2FsdGVkX1/wFt7xHUm4hnzpn1Cz3Ge61HN6ab9tvkwYFLWoP1EhGU9sQ6J+h6DMfPuI2qPeuqY4wPstBbrGyXQv2a/LCsfbPyrNvexp6BISvZISTUPkimGq/E9WRMfdbxdISMQR+Fvhd7I/qHfBp+mZIDj5YbUcW4+Jiokz5FF4HJW41iWNieCfkQ1PgkwMLnmW//jmn/SilsRH0FfykHDNCUVBcN8oL36F0nFeYlNLZ9Lg/ZbcIitDwX3grTifntxyuMc1R8vuSekNowIT1aCUM0Iuayzi1UOqRRee5YUxWRDj9wjgVs+bFqtb9y51+xM146I+7DS17z0LUHLJq2xHLRu39wH9AuaeR0VabddMER2oLpLjlE0qDHUPcWiG76VaMgp/LB/V4n6CTO4kAODUGEjm68m5XSRJc5JgKp4vaWcBW8SQULSKiwdmTZHcdpwnhkqcmrdcOojtNknuZ+/65mfMyv/iqOjIuE1/ssXW8sEieAqwXN+fwviqsWlC8ZL4V0gDsAP1ZHiNYeed1jmJOO4w+1ILlQfqKbtp7dIyCki60UtCN07VQmSteDKL4Q+E8nX716a8PqSaj4k24zcfnXl3kFhAl6dWpkzZS9CB19XjNbk4m7dV08tnuDfcvL+II8qguSNl+eDTGsPeu+yAwj068wqBFa8JXJaLgx8WZihewh1owekn18CC58GypbX9SzT/+yAViuRvu19wdB5TdO4F+wh03/lRCM8Caiz894+xnmIglT0Oz9H3ixc35ZN/QQRET16qYweVJxce2yCThvXZt9dS4wEFWDaKRNhRCX20Io48+YgjtPZPTPhW4MUasZeyOz2PAlo8cAQgT1hpHXrpDmiKtoFdO2M80YvmebwhwwP85ff2nQ0w9KQSXU6R/l2FAyL1KpkPPKopcYfrflBfQe5aTqPlcUkR2L/hljwPFedW9rZsCWzSvHK/uiSBg+nFlS8TaRe+ssF iFLFrNhV auLZILFwDOn7wifaltjACfqgsvX4J2AcY6CfBGj5US2cTpLifdg9qU21jsDpHNNp3ibSZRX+Ty0NDZSMxXqYhXbEijGaT/iyVSRl+K698qvUoSzNs4pQP5h8VxBVoayOPMnbr4Lsr0DZMiO5xdBXdntAwIQdZm4V3/NzAk2UL4zm0cOgWJkCK9cb2MgtWqg1cPHev 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 Fix it by skipping the __alloc_contig_migrate_range() if met gigantic pages when memory offline, which return back to the original logic to handle the gigantic pages. Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity") Signed-off-by: Kefeng Wang --- mm/page_isolation.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/page_isolation.c b/mm/page_isolation.c index 042937d5abe4..25db4040e70a 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -400,6 +400,16 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, continue; } + if ((flags & MEMORY_OFFLINE) && PageHuge(page)) { + struct hstate *h; + + h = size_to_hstate(nr_pages << PAGE_SHIFT); + if (hstate_is_gigantic(h)) { + pfn = head_pfn + nr_pages; + continue; + } + } + #if defined CONFIG_COMPACTION || defined CONFIG_CMA if (PageHuge(page)) { int page_mt = get_pageblock_migratetype(page);