Bug 217498 - kernel/cpu.c: linux misses the initialization of one CPU
Summary: kernel/cpu.c: linux misses the initialization of one CPU
Status: RESOLVED CODE_FIX
Alias: None
Product: Linux
Classification: Unclassified
Component: Kernel (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: Virtual assignee for kernel bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-28 12:48 UTC by spasswolf
Modified: 2023-05-31 10:44 UTC (History)
1 user (show)

See Also:
Kernel Version: next-20230518, next-20230525
Subsystem:
Regression: Yes
Bisected commit-id: 18415f33e2ac4ab382cbca8b5ff82a9036b5bd49


Attachments

Description spasswolf 2023-05-28 12:48:50 UTC
Since commit 18415f33e2ac4ab382cbca8b5ff82a9036b5bd49 linux misses the initialization of 1 CPU when the CONFIG_NR_CPUS is equal to the actual number of CPUs in the system. One can work around the issue by increasing CONFIG_NR_CPUS or apply the following patch:

From aa5ef661936655f0d806fdbf2d28fc9513dd5c69 Mon Sep 17 00:00:00 2001
From: Bert Karwatzki <spasswolf@web.de>
Date: Sun, 28 May 2023 14:35:45 +0200
Subject: [PATCH] Fix CPU detection when CONFIG_NR_CPUS is equal to the actual
 number of CPUs.

Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
 kernel/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 005f863a3d2b..5e900b531827 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1770,7 +1770,7 @@ static void __init cpuhp_bringup_mask(const struct cpumask *mask, unsigned int n
 	for_each_cpu(cpu, mask) {
 		struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
 
-		if (!--ncpus)
+		if (!ncpus--)
 			break;
 
 		if (cpu_up(cpu, target) && can_rollback_cpu(st)) {
-- 
2.40.1
Comment 1 Bagas Sanjaya 2023-05-31 06:02:18 UTC
(In reply to spasswolf from comment #0)
> Since commit 18415f33e2ac4ab382cbca8b5ff82a9036b5bd49 linux misses the
> initialization of 1 CPU when the CONFIG_NR_CPUS is equal to the actual
> number of CPUs in the system. One can work around the issue by increasing
> CONFIG_NR_CPUS or apply the following patch:
> 
> From aa5ef661936655f0d806fdbf2d28fc9513dd5c69 Mon Sep 17 00:00:00 2001
> From: Bert Karwatzki <spasswolf@web.de>
> Date: Sun, 28 May 2023 14:35:45 +0200
> Subject: [PATCH] Fix CPU detection when CONFIG_NR_CPUS is equal to the actual
>  number of CPUs.
> 
> Signed-off-by: Bert Karwatzki <spasswolf@web.de>
> ---
>  kernel/cpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 005f863a3d2b..5e900b531827 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -1770,7 +1770,7 @@ static void __init cpuhp_bringup_mask(const struct
> cpumask *mask, unsigned int n
>       for_each_cpu(cpu, mask) {
>               struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
>  
> -             if (!--ncpus)
> +             if (!ncpus--)
>                       break;
>  
>               if (cpu_up(cpu, target) && can_rollback_cpu(st)) {
> -- 
> 2.40.1

Can you instead try Mark Brown's patch [1]?

[1]: https://lore.kernel.org/all/87wn10ufj9.ffs@tglx/
Comment 2 spasswolf 2023-05-31 10:44:35 UTC
(In reply to Bagas Sanjaya from comment #1)
> (In reply to spasswolf from comment #0)
> > Since commit 18415f33e2ac4ab382cbca8b5ff82a9036b5bd49 linux misses the
> > initialization of 1 CPU when the CONFIG_NR_CPUS is equal to the actual
> > number of CPUs in the system. One can work around the issue by increasing
> > CONFIG_NR_CPUS or apply the following patch:
> > 
> > From aa5ef661936655f0d806fdbf2d28fc9513dd5c69 Mon Sep 17 00:00:00 2001
> > From: Bert Karwatzki <spasswolf@web.de>
> > Date: Sun, 28 May 2023 14:35:45 +0200
> > Subject: [PATCH] Fix CPU detection when CONFIG_NR_CPUS is equal to the
> actual
> >  number of CPUs.
> > 
> > Signed-off-by: Bert Karwatzki <spasswolf@web.de>
> > ---
> >  kernel/cpu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/kernel/cpu.c b/kernel/cpu.c
> > index 005f863a3d2b..5e900b531827 100644
> > --- a/kernel/cpu.c
> > +++ b/kernel/cpu.c
> > @@ -1770,7 +1770,7 @@ static void __init cpuhp_bringup_mask(const struct
> > cpumask *mask, unsigned int n
> >       for_each_cpu(cpu, mask) {
> >               struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
> >  
> > -             if (!--ncpus)
> > +             if (!ncpus--)
> >                       break;
> >  
> >               if (cpu_up(cpu, target) && can_rollback_cpu(st)) {
> > -- 
> > 2.40.1
> 
> Can you instead try Mark Brown's patch [1]?
> 
> [1]: https://lore.kernel.org/all/87wn10ufj9.ffs@tglx/

Works for me and already in next-20230531.

Note You need to log in before you can comment on or make changes to this bug.