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 E9801C3DA4A for ; Fri, 16 Aug 2024 11:30:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DFCD8D0074; Fri, 16 Aug 2024 07:30:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 789788D0073; Fri, 16 Aug 2024 07:30:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 629FA8D0074; Fri, 16 Aug 2024 07:30:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 40B8B8D0073 for ; Fri, 16 Aug 2024 07:30:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D0E0081A8D for ; Fri, 16 Aug 2024 11:30:52 +0000 (UTC) X-FDA: 82457891544.22.208DCAA Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf07.hostedemail.com (Postfix) with ESMTP id E39CE4000D for ; Fri, 16 Aug 2024 11:30:48 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1723807814; 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=UBGIOlDT5wBcpcZI1CtSoPbTg81a/H/C7bUql+ItsfQ=; b=GY9A1MVGyuC/XWxOR6kpqHgMpa5kbpkih7zgQOtpSwvZ66zs7hOXIjSSvWx/5G/EWRoxmu +PjAvFjMYZPq2AL5K7Pv68Ge6LVWYWsV5MSB6G+UQkyBqMN+HBw7DQ6Xl4lqIMAokOK72q hxd9xwTJwLo0O4Ajg5LSzFx1qW59sT0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1723807814; a=rsa-sha256; cv=none; b=sFtDFoBzU5q9cAMITs/rA0OKmtIir7o5SKb3lC/yuum04wsYgrWgKFmxKdW6DXsa/W7ifR hsBITaaHh0yPWOQoMX7od/BA8hnNerwLClVYirHZiUk7V6i8+A6UBeJVND0hPnszKQZrvs QqBG/jwn+KTPahL3n2mqVriWbuogh+8= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WlfnW4rTBzQpv4; Fri, 16 Aug 2024 19:26:07 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 5165E1800A3; Fri, 16 Aug 2024 19:30:44 +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; Fri, 16 Aug 2024 19:30:43 +0800 Message-ID: Date: Fri, 16 Aug 2024 19:30:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: remove migration for HugePage in isolate_single_pageblock() Content-Language: en-US To: David Hildenbrand , Andrew Morton , Oscar Salvador , Zi Yan CC: , Matthew Wilcox References: <20240816040625.650053-1-wangkefeng.wang@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.243] 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: E39CE4000D X-Stat-Signature: drikjebykr7ftytqburzhrz1d7bkzqqg X-HE-Tag: 1723807848-544745 X-HE-Meta: U2FsdGVkX19HSKA/wcza0Lnu7AC17dbzkFECW26ERp6UWWLsRNwQlEdNp49u0Mijbbn/Pqj/ip5DXLCubPV3aVpGomftoZBz34rVLgbbPa05sOGO5eKPCasH87WQizgGd5OdPKzlGSHhhbxtgEUDU5fRosJCiSlFyU4BpyuHAkew4yNvBazTg7DuuQ9UpMRl82IcBehRB2pZgZnexDlqo0cbKfVjLTszIarxX+SyMhWGp0BPb49twuIzdr+A2tPeLhsQK6nejYiuuhv0KHMZviqDuf796R7GJ28pA8Svl3Uk0eeAMg7/nKGFIqyNecr4OWYJlpTat54jjh+G7CBQf2+/5zfXvEtQd09Qf1VNuwnB1OsZWcfCdrDbN9Gf7dQEuJHhCOy+Jb8I163M2jQ2W1Wi6gJcc/9fqsZZ/0qpFRBISv4/96h3WUIqXLL1VTPikRYi4grUmr0VZ473qNKIHzhgV85YA/vNPlReYe5UTthPZDDkIyfzMrWfAxXwP5/WsC3d1trqLfVWSfZNtCNu87zhwJAcB2thWo9NhBk32eHhBJ+UJnzwrn5xtOyYWX7TxD9OuTNjxlYmP5u/b5fuA59slViVyOYVV/ZIyTjeR7cQtgYMUJJKuzgvQC7SoY+nTnBZssPhaYCWUP0zHThHhOiBF0bLYuQIXrO5sgj6ghgR5yfw71njRaU84EPGf2gWn34DNH/WbtK7m7qCrwAq6zFj6+P7Fapkbr72Eya9WYXL/hhcJrVOb/nPqGEsoRMNbv2m05ZlNKPqA6xT6Rm1mNE8f2NSomEicKMylKUQoU0Hokph5CCvkIJYPdxzrQXAdCPZ3fpVnNvUk14CebdBr2IrapGIUuVDQsFs9g8rnoXddyLSuCkW3EGwTAJCd0DObyRVS2nJ+Ojku+taAVmg+M41QT5enO3oFLhoo9RwEh57q9bL8LY41po1UeYN9vjZ6tkayD2ekRwneWjpOZn w5/R/r4q 7SrxG23TA1dh7xD1ro4NGenLwuI/3Ip7ykeqolEKMSAYhxuDcsTu8p8hX5mQt4Ju2hIa6X3IyTEj2unHczdP3TBSHB/JmK15FfwyM8TCzl5BoYjUWhL0oGYyPZLfQ547Sru0dkfxRkDR2eIl8oVJsJlRAfhCYXzoDpWEh/Y2kZQAdR5/BU7K3cSunX+6TFBRgSuo2M9+QHDez7cx0A9y0KT/twK6eul5ZivWUQY2XU4hL/MLGP16GKcpjx6qYW2IUHTHm5KbpJdAgDyolWAEBp5nAcHpz/tIDMz5Yhhc64HOSRVKbvA7QB0AL5vS9n64gwE7d4f9NNEiJWm93t/P09WiNBNWVe6CoFshS 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/16 18:11, David Hildenbrand wrote: > On 16.08.24 06:06, 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; >> >> In fact, we don't need to migrate page in page range isolation, for >> memory offline path, there is do_migrate_range() to move the pages. >> For contig allocation, there is another __alloc_contig_migrate_range() >> after isolation to migrate the pages. So fix issue by skipping the >> __alloc_contig_migrate_range() in isolate_single_pageblock(). >> >> Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock >> granularity") >> Signed-off-by: Kefeng Wang >> --- >>   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; > > But won't this break alloc_contig_range() then? I would have expected > that you have to special-case here on the migration reason > (MEMORY_OFFLINE). > Yes, this is what I did in rfc, only skip migration for offline path. but Zi Yan suggested to remove migration totally[1] [1] https://lore.kernel.org/linux-mm/50FEEE33-49CA-48B5-B4C5-964F1BE25D43@nvidia.com/ > I remember some dirty details when we're trying to allcoate with a > single pageblock for alloc_contig_range(). > > Note that memory offlining always covers pageblocks large than MAX_ORDER > chunks (which implies full pageblocks) but alloc_contig_range() + CMA > might only cover (parts of) single pageblocks. > > Hoping Zi Yan can review :) >