From patchwork Mon Mar 25 15:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602388 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 A2BB6C54E58 for ; Mon, 25 Mar 2024 15:05:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FA366B00A0; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 483656B00A2; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D4586B00A1; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0F8B26B009F for ; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CED5B1A05B3 for ; Mon, 25 Mar 2024 15:05:32 +0000 (UTC) X-FDA: 81935885304.07.AA72F44 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id D75961A001E for ; Mon, 25 Mar 2024 15:05:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IFsfE4LU; spf=pass (imf19.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711379131; a=rsa-sha256; cv=none; b=4z38Lwv0OZ8vi7MQeomud1RfhBaGRr9ftx0crmcAxy14Eue0KiA2+vCQxhLVICGukD428T rBietT8Mh0g/WMx3kWwL1vUqMTI8ZOgHhQ19pzV/O/cS6JgJbyDsQu5QxCb+e/GO5F3h8o 4MnaM9NybVk8wLVAfrlUK/BabQqHugM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IFsfE4LU; spf=pass (imf19.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711379131; 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:dkim-signature; bh=62MNx0xItSDlm7BWyxiaL7hkcreRJtBILyc9X1U9tZs=; b=CgUpTvQtL6z0EqxtQiyRZzoDvWHMUEfpM2MHk+mdJ0o0GvdCOrlrNIsGaD2R2zPm7+iW5l i6hubbs0FQIpVSqO2vx73p52YY+8nqF1IDCwXdsJG2W7MTeAOP/lur7ZmWIkAxf9nc97Iv uvt32szLJBmAVTNb7ykB8kc7VkmHeiA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379130; h=from:from: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=62MNx0xItSDlm7BWyxiaL7hkcreRJtBILyc9X1U9tZs=; b=IFsfE4LURKiIx/X1B0oyL6qQlBxs2GBqdffDGDfwxB9qSNEpGHdyvy31QhbflOcgS61pAy nfVZKuY5VEuudQgr7SJZbRjmb9MWE0D5gbeWWf0pf/ZhSotfbsAseuy1ldsb1/KIEG4ywh GqGEEIjBvosAn6Acut5xk8WAj5ellUw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-WhcoI3peNh6W4z2_OQeP7Q-1; Mon, 25 Mar 2024 11:05:28 -0400 X-MC-Unique: WhcoI3peNh6W4z2_OQeP7Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F0B7101A588; Mon, 25 Mar 2024 15:05:26 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03E49C04121; Mon, 25 Mar 2024 15:05:23 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 6/7] mm: move array mem_section init code out of memory_present() Date: Mon, 25 Mar 2024 23:04:58 +0800 Message-ID: <20240325150459.1045407-7-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D75961A001E X-Stat-Signature: kc499stq7fsw3y8cutpzr9u9xs5jhzcf X-Rspam-User: X-HE-Tag: 1711379130-279157 X-HE-Meta: U2FsdGVkX19aWI+aXT6ssL6d71VRBvu/w3Dxwmx8wV+XLUe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53LxIzuRzNSN6AIZeh/19q0W2rtPWX/WOX1LHCWC5Hr6+F7b1Jo/oF6P5DLCxrMQflHIHb4J16ehBF458BrXK0Og== 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: When CONFIG_SPARSEMEM_EXTREME is enabled, mem_section need be initialized to point at a two-dimensional array, and its 1st dimension of length NR_SECTION_ROOTS will be dynamically allocated. Once the allocation is done, it's available for all nodes. So take the 1st dimension of mem_section initialization out of memory_present()(), and put it into memblocks_present() which is a more appripriate place. Signed-off-by: Baoquan He --- mm/sparse.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index aed0951b87fa..46e88549d1a6 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -226,19 +226,6 @@ static void __init memory_present(int nid, unsigned long start, unsigned long en { unsigned long pfn; -#ifdef CONFIG_SPARSEMEM_EXTREME - if (unlikely(!mem_section)) { - unsigned long size, align; - - size = sizeof(struct mem_section *) * NR_SECTION_ROOTS; - align = 1 << (INTERNODE_CACHE_SHIFT); - mem_section = memblock_alloc(size, align); - if (!mem_section) - panic("%s: Failed to allocate %lu bytes align=0x%lx\n", - __func__, size, align); - } -#endif - start &= PAGE_SECTION_MASK; mminit_validate_memmodel_limits(&start, &end); for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) { @@ -267,6 +254,19 @@ static void __init memblocks_present(void) unsigned long start, end; int i, nid; +#ifdef CONFIG_SPARSEMEM_EXTREME + if (unlikely(!mem_section)) { + unsigned long size, align; + + size = sizeof(struct mem_section *) * NR_SECTION_ROOTS; + align = 1 << (INTERNODE_CACHE_SHIFT); + mem_section = memblock_alloc(size, align); + if (!mem_section) + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", + __func__, size, align); + } +#endif + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, &nid) memory_present(nid, start, end); }