Message ID | 20231229120107.2281153-4-mpe@ellerman.id.au (mailing list archive) |
---|---|
State | Accepted |
Commit | 9832de654499f0bf797a3719c4d4c5bd401f18f5 |
Headers | show |
Series | [RFC,1/5] powerpc/smp: Adjust nr_cpu_ids to cover all threads of a core | expand |
Michael Ellerman <mpe@ellerman.id.au> writes: .... > +static int assign_threads(unsigned cpu, unsigned int nthreads, bool avail, > May be rename 'avail' to 'present' > + const __be32 *hw_ids) > +{ > + for (int i = 0; i < nthreads && cpu < nr_cpu_ids; i++) { > + __be32 hwid; > + > + hwid = be32_to_cpu(hw_ids[i]); > + > + DBG(" thread %d -> cpu %d (hard id %d)\n", i, cpu, hwid); > + > + set_cpu_present(cpu, avail); > + set_cpu_possible(cpu, true); > + cpu_to_phys_id[cpu] = hwid; > + cpu++; > + } > + -aneesh
Aneesh Kumar K.V <aneesh.kumar@kernel.org> writes: > Michael Ellerman <mpe@ellerman.id.au> writes: > > .... > >> +static int assign_threads(unsigned cpu, unsigned int nthreads, bool avail, >> > > May be rename 'avail' to 'present' Yeah, will do. cheers >> + const __be32 *hw_ids) >> +{ >> + for (int i = 0; i < nthreads && cpu < nr_cpu_ids; i++) { >> + __be32 hwid; >> + >> + hwid = be32_to_cpu(hw_ids[i]); >> + >> + DBG(" thread %d -> cpu %d (hard id %d)\n", i, cpu, hwid); >> + >> + set_cpu_present(cpu, avail); >> + set_cpu_possible(cpu, true); >> + cpu_to_phys_id[cpu] = hwid; >> + cpu++; >> + } >> + > > -aneesh
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index ff7616023ade..d9f8ed9bd2fc 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -411,6 +411,25 @@ static void __init cpu_init_thread_core_maps(int tpc) u32 *cpu_to_phys_id = NULL; +static int assign_threads(unsigned cpu, unsigned int nthreads, bool avail, + const __be32 *hw_ids) +{ + for (int i = 0; i < nthreads && cpu < nr_cpu_ids; i++) { + __be32 hwid; + + hwid = be32_to_cpu(hw_ids[i]); + + DBG(" thread %d -> cpu %d (hard id %d)\n", i, cpu, hwid); + + set_cpu_present(cpu, avail); + set_cpu_possible(cpu, true); + cpu_to_phys_id[cpu] = hwid; + cpu++; + } + + return cpu; +} + /** * setup_cpu_maps - initialize the following cpu maps: * cpu_possible_mask @@ -446,7 +465,7 @@ void __init smp_setup_cpu_maps(void) for_each_node_by_type(dn, "cpu") { const __be32 *intserv; __be32 cpu_be; - int j, len; + int len; DBG(" * %pOF...\n", dn); @@ -473,16 +492,7 @@ void __init smp_setup_cpu_maps(void) avail = !of_property_match_string(dn, "enable-method", "spin-table"); - for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) { - - DBG(" thread %d -> cpu %d (hard id %d)\n", - j, cpu, be32_to_cpu(intserv[j])); - - set_cpu_present(cpu, avail); - set_cpu_possible(cpu, true); - cpu_to_phys_id[cpu] = be32_to_cpu(intserv[j]); - cpu++; - } + cpu = assign_threads(cpu, nthreads, avail, intserv); if (cpu >= nr_cpu_ids) { of_node_put(dn);
Factor out the for loop that assigns CPU numbers to threads of a core. The function takes the next CPU number to use as input, and returns the next available CPU number after the threads has been assigned. This will allow a subsequent change to assign threads out of order. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> --- arch/powerpc/kernel/setup-common.c | 32 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-)