* [PATCH] kernel/cpu.c: fix init_cpu_online @ 2022-01-31 1:46 Yury Norov 2022-01-31 11:19 ` Vincent Donnefort 0 siblings, 1 reply; 3+ messages in thread From: Yury Norov @ 2022-01-31 1:46 UTC (permalink / raw) To: Thomas Gleixner, Peter Zijlstra, Valentin Schneider, Vincent Donnefort, Ingo Molnar, YueHaibing, Yuan ZhaoXiong, Randy Dunlap, Mathieu Desnoyers, linux-ia64, linux-kernel Cc: Yury Norov cpu_online_mask has an associate counter of online cpus, which must be initialized in init_cpu_online(). Fixes: 0c09ab96fc82010 (cpu/hotplug: Cache number of online CPUs) Signed-off-by: Yury Norov <yury.norov@gmail.com> --- kernel/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index 407a2568f35e..cd7605204d4d 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2616,6 +2616,7 @@ void init_cpu_possible(const struct cpumask *src) void init_cpu_online(const struct cpumask *src) { cpumask_copy(&__cpu_online_mask, src); + atomic_set(&__num_online_cpus, cpumask_weight(cpu_online_mask)); } void set_cpu_online(unsigned int cpu, bool online) -- 2.30.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kernel/cpu.c: fix init_cpu_online 2022-01-31 1:46 [PATCH] kernel/cpu.c: fix init_cpu_online Yury Norov @ 2022-01-31 11:19 ` Vincent Donnefort 2022-02-01 18:30 ` Yury Norov 0 siblings, 1 reply; 3+ messages in thread From: Vincent Donnefort @ 2022-01-31 11:19 UTC (permalink / raw) To: Yury Norov Cc: Thomas Gleixner, Peter Zijlstra, Valentin Schneider, Ingo Molnar, YueHaibing, Yuan ZhaoXiong, Randy Dunlap, Mathieu Desnoyers, linux-ia64, linux-kernel Hi Yury, On Sun, Jan 30, 2022 at 05:46:48PM -0800, Yury Norov wrote: > cpu_online_mask has an associate counter of online cpus, which must be > initialized in init_cpu_online(). > > Fixes: 0c09ab96fc82010 (cpu/hotplug: Cache number of online CPUs) Aren't the increments/decrements from set_cpu_online() enough? I guess we could argue that this isn't a private function and the num_online_cpus should be updated here. But unless I missed something, init_cpu_online() is only called in ia64 arch, in the !SMP case. Is this the problem you're trying to tackle? If not, I'm not sure that warrants a "Fixes:" tag > Signed-off-by: Yury Norov <yury.norov@gmail.com> > --- > kernel/cpu.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/cpu.c b/kernel/cpu.c > index 407a2568f35e..cd7605204d4d 100644 > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -2616,6 +2616,7 @@ void init_cpu_possible(const struct cpumask *src) > void init_cpu_online(const struct cpumask *src) > { > cpumask_copy(&__cpu_online_mask, src); > + atomic_set(&__num_online_cpus, cpumask_weight(cpu_online_mask)); > } > > void set_cpu_online(unsigned int cpu, bool online) > -- > 2.30.2 > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kernel/cpu.c: fix init_cpu_online 2022-01-31 11:19 ` Vincent Donnefort @ 2022-02-01 18:30 ` Yury Norov 0 siblings, 0 replies; 3+ messages in thread From: Yury Norov @ 2022-02-01 18:30 UTC (permalink / raw) To: Vincent Donnefort Cc: Thomas Gleixner, Peter Zijlstra, Valentin Schneider, Ingo Molnar, YueHaibing, Yuan ZhaoXiong, Randy Dunlap, Mathieu Desnoyers, linux-ia64, linux-kernel On Mon, Jan 31, 2022 at 3:20 AM Vincent Donnefort <vincent.donnefort@arm.com> wrote: > > Hi Yury, > > On Sun, Jan 30, 2022 at 05:46:48PM -0800, Yury Norov wrote: > > cpu_online_mask has an associate counter of online cpus, which must be > > initialized in init_cpu_online(). > > > > Fixes: 0c09ab96fc82010 (cpu/hotplug: Cache number of online CPUs) > > Aren't the increments/decrements from set_cpu_online() enough? It will only count cpus onlined by this function . Those onlined before will never be counted. > I guess we could argue that this isn't a private function and the > num_online_cpus should be updated here. But unless I missed something, > init_cpu_online() is only called in ia64 arch, in the !SMP case. Yes, this looks weird. In !SMP case this counter and function are not needed at all, and this is the only case when the function is used. In SMP case, things work just because the cpu_online_mask and num_online_cpus are both initialized to 0. If this is the intentional behavior, and it would be like this forever, then the init_cpu_online() must be dropped, otherwise it needs to be fixed. Isn't? > Is this the problem you're trying to tackle? It was initially a part of a bigger series that added 3 more counters like this: https://lkml.org/lkml/2021/12/18/253 But now it's postponed. > If not, I'm not sure that warrants a "Fixes:" tag The patch 0c09ab96fc82010 adds the counter but does not initialize it properly. For me it sounds like a fix. > > Signed-off-by: Yury Norov <yury.norov@gmail.com> > > --- > > kernel/cpu.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/kernel/cpu.c b/kernel/cpu.c > > index 407a2568f35e..cd7605204d4d 100644 > > --- a/kernel/cpu.c > > +++ b/kernel/cpu.c > > @@ -2616,6 +2616,7 @@ void init_cpu_possible(const struct cpumask *src) > > void init_cpu_online(const struct cpumask *src) > > { > > cpumask_copy(&__cpu_online_mask, src); > > + atomic_set(&__num_online_cpus, cpumask_weight(cpu_online_mask)); > > } > > > > void set_cpu_online(unsigned int cpu, bool online) > > -- > > 2.30.2 > > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-01 18:30 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-01-31 1:46 [PATCH] kernel/cpu.c: fix init_cpu_online Yury Norov 2022-01-31 11:19 ` Vincent Donnefort 2022-02-01 18:30 ` Yury Norov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox