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 7537B38B7DB for ; Thu, 2 Jul 2026 19:22:29 +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=1783020150; cv=none; b=mvtyvxbRdNTf7lcYIxO0N6MsWAD7IzPTIYNaN637fMe2eECdpMgToIHjnwIB775WavnzyywWWIErWHgwHIzaH3aXqvLi+/lKujg3LTxJJNPramTWKMqxtviuwzAZ95eotN/3WmD0sYLGmXL3bBic5PvmkJ9FueGA/xpa863uU+A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783020150; c=relaxed/simple; bh=X2WEwnzCSicImvmmlqsdUelw2XH5Gh+wwNHN5ZY/tCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UMOHxY4xDT8g9Bf7IYbMS+mfH8dJFcMi9AJmLa506qxCJrCWWdmo0GoXKmxnsqM13KzLR0hQY/mV5PxUBFFTgZDw/UZiDO9CkYapNv7HhelV0cTt+R6prVLGvlxVNnnm9qMKMoswi2LFXQYKWWqVkTnhyo3OACYXtr7HIoS3Pgk= 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=ovB9AmTP; 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="ovB9AmTP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=smtpout1; t=1783020143; bh=YS6QqVHkXP1U2/UQ4NX0LJUlpc/d8EJ8crk/vCMK99k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ovB9AmTPOA7bsk5TRuBcHS9E6fx1XJrF6/KU6UPTigqEI5msjt+jv4L8L1Gin5FMm Vtj4wqpruYvfhHZkgaHBQVeef2TnTdwU7vwaNFgkXMFK3/8rXaD+mFNmqNfSIFQ03Y XHsM9Yte8eQKffvewYvhf31aXLk5wbIYqpZ+/zXxMQUKtUcgDDfPs0e9zS8hYVefkg f4WcRdIlxmMuec+2i7QHlYH/uaR1UehPiWXDGQIloMIowLNXy8qM/FAMrgFW7w/Mkx RGYIfZDpZJ7/YN6LC/fhwSBWQ8s1wyGxBcARQxIq/Ctgv49qH9amtpUSgPltzH06dF RxfTc4AJbNAug== Received: from compudjdev.. (mtl.efficios.com [216.120.195.104]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4grmwv1GlLzS4S; Thu, 02 Jul 2026 15:22:23 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers Subject: [PATCH v19 5/6] init: move percpu_counter_tree_subsystem_init() earlier in boot Date: Thu, 2 Jul 2026 15:21:58 -0400 Message-ID: <20260702192214.41467-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260702192214.41467-1-mathieu.desnoyers@efficios.com> References: <20260702192214.41467-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