From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout.efficios.com (smtpout.efficios.com [158.69.130.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA6723FB7DE for ; Tue, 7 Jul 2026 13:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=158.69.130.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783430179; cv=none; b=s5llq0JV7NP9ddBZtvNyOud4KkBJFXKiVwI4pGKmYhW4ReGj8gR6HQ3g0gHrykRgCI/Cy0SKxesEe7CYzB7lY2icn2VDR7u5p37x+QZ4rGrgTGRu+l8rGtSgbIdMLySBHg3areyMLy9TojFpynRDniDlpebqgQycxloXILcABnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783430179; c=relaxed/simple; bh=X2WEwnzCSicImvmmlqsdUelw2XH5Gh+wwNHN5ZY/tCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lqwLiyETK4bJvF6ApyfIt51kOMFLtTHG460v1HsvWIedEnD7bc9o0FNdhpwgPRbIsWy0/lv5dlVPsN3HFCQLeRfVaBhCE38eMcXy9G50ELGMHEpfY0sx9m2qeFeVI9DP6Unm0TprFFqn2stIR02/gfM4dFbSFuP4q1pEcWV6c4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=XGyH10bO; arc=none smtp.client-ip=158.69.130.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="XGyH10bO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1783430170; bh=YS6QqVHkXP1U2/UQ4NX0LJUlpc/d8EJ8crk/vCMK99k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XGyH10bOE7Q4ZrFmz9MwlnYR5QuTgKP6z9iowpgpyHZ31scBlujHPOHlqAM0T70r/ OStvm9VpZcGHXdYHd5p7xYqwdy8jLWjzO/738JaI8N9MO8rI0OCtMsCXwuZrfWCqyV SBNKqa2Chik01KlWXqi7iirdVKfu3aQS2KZoJ9paBPtpI/dnt1gN666kHfFA9BXqJJ MlFLpCxm2/4LICHMawR2QB7WzzHSNrg6TeosQqWHT8JwojNhwHsSVrdyQqEVcJHj1g u3GbspL2HxQ2zt4ES9ubwqUf/Z3a2H+ct6g7AWoaqcJ+OjsBP5JsB454SKznziubJp sft8SBAZ4jdBg== Received: from compudjdev.. (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4gvhZ252rszV2p; Tue, 07 Jul 2026 09:16:10 -0400 (EDT) From: Mathieu Desnoyers To: Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers Subject: [PATCH v20 5/6] init: move percpu_counter_tree_subsystem_init() earlier in boot Date: Tue, 7 Jul 2026 09:15:35 -0400 Message-ID: <20260707131544.75906-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260707131544.75906-1-mathieu.desnoyers@efficios.com> References: <20260707131544.75906-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Move percpu_counter_tree_subsystem_init() from after trap_init() to immediately after setup_nr_cpu_ids() in start_kernel(). The function's only dependency is nr_cpu_ids: it calls get_count_order(nr_cpu_ids), indexes into a const configuration table, and performs arithmetic to derive accuracy parameters. It requires no memory allocator, percpu areas, or other infrastructure. Initialize the subsystem as soon as its dependency is available rather than deferring until later in the boot sequence. This ensures percpu_counter_tree_items_size() returns the correct value well before its first use in mm_cache_init(). Signed-off-by: Mathieu Desnoyers --- init/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/main.c b/init/main.c index 8581ea542cde..a0701d400b0f 100644 --- a/init/main.c +++ b/init/main.c @@ -1001,6 +1001,7 @@ void start_kernel(void) setup_boot_config(); setup_command_line(command_line); setup_nr_cpu_ids(); + percpu_counter_tree_subsystem_init(); setup_per_cpu_areas(); smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ early_numa_node_init(); @@ -1032,7 +1033,6 @@ void start_kernel(void) vfs_caches_init_early(); sort_main_extable(); trap_init(); - percpu_counter_tree_subsystem_init(); mm_core_init(); maple_tree_init(); poking_init(); -- 2.43.0