From mboxrd@z Thu Jan 1 00:00:00 1970 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 61FC7C52D7C for ; Wed, 14 Aug 2024 02:01:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABFA26B0082; Tue, 13 Aug 2024 22:01:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6FCE6B0083; Tue, 13 Aug 2024 22:01:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9372E6B0085; Tue, 13 Aug 2024 22:01:58 -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 74B936B0082 for ; Tue, 13 Aug 2024 22:01:58 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1A83B1C42EE for ; Wed, 14 Aug 2024 02:01:58 +0000 (UTC) X-FDA: 82449200316.14.1B65C64 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 4910C20009 for ; Wed, 14 Aug 2024 02:01:54 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723600858; a=rsa-sha256; cv=none; b=489dGEEsCSPMCmFDQU6ECWEF6cC6CbeLvsyP77cCCKcsatkKfusnqzeCChr6vZeK7dREHG NjVbS21LBLywumHwTfLquD4rxNztZg647GVCkKRJqccFGMNSFmFb217STlcpgR8A28/+MQ P7IQNv4bqESEsSV5/iLlBMzkLoPvkFI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.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=1723600858; 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=A+D+HsvcXXowTK1PW1FFtF+mA0yXFZ2gROstJc6mRoM=; b=PfdD+jeNckhMS0Ne7xShvc4OxKt8ME0Dj7KrjQFcUzFxj/XQkCWVHvlQS6/MReI5BTEs45 h4UgFOuWzdyltJYl3i72SLZNpJnHVFdxSCGX2/gC7wHYaEQ7SfE1obzzHfwZQ9hSjiasnZ TAzWEXnVkrYfrXPreidUu1l9IfKzArE= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WkBM44qj9zcd5W; Wed, 14 Aug 2024 10:01:36 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 385681800A4; Wed, 14 Aug 2024 10:01:51 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) 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; Wed, 14 Aug 2024 10:01:50 +0800 Message-ID: Date: Wed, 14 Aug 2024 10:01:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC] mm: skip gigantic pages in isolate_single_pageblock() when mem offline Content-Language: en-US To: Zi Yan CC: Matthew Wilcox , Andrew Morton , David Hildenbrand , Oscar Salvador , References: <20240813125226.1478800-1-wangkefeng.wang@huawei.com> <92fedec5-62c9-4ec0-9d4c-a722b30aa63c@huawei.com> <905740F8-58C6-4333-8EA1-4A53C95CC1FE@nvidia.com> From: Kefeng Wang In-Reply-To: <905740F8-58C6-4333-8EA1-4A53C95CC1FE@nvidia.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4910C20009 X-Stat-Signature: 815pa18fmz8jxad4zzom7eubopgyatc1 X-Rspam-User: X-HE-Tag: 1723600914-131758 X-HE-Meta: U2FsdGVkX18+Mgpg0c3WNOWCQ7+XTvBXn//TsbqUVChvbDFewmHuTFTYeVA2DccGlvLo4XIFgYnyD14aMgq3ZsCcRM/30niWmykEqDMgb1qfG0T5qzVAtNfgMRiXKW6sTqSxQ9UCq8F3S34tRTSIGLlNS3edC3trtfonFVnxFY8RZggM8lWVl+HUiMjMuCaHwrosDT+7qE4XQwOOyw5F7qOBkA7ukqVHTTgAhcOubieN267C6cEEOEjKsHbAE6CWmR/6bN9oHzIq7YQR5g/C1vJzke7xFiR6Bn/C+8ept2eCJX5rF5lQSS2HupIw3bifJZwsjTz3xmhURLyLXKiR0d4kekLIQG4SdImnfiCudlMLa701qHhGE5H4/HsQn9FOhZaa0TtvZzMU+P/w8kmFbTPuaRq6jitEOfuUhJ7yI5daZFWeuom/7j2iO5riCaN+jBb19MCI6PbUzeDAWC0C7WJJ/SBPrSuiRPYFJqa2LsuFpi6KULR1R5UoWmOJ7SMKVgRwnqEvrao6k6oyhitS/WpmyNFDTrYj7MiflBmT4PMTmtWmZWHd1ChSfJAzUcSVqUUZO8Jviuu/YLPskAmZHKtaeV46JLW3mawLamjgYsJT4bpiK0XEHRMAT1OEjKZOEtoIjhvYJjMcKcoxPBd/Rl8nMuh3eZIRHcPSYuOxdOLXMZQhVr0HTWozDutazTQGPd3a+BPOvzFLrWBBLRN1j8TTufLjrdbIt9R8aIBo/Be4AV95QdyCg7GLa1oGaxJ21z7f/l+GhYVepfn2yaKK533DFiqZck8lGdiD6vZ/3jAyGlunoIyT5cS+C4yeyR8K52WacGQ7vUigJR0XYvPjm0g7acjJm9y2HK+Uhg1K7PlRdbDNWF1xlQ3QIfTMEz5MdEoeW86O7t3K2v0Bq9DNE4zGjrZFiSYnYJ25OP+jaxYO32WK3zsbKQZvPdEzFmAStNF/nL1Pc/FY6uHbPR+ gnNsSwfK xgsxAn5Yo1nK6RUblpLbft7uRv9RPOHCLnSZ8IE2zI+/H2zbL+MRHWkTRobRIe1EFu8VIvNWzqKY0TAgOxXpbxujVbsGZdOMZu8vlAQX4Fh4+8TB4CVLLlHOMhgRe0VZG4pQSsTRBKWdl9HKISlRz4HkwjLFQRrg/Bm0D1eBZA0hhYBq2G1QlT8wOOXGXyGrFt8u9rTVDjxYSLhAqp9M4/g1LaLw4zmHscHWVZEBeByvNWAiEF+WFknhbu2SVWS9CExjdMB6CJg6t9U1XcKyuns4hJUuIciLpgZfvG8h2AJpDH1giCj07GNvR10nrxo0Y2Hun+IyNk74TrHG8xNsGCRpnAQ== 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: On 2024/8/13 22:59, Zi Yan wrote: > On 13 Aug 2024, at 10:46, Kefeng Wang wrote: > >> On 2024/8/13 22:03, Matthew Wilcox wrote: >>> On Tue, Aug 13, 2024 at 08:52:26PM +0800, Kefeng Wang wrote: >>>> 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. >>> >>> This seems like the wrong way to fix this. The logic in the next >>> PageHuge() section seems like it's specifically supposed to handle >>> gigantic pages. So you've just made that dead code, but instead of >>> removing it, you've left it there to confuse everyone? >> >> isolate_single_pageblock() in start_isolate_page_range() will be called >> from memory offline and contig allocation (alloc_contig_pages()), this >> changes only restore the behavior from memory offline code, but we still >> fail in contig allocation. >> >> From memory offline, we has own path to isolate/migrate page or dissolve >> free hugetlb folios, so I think we don't depends on the __alloc_contig_migrate_range(). >>> >>> I admit to not understanding this code terribly well. >>> >> A quick search from [1], the isolate_single_pageblock() is added for >> contig allocation, but it has negative effects on memory hotplug, >> Zi Yan, could you give some comments? >> >> [1] https://lore.kernel.org/linux-mm/20220425143118.2850746-1-zi.yan@sent.com/ > > Probably we can isolate the hugetlb page and use migrate_page() instead of > __alloc_contig_migrate_range() in the section below, since we are targeting > only hugetlb pages here. It should solve the issue. For contig allocation, I think we must isolate/migrate page in __alloc_contig_migrate_range(), but for memory offline,(especially for gigantic hugepage)as mentioned above, we already have own path to isolate/migrate used page and dissolve the free pages,the start_isolate_page_range() only need to mark page range MIGRATE_ISOLATE, that is what we did before b2c9e2fbba32, start_isolate_page_range scan_movable_pages do_migrate_range dissolve_free_hugetlb_folios Do we really need isolate/migrate the hugetlb page and for memory offline path? > > When I sent the original patchset, I over-thought about the situation and > included PageLRU and __PageMovable, so used __alloc_contig_migrate_range(). > That was probably not the right approach. > > I am aware of that the current page isolation code is very complicated and > planning to clean it up. My current plan is: > 1. turn MIGRATE_ISOLATE a standalone bit instead of a migratetype (I have > a local patch) > 2. refactor page isolation code, since after 1, migratetype is preserved > across isolations > 3. clean up alloc_contig_range(). > OK, this is another issue not related about memory hotplug, but we should fix the current memory offline issue. Thanks. > > Best Regards, > Yan, Zi