From patchwork Tue May 16 06:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13242574 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 E768DC7EE30 for ; Tue, 16 May 2023 06:21:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 811FB900002; Tue, 16 May 2023 02:21:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71E1E900003; Tue, 16 May 2023 02:21:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE3C900005; Tue, 16 May 2023 02:21:37 -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 28727900002 for ; Tue, 16 May 2023 02:21:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E848A80A47 for ; Tue, 16 May 2023 06:21:36 +0000 (UTC) X-FDA: 80795121792.15.0E22B37 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id 68718140007 for ; Tue, 16 May 2023 06:21:33 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1684218095; 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=LnJ/2FHbHKFcBTkWNnx8nE7c+6i3wW8vlrKFpxUMFLM=; b=LKhAJDT9F84nJs+t1B/Mtkd9rYO0E96APG391Z85/paHcuECXkRbH/UwHf4bydUYxMR28u 4rx00ucBg8H1O/IVDaXylEztkcHBAK8x/6+7uiKi76sSANGnz+cilcRcXs3RwX8nhOeUbq 2D7Nx8em/tkFSd7friuNydKrv9AfDUQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1684218095; a=rsa-sha256; cv=none; b=o1FVe5gChq9jPaQZ66ad+Bszm+hrydOlv9VEviuY5sMmU/K5klufxrC4KLU086TEMDKKV+ 5XbtuI5pvbmUfp/JCK3G0RzZqD5fvsM5AYqs/hQLNUr/P29oLZirXhOZ7EZsmzsDhhOkHp yvVsxj3xBA+SqxG3C+Lg/qtX+Ql8A5c= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QL5bw68MrzTkk2; Tue, 16 May 2023 14:16:44 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 16 May 2023 14:21:30 +0800 From: Kefeng Wang To: Andrew Morton , Mike Rapoport , CC: David Hildenbrand , Oscar Salvador , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Luis Chamberlain , Kees Cook , Iurii Zaikin , , , , , Kefeng Wang Subject: [PATCH v2 03/13] mm: page_alloc: move set_zone_contiguous() into mm_init.c Date: Tue, 16 May 2023 14:38:11 +0800 Message-ID: <20230516063821.121844-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230516063821.121844-1-wangkefeng.wang@huawei.com> References: <20230516063821.121844-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 68718140007 X-Stat-Signature: x497u5q5n3yfiackywdjo4ftqwdpeku9 X-HE-Tag: 1684218093-468610 X-HE-Meta: U2FsdGVkX1///ghoA6ucIMW8/yaIysJ8T3NqCSdk+yBQrJw8baR2WvOjcBK4zpP8Z3uR7EwNQVj7FPLGSuV6nKIe2FPsdyU1olmyw+UMkB4tVngTcMg9yNiNfPtE0Q3CcoGK4mU7nSOStDbxiJZjjjnA0SfKMAexDyRNFf03Z0NXIM3KtV5xXDTBo1DWAsLBq/CshuW1ZXtGBDt5pkGIB1dPMpzHCwS7vnk0WkGxvS4fBn0WNfDdO/I4dsG8USinfboY+ncGsZFvbm2o+/ELNlxx5dgs7Pcgev8mV26oZo3bdU4OlgPbldkl/ySIZEcIC0WlW520C7zeFrFFwmHDvNSQ+b0TWapUvaAX15TLZQj6WBjCLz0UvKH7D536aFTb9hE3NlctZrQg8ORyER+fpxdp9YTRY9E54KrEo/qQNdQJLVQ3HGXgoMlDlt1SkjxF791wRrYdR1fVvn0oPdNAnACyMXG+OPI+PTF2fbACUt+CDbpA0cs+yCKrP8uei4vqyL/QAF5A7eOopKMH1k//pK1iqEc/wkOUBn9zz88xpcYTborlP6EZzbeF1lndRFc3tzwRQycP6ArxgXzjNZ26oTyXNUItw2Vil7gbdQDjjCTsR/IclrfqcRNrAX1ffY4Xc696QiJ4kK9sVXVH38ZW2JqlwNedU1OzElhcWn5crVQvyXqMEIkIImXyxJdcziM4V5TRUetCNfXqiADyK9GN2mwqfyUZTO/DoDzKqtv3qVtp4j2ORHEcwCQQCb4MjjxpRMXmeJm/bb4cRReu9+W13ZW2zucTguoFl3KKVkgPMSviQ9p3coWKyTUl6+NADqdnYztg+lTiSj5IgjpxMrpk0ncZmonfpNoEkEY/MP7SIB7x8STb2Mhhb+j1dm6kCpM3Hu0qz2p3nPLRwrbCAKsezuhG2EshLeyiV/6Q/ixnAmXNN7F4zeXYd/fi3+oP5k0N3nfcL4LzE+/JmqITodn oxOyfyNQ Pf/qjliD2ltjeFleW2wVPxIrWi07R3ZWQPyC59qmIXudUBMgUpmfch7iSU4GiOq0qlht+fBAUnCEGFcvNwQ+FqZMwG7SzdK/1qB6cDeDna0Zv1uKvwlLYLM/jBRHunkmo22+ukgOnVLZRVTjZgPhHv/IsvCyRASVlB58CCSB5nTCUWuMXX6B03vTZzuEDVYvcjwuS 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: set_zone_contiguous() is only used in mm init/hotplug, and clear_zone_contiguous() only used in hotplug, move them from page_alloc.c to the more appropriate file. Signed-off-by: Kefeng Wang --- include/linux/memory_hotplug.h | 3 --- mm/internal.h | 7 +++++++ mm/mm_init.c | 22 ++++++++++++++++++++++ mm/page_alloc.c | 27 --------------------------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 9fcbf5706595..04bc286eed42 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -326,9 +326,6 @@ static inline int remove_memory(u64 start, u64 size) static inline void __remove_memory(u64 start, u64 size) {} #endif /* CONFIG_MEMORY_HOTREMOVE */ -extern void set_zone_contiguous(struct zone *zone); -extern void clear_zone_contiguous(struct zone *zone); - #ifdef CONFIG_MEMORY_HOTPLUG extern void __ref free_area_init_core_hotplug(struct pglist_data *pgdat); extern int __add_memory(int nid, u64 start, u64 size, mhp_t mhp_flags); diff --git a/mm/internal.h b/mm/internal.h index 644fa8b761f5..79324b7f2bc8 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -371,6 +371,13 @@ static inline struct page *pageblock_pfn_to_page(unsigned long start_pfn, return __pageblock_pfn_to_page(start_pfn, end_pfn, zone); } +void set_zone_contiguous(struct zone *zone); + +static inline void clear_zone_contiguous(struct zone *zone) +{ + zone->contiguous = false; +} + extern int __isolate_free_page(struct page *page, unsigned int order); extern void __putback_isolated_page(struct page *page, unsigned int order, int mt); diff --git a/mm/mm_init.c b/mm/mm_init.c index 15201887f8e0..0fd4ddfdfb2e 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2330,6 +2330,28 @@ void __init init_cma_reserved_pageblock(struct page *page) } #endif +void set_zone_contiguous(struct zone *zone) +{ + unsigned long block_start_pfn = zone->zone_start_pfn; + unsigned long block_end_pfn; + + block_end_pfn = pageblock_end_pfn(block_start_pfn); + for (; block_start_pfn < zone_end_pfn(zone); + block_start_pfn = block_end_pfn, + block_end_pfn += pageblock_nr_pages) { + + block_end_pfn = min(block_end_pfn, zone_end_pfn(zone)); + + if (!__pageblock_pfn_to_page(block_start_pfn, + block_end_pfn, zone)) + return; + cond_resched(); + } + + /* We confirm that there is no hole */ + zone->contiguous = true; +} + void __init page_alloc_init_late(void) { struct zone *zone; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bc69a0474069..1b84b86fd33d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1532,33 +1532,6 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, return start_page; } -void set_zone_contiguous(struct zone *zone) -{ - unsigned long block_start_pfn = zone->zone_start_pfn; - unsigned long block_end_pfn; - - block_end_pfn = pageblock_end_pfn(block_start_pfn); - for (; block_start_pfn < zone_end_pfn(zone); - block_start_pfn = block_end_pfn, - block_end_pfn += pageblock_nr_pages) { - - block_end_pfn = min(block_end_pfn, zone_end_pfn(zone)); - - if (!__pageblock_pfn_to_page(block_start_pfn, - block_end_pfn, zone)) - return; - cond_resched(); - } - - /* We confirm that there is no hole */ - zone->contiguous = true; -} - -void clear_zone_contiguous(struct zone *zone) -{ - zone->contiguous = false; -} - /* * The order of subdivision here is critical for the IO subsystem. * Please do not alter this order without good reasons and regression