From: Thomas Gleixner <tglx@linutronix.de>
To: Steven Price <steven.price@arm.com>,
Vincent Donnefort <vincent.donnefort@arm.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Baokun Li <libaokun1@huawei.com>,
Dongli Zhang <dongli.zhang@oracle.com>,
Randy Dunlap <rdunlap@infradead.org>,
Valentin Schneider <valentin.schneider@arm.com>,
Yuan ZhaoXiong <yuanzhaoxiong@baidu.com>,
YueHaibing <yuehaibing@huawei.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>
Subject: Re: [PATCH v2] cpu/hotplug: Set st->cpu earlier
Date: Wed, 23 Mar 2022 12:21:48 +0100 [thread overview]
Message-ID: <87czicap83.ffs@tglx> (raw)
In-Reply-To: <a704e21e-c1a6-6ffd-439c-e715a2633319@arm.com>
On Wed, Mar 23 2022 at 10:10, Steven Price wrote:
> On 22/03/2022 22:58, Thomas Gleixner wrote:
>> Indeed. But the description is not the only problem here:
>>
>> It's completely uncomprehensible from the code in _cpu_up() _WHY_ this
>>
>> st->cpu = cpu;
>>
>> assignment has to be there.
>>
>> It's non-sensical if you really think about it, right?
>
> I entirely agree, and I did ask in my v1 posting[1] if anyone could
> point me to a better place to do the assignment. Vincent suggested
> moving it earlier in _cpu_up() which is this v2.
>
> But it still seems out-of-place to me. I've just had a go at simply
> removing the 'cpu' member and it doesn't look too bad. I'll post that
> patch as a follow up. I'm open to other suggestions for the best way to
> fix this.
Yes, we can do that. The alternative solution is to initialize the
states once upfront. Something like the uncompiled below.
Thanks,
tglx
---
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -714,15 +714,6 @@ static int cpuhp_up_callbacks(unsigned i
/*
* The cpu hotplug threads manage the bringup and teardown of the cpus
*/
-static void cpuhp_create(unsigned int cpu)
-{
- struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
-
- init_completion(&st->done_up);
- init_completion(&st->done_down);
- st->cpu = cpu;
-}
-
static int cpuhp_should_run(unsigned int cpu)
{
struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
@@ -882,15 +873,28 @@ static int cpuhp_kick_ap_work(unsigned i
static struct smp_hotplug_thread cpuhp_threads = {
.store = &cpuhp_state.thread,
- .create = &cpuhp_create,
.thread_should_run = cpuhp_should_run,
.thread_fn = cpuhp_thread_fun,
.thread_comm = "cpuhp/%u",
.selfparking = true,
};
+static __init void cpuhp_init_state(void)
+{
+ struct cpuhp_cpu_state *st;
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ st = per_cpu_ptr(&cpuhp_state, cpu);
+ init_completion(&st->done_up);
+ init_completion(&st->done_down);
+ st->cpu = cpu;
+ }
+}
+
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));
}
next prev parent reply other threads:[~2022-03-23 11:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 15:36 [PATCH v2] cpu/hotplug: Set st->cpu earlier Steven Price
2022-03-22 11:38 ` Vincent Donnefort
2022-03-22 15:31 ` Thomas Gleixner
2022-03-22 15:59 ` Vincent Donnefort
2022-03-22 22:58 ` Thomas Gleixner
2022-03-23 10:10 ` Steven Price
2022-03-23 10:11 ` [PATCH] cpu/hotplug: Remove the 'cpu' member of cpuhp_cpu_state Steven Price
2022-03-23 11:21 ` Thomas Gleixner [this message]
2022-03-28 15:19 ` [PATCH v2] cpu/hotplug: Set st->cpu earlier Steven Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87czicap83.ffs@tglx \
--to=tglx@linutronix.de \
--cc=dietmar.eggemann@arm.com \
--cc=dongli.zhang@oracle.com \
--cc=libaokun1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=steven.price@arm.com \
--cc=valentin.schneider@arm.com \
--cc=vincent.donnefort@arm.com \
--cc=yuanzhaoxiong@baidu.com \
--cc=yuehaibing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox