From patchwork Wed May 10 08:01:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13236580 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 EC4E1C77B7D for ; Wed, 10 May 2023 07:44:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DF456B0071; Wed, 10 May 2023 03:44:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28F2A6B0072; Wed, 10 May 2023 03:44:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17E416B0074; Wed, 10 May 2023 03:44:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 089506B0071 for ; Wed, 10 May 2023 03:44:47 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C7BB71203D1 for ; Wed, 10 May 2023 07:44:46 +0000 (UTC) X-FDA: 80773558572.23.7AB90EC Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf20.hostedemail.com (Postfix) with ESMTP id 3368F1C000D for ; Wed, 10 May 2023 07:44:42 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.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=1683704685; a=rsa-sha256; cv=none; b=tu51+xuFv5mA9rgzl4+LcP3GBoyWV5DrNsSapbQJrktvFWJENxb+CjnyIx/mGKHB/xFyzm L7Uwtn0S3Ig3QNIlyg9DSP7NN2b+sDlb/gUT49fBcS0gARYQa+/QmGK+em/SKa/sEuicFy oVeyFJIawCz0mT791Jqk1OGC1lUNzys= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.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=1683704685; 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=wAVFofm9STiyAOIkEmt3cfmR60NUDDcu92tSB/S4J8I=; b=3U2CdmteV6D6E7h4+3YZEQhaSW9q7+9VBAC5jd/N937hs2SwAUzuk2AvpFVnLRbE+aD31s XxAWo6Oj2nnAhYgzdh7vh/MQN0Mgi67d8p+B3h+ziinMOuoG1+71a/SVhTxRrFNYTY2wkc f8HzH0yZVnUmeHcuOrLtYB9EbWVXdLc= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QGRpd3pbPzpWF5; Wed, 10 May 2023 15:43:21 +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; Wed, 10 May 2023 15:44:34 +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/12] mm: page_alloc: move set_zone_contiguous() into mm_init.c Date: Wed, 10 May 2023 16:01:29 +0800 Message-ID: <20230510080129.170189-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230508071200.123962-4-wangkefeng.wang@huawei.com> References: <20230508071200.123962-4-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: 5mt4xfcjhu6dafk1pb6c3ixyzjtat6r5 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3368F1C000D X-HE-Tag: 1683704682-617699 X-HE-Meta: U2FsdGVkX1+ZaFQOlVfCFSRjSWejmOoOXIHyYkXOb1luu960poAR57Vs6HABMEWO72xl1GBpPXtYPzAREJik5yjf70N88bbCAwGkrUMPaH/2QrCwHUl01WlC6iwA0b5rv7cgqeNLYp6LDokfiJDMwfQ43DK29b3wkQ7fzQ8aTA8uyVneNXe0fUTgkjDX1XSdMQxydDj/M8bJhZ3HvJ9hN5R1RgSE4Fdxb023e++iE8kAELj4MDgyUo65tfTuD51Z0jZKt9+hd9I+2vVUVm2V7MkC8rVQI91sbW40d6XUiRjeUvZKTEu5RLOq12Jx55tIrHWAKQqnb/ksZ6+E3/RJwt2gAUV/kRwIPBZXkHLvNOdyv/pPDSQ1LO/ibi9Bg28VHWKuwlpYU6ZstZOxmHA/7H/kTWhS0h01vzPq4ZOGYz30FJBureTcPU2PVycLB7xfHWm7hLomNThFXNdRZFzuKCMHWC0fxUlaVgbsQyQVPo0S9wd6PBZDBISDJIw83fC3PoEan57QHj0N3HN8korwuzmxMDsTnj2C8hJNPaltGtQpdMpKjBC2QpTVF2fcKOdh0Urh7qAPebPZeDjxN4PPAPi3wGg+HkoEUr1zNK2ik+hTC3QzxM1N67XH+zztblYrEv03lqsBeYihzydXS0kgrbg35mtsndAK1jtzExnW2eyhLihDZClq8PmVVPbXqJOMMzGltsHwnWcy7BXKhHPKjjWacEDFqef8cSMZ5/gZMcBr8TV2hlGpiG+5HtBmCn4zLzdnoJ4mabYxTi/s58ZhbLLLXG+AJ4L+nal1wPLNKZ8S6DH3KE74tSe074qjwKlRq693S+vj/dc6iLXqNvkv0ZwuFQjG3s2RankypASoxj/qNpnLKIDdSj0L9m17vdLctfp9wpjbMiTutqiT6/b8vw+Rc1s/lPpFa2ljdSL5dZWZaW4tomrmaONYajzbCpueULWkLCryh+RZ/bQcefb N3dsuwS7 gWGlzy39EQvGV2/PIavq+VDLnIi8iIKGprwnd3UH+nV5axx0yvyat3CARgUoOso5crk7rcv4N26PC0e5GHkpShQ12cr6LVF6koqsNY66MFZFhZQjRv/Dx2w6JVYRSCrRHZrID2RgW4N9L5vEIT9NqroS8onWlMhzPqaYDoGpSyYC7F3Vse4PN2osGQzWSTgAN3HWU 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 --- v2: drop move of __pageblock_pfn_to_page(), suggested by Huang Ying 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 e28442c0858a..9482862b28cc 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 4f094ba7c8fb..7bb0d6abfe3d 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