Message ID | 20231229120107.2281153-1-mpe@ellerman.id.au (mailing list archive) |
---|---|
State | Accepted |
Commit | 5580e96dad5a439d561d9648ffcbccb739c2a120 |
Headers | show |
Series | [RFC,1/5] powerpc/smp: Adjust nr_cpu_ids to cover all threads of a core | expand |
On Fri, 29 Dec 2023 23:01:03 +1100, Michael Ellerman wrote: > If nr_cpu_ids is too low to include at least all the threads of a single > core adjust nr_cpu_ids upwards. This avoids triggering odd bugs in code > that assumes all threads of a core are available. > > Applied to powerpc/next. [1/5] powerpc/smp: Adjust nr_cpu_ids to cover all threads of a core https://git.kernel.org/powerpc/c/5580e96dad5a439d561d9648ffcbccb739c2a120 [2/5] powerpc/smp: Increase nr_cpu_ids to include the boot CPU https://git.kernel.org/powerpc/c/777f81f0a9c780a6443bcf2c7785f0cc2e87c1ef [3/5] powerpc/smp: Lookup avail once per device tree node https://git.kernel.org/powerpc/c/dca79603fbc592ec7ea8bd7ba274052d3984e882 [4/5] powerpc/smp: Factor out assign_threads() https://git.kernel.org/powerpc/c/9832de654499f0bf797a3719c4d4c5bd401f18f5 [5/5] powerpc/smp: Remap boot CPU onto core 0 if >= nr_cpu_ids https://git.kernel.org/powerpc/c/0875f1ceba974042069f04946aa8f1d4d1e688da cheers
On Thu, Feb 15, 2024 at 9:09 PM Michael Ellerman <patch-notifications@ellerman.id.au> wrote: > > On Fri, 29 Dec 2023 23:01:03 +1100, Michael Ellerman wrote: > > If nr_cpu_ids is too low to include at least all the threads of a single > > core adjust nr_cpu_ids upwards. This avoids triggering odd bugs in code > > that assumes all threads of a core are available. > > > > > > Applied to powerpc/next. > Great! After all these years, finally we are close to the conclusion of this feature. Thanks, Pingfan > [1/5] powerpc/smp: Adjust nr_cpu_ids to cover all threads of a core > https://git.kernel.org/powerpc/c/5580e96dad5a439d561d9648ffcbccb739c2a120 > [2/5] powerpc/smp: Increase nr_cpu_ids to include the boot CPU > https://git.kernel.org/powerpc/c/777f81f0a9c780a6443bcf2c7785f0cc2e87c1ef > [3/5] powerpc/smp: Lookup avail once per device tree node > https://git.kernel.org/powerpc/c/dca79603fbc592ec7ea8bd7ba274052d3984e882 > [4/5] powerpc/smp: Factor out assign_threads() > https://git.kernel.org/powerpc/c/9832de654499f0bf797a3719c4d4c5bd401f18f5 > [5/5] powerpc/smp: Remap boot CPU onto core 0 if >= nr_cpu_ids > https://git.kernel.org/powerpc/c/0875f1ceba974042069f04946aa8f1d4d1e688da > > cheers >
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 0b5878c3125b..58e80076bed5 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -375,6 +375,12 @@ static int __init early_init_dt_scan_cpus(unsigned long node, if (IS_ENABLED(CONFIG_PPC64)) boot_cpu_hwid = be32_to_cpu(intserv[found_thread]); + if (nr_cpu_ids % nthreads != 0) { + set_nr_cpu_ids(ALIGN(nr_cpu_ids, nthreads)); + pr_warn("nr_cpu_ids was not a multiple of threads_per_core, adjusted to %d\n", + nr_cpu_ids); + } + /* * PAPR defines "logical" PVR values for cpus that * meet various levels of the architecture:
If nr_cpu_ids is too low to include at least all the threads of a single core adjust nr_cpu_ids upwards. This avoids triggering odd bugs in code that assumes all threads of a core are available. Cc: stable@vger.kernel.org Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> --- arch/powerpc/kernel/prom.c | 6 ++++++ 1 file changed, 6 insertions(+)