From nobody Mon May 11 05:35:49 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C970C433EF for ; Wed, 13 Apr 2022 19:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236869AbiDMTfE (ORCPT ); Wed, 13 Apr 2022 15:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233005AbiDMTe6 (ORCPT ); Wed, 13 Apr 2022 15:34:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 788EB76585; Wed, 13 Apr 2022 12:32:36 -0700 (PDT) Date: Wed, 13 Apr 2022 19:32:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649878355; h=from:from:sender:sender:reply-to: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=0iorNaHWnmbP15mgEIAifHH7Nvn7KVWv7GrX/fT9Fhg=; b=SDjahuni5frp/d8eGi7NGXhKJJgca52DhTGRqJghvjGuWV+Z9wy6fjQ6agd/Bqrw8Xhr3A hDny/qzNpK2/EtHkDWOldghdoA1IPw8H6glb1XlwGZsaVSGncLRCHEebRpxuuJk8CvBTAQ 26f+k6FOotwkeIyx/R2O0k2wsoYUHLSNgNitI7MAxcT3p3qU1TinmCWZqE5v3wJp0IWuiO eaKZn2y7OzAztjY5HYDnZW3XXumylhoYbNSAsGMzQevTx56TE4HJr5uCrmPjBlFIv1pSO+ r4yx+of3qDHQhiI677H7IToPzYoJ2lojcGgm/FDLM0loFCDWcVJ+4JlDnHChZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649878355; h=from:from:sender:sender:reply-to: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=0iorNaHWnmbP15mgEIAifHH7Nvn7KVWv7GrX/fT9Fhg=; b=ZyTrxx0hkn5OjKVf4CJbN55grN1ixO4TyvBSLWRc1MgWVLGZYaZWk21rFyXa6CGCoZ4Y45 4KnGQmf4FIutOQCg== From: "tip-bot2 for Steven Price" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: smp/core] cpu/hotplug: Initialise all cpuhp_cpu_state structs earlier Cc: Thomas Gleixner , Steven Price , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220411152233.474129-3-steven.price@arm.com> References: <20220411152233.474129-3-steven.price@arm.com> MIME-Version: 1.0 Message-ID: <164987835389.4207.2665456331757900114.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the smp/core branch of tip: Commit-ID: d308077e5e4dc8c93f97f5ebc70274e7c7a92d49 Gitweb: https://git.kernel.org/tip/d308077e5e4dc8c93f97f5ebc70274e7c= 7a92d49 Author: Steven Price AuthorDate: Mon, 11 Apr 2022 16:22:33 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 13 Apr 2022 21:27:41 +02:00 cpu/hotplug: Initialise all cpuhp_cpu_state structs earlier Rather than waiting until a CPU is first brought online, do the initialisation of the cpuhp_cpu_state structure for each CPU during the __init phase. This saves a (small) amount of non-__init memory and avoids potential confusion about when the cpuhp_cpu_state struct is valid. Suggested-by: Thomas Gleixner Signed-off-by: Steven Price Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20220411152233.474129-3-steven.price@arm.com --- kernel/cpu.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index d0a9aa0..02a77ac 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -716,14 +716,6 @@ static int cpuhp_up_callbacks(unsigned int cpu, struct= cpuhp_cpu_state *st, /* * The cpu hotplug threads manage the bringup and teardown of the cpus */ -static void cpuhp_create(unsigned int cpu) -{ - struct cpuhp_cpu_state *st =3D per_cpu_ptr(&cpuhp_state, cpu); - - init_completion(&st->done_up); - init_completion(&st->done_down); -} - static int cpuhp_should_run(unsigned int cpu) { struct cpuhp_cpu_state *st =3D this_cpu_ptr(&cpuhp_state); @@ -883,15 +875,27 @@ static int cpuhp_kick_ap_work(unsigned int cpu) =20 static struct smp_hotplug_thread cpuhp_threads =3D { .store =3D &cpuhp_state.thread, - .create =3D &cpuhp_create, .thread_should_run =3D cpuhp_should_run, .thread_fn =3D cpuhp_thread_fun, .thread_comm =3D "cpuhp/%u", .selfparking =3D true, }; =20 +static __init void cpuhp_init_state(void) +{ + struct cpuhp_cpu_state *st; + int cpu; + + for_each_possible_cpu(cpu) { + st =3D per_cpu_ptr(&cpuhp_state, cpu); + init_completion(&st->done_up); + init_completion(&st->done_down); + } +} + void __init cpuhp_threads_init(void) { + cpuhp_init_state(); BUG_ON(smpboot_register_percpu_thread(&cpuhp_threads)); kthread_unpark(this_cpu_read(cpuhp_state.thread)); }