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 87FEBC52D7C for ; Tue, 13 Aug 2024 14:46:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DD3A6B007B; Tue, 13 Aug 2024 10:46:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08EAB6B008C; Tue, 13 Aug 2024 10:46:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBD796B0092; Tue, 13 Aug 2024 10:46:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CEA676B007B for ; Tue, 13 Aug 2024 10:46:23 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 18BB9A7580 for ; Tue, 13 Aug 2024 14:46:23 +0000 (UTC) X-FDA: 82447497846.29.BF20216 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf19.hostedemail.com (Postfix) with ESMTP id CC4891A0016 for ; Tue, 13 Aug 2024 14:46:19 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723560323; a=rsa-sha256; cv=none; b=Wu/4q+jKHjx/0KlsKYI+XU0wF6EWHizXVm2+HC1VaiBXWCAtyKWfWp5c6U5uGs5JT9q2d5 /Lfnl0hYluiU4LyExxz4WLxP/NU71HfE8yBtgnOE6TWAG3CEeJpgcd4JOeXiEN1MHdkzoV JriKylUxkxrUCYW73gdh21xCr9WRZE8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1723560323; 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=x2Bzw9bSBFR8yVglqvjeM47E2CS8Jcl9yi1KnlOgasA=; b=xhMeRSeZNFqA7E3UIpjsDqSJI3KBsnU8l2PcOWFJvUl1qIpdMPORu9HBX82a/FP+YWXuDL aVsuJKgdj2DhqPP48/hnIliPdrrpvw7gAuppo+3hU4f9a3VTwrkTEy+Fr1JvBdagJf6Qsp yGM1Gz3rJ2YHzUxM2A8AHywhPF451Y0= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WjvGB0cm3z2CmN4; Tue, 13 Aug 2024 22:41:22 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 01820140337; Tue, 13 Aug 2024 22:46:13 +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; Tue, 13 Aug 2024 22:46:12 +0800 Message-ID: <92fedec5-62c9-4ec0-9d4c-a722b30aa63c@huawei.com> Date: Tue, 13 Aug 2024 22:46:12 +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: Matthew Wilcox CC: Andrew Morton , David Hildenbrand , Oscar Salvador , Zi Yan , References: <20240813125226.1478800-1-wangkefeng.wang@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CC4891A0016 X-Stat-Signature: eqqagzpudsdnyy4yycck57nny896wcwa X-Rspam-User: X-HE-Tag: 1723560379-222718 X-HE-Meta: U2FsdGVkX184HxNQpOrEhAkoND5xQRCZFfJwVHS+sHUq9Iw155eOxh+TZXLQelsasibSWeWQLD2RtgGupYo8nF/224se+1+qOGaAvEDe3z+mET/C22NeicHBKHy9F7vmtJyZ5ZCAy4nIm/FZ0yg4F17jLyBqaysDv5mVron6APPTkgBPq1a/cO6eHub1QLsgqwq5ezIxdOBUaYOP83FfEQq1R6NCTv3wQxjBQIPVVvtTz0WEabU7V+D9EuZMuk9KzrZNU/g0kBqMW+NsktayKK8XAKQJiFD/UfAadanLngicKJHbsdv30bs53EWuqci0+fCkt867ep0xjsbjPdL/f9SjKvSPwkmYEwkfXfU8+xsWAB3wino39qB6C2hJOzJPJfkJRBwlxOpv6eQ+7faO1eNbtdzbkthrdKP/VV/bUHDpXQrn5ApatRL5oW1NaqFRDrnSKOEVBA89mmb4ZPq2NqJqNMjtcJI7fya51+d1D4fQHcWroMOBl+LJkcd+A7l7xckUIRVVe7F7CMerCxb227vDy4pUAj1BV7MorBS6g4bzEZdmM9sKWdFzkar5TDuS7qNm8MsHHL23MkNh+qvMzRX6B/vcVIZEcJh6mgj9ZVU/N94JagBZeEFnPHUf/nkVpSfbQBXgiu9zPKIvuqvFL2OnnSjvsVCiiYcoEl3VTSGL+6WB2INgL7JINl1GVbBtAk17pZ6ZAmyITsi68vOr7ZZh1MhfNTp5MzueP32NbKoH4qeoTDvX8WrMrH08pzUGXa9pbzj8W6NtMvvVd9MKJ0DVDcTBHm6xJuOP92z/DWO3x0/l5ZYML+Z4+eQG0D9nWrLaImkbW8b0wU1ZZf9emhZiAAwu0hUJFyv9ZwvEu1fxpKAbJuggMPfxkYsa+VplXyEGNHmRzYYNPLrxGtkNKGPoGAcETVHw843eK54G5rx40kgxK7LH7OurFnu7bv2rtQBVmaHsZ/l4QB94tFK V/KprRyw FL7B4+0t9YOdmf1t5v0AIw9rdI3QSd/y2Gq1+hvxjwsv+AftF3b1AfkdjgopXrANbeLI7BvcMa4Slk7QlnXAGUeOdeg2ZPwfCz4PCcw+f85h1CA0CthJgb+t93VhpphB+HNCkmMcslwUFw8jlzoNHsKQLdPu9KF3yAQ1YxeicNQm8rY7FoxdYUtbm2DQc268LmMszc1vcuLg08Nt/1i4oNK1FCn/+UD7ckUZr0ApvVrP4YJl69pCD9i0GC0xvVpd4gurrdDblsYRAxoiQFeA6uYt25GQ91RiQ6hj4pjQrcxFVPuarIIOmIGzmFoAqq0NPmilsPOyldSVNZLEFrWoLvE7v6UbTxADD++IDEeyq5DESkBU= 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: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/ >> 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); >> -- >> 2.27.0 >> >> >