Remove the 'slow' argument from cpu_topology_set and create a new

function cpu_topology_setspeed which sets the relative speed of the
cpu.

This allows cpu_topology_set is be used at cpu hatch time.  The relative
speed is only known once all cpus have hatched/attached

OK ad@
This commit is contained in:
skrll 2020-02-15 07:20:40 +00:00
parent bc4050cada
commit 6149350c48
6 changed files with 35 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arm_cpu_topology.c,v 1.2 2020/01/16 06:34:24 mrg Exp $ */
/* $NetBSD: arm_cpu_topology.c,v 1.3 2020/02/15 07:20:41 skrll Exp $ */
/*
* Copyright (c) 2020 Matthew R. Green
@ -33,7 +33,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: arm_cpu_topology.c,v 1.2 2020/01/16 06:34:24 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: arm_cpu_topology.c,v 1.3 2020/02/15 07:20:41 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -61,7 +61,7 @@ arm_cpu_topology_set(struct cpu_info * const ci, uint64_t mpidr, bool slow)
coreid = __SHIFTOUT(mpidr, MPIDR_AFF0);
smtid = 0;
}
cpu_topology_set(ci, pkgid, coreid, smtid, numaid, slow);
cpu_topology_set(ci, pkgid, coreid, smtid, numaid);
#endif /* MULTIPROCESSOR */
}
@ -88,8 +88,7 @@ arm_cpu_do_topology(struct cpu_info *const newci)
* mi_cpu_attach() is called and ncpu is bumped, so call it
* directly here. This also handles the not-MP case.
*/
arm_cpu_topology_set(newci, arm_cpu_mpidr(newci),
newci->ci_capacity_dmips_mhz < best_cap);
cpu_topology_setspeed(newci, newci->ci_capacity_dmips_mhz < best_cap);
/*
* Using saved largest capacity, refresh previous topology info.
@ -98,8 +97,8 @@ arm_cpu_do_topology(struct cpu_info *const newci)
for (CPU_INFO_FOREACH(cii, ci)) {
if (ci == newci)
continue;
arm_cpu_topology_set(ci, arm_cpu_mpidr(ci),
ci->ci_capacity_dmips_mhz < best_cap);
cpu_topology_setspeed(newci,
newci->ci_capacity_dmips_mhz < best_cap);
}
#endif /* MULTIPROCESSOR */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.71 2020/02/09 09:30:37 skrll Exp $ */
/* $NetBSD: cpu.c,v 1.72 2020/02/15 07:20:41 skrll Exp $ */
/*-
* Copyright (c) 2001 Tsubai Masanari.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.71 2020/02/09 09:30:37 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.72 2020/02/15 07:20:41 skrll Exp $");
#include "opt_ppcparam.h"
#include "opt_multiprocessor.h"
@ -175,7 +175,7 @@ cpuattach(device_t parent, device_t self, void *aux)
core = package & 1;
package >>= 1;
}
cpu_topology_set(ci, package, core, 0, 0, false);
cpu_topology_set(ci, package, core, 0, 0);
if (ci->ci_khz == 0) {
cpu_OFgetspeed(self, ci);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu_subr.c,v 1.45 2020/01/09 16:35:03 ad Exp $ */
/* $NetBSD: cpu_subr.c,v 1.46 2020/02/15 07:20:41 skrll Exp $ */
/*-
* Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.45 2020/01/09 16:35:03 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.46 2020/02/15 07:20:41 skrll Exp $");
#include "opt_cputype.h"
#include "opt_ddb.h"
@ -189,7 +189,7 @@ cpu_info_alloc(struct pmap_tlb_info *ti, cpuid_t cpu_id, cpuid_t cpu_package_id,
ci->ci_divisor_recip = cpu_info_store.ci_divisor_recip;
ci->ci_cpuwatch_count = cpu_info_store.ci_cpuwatch_count;
cpu_topology_set(ci, cpu_package_id, cpu_core_id, cpu_smt_id, 0, false);
cpu_topology_set(ci, cpu_package_id, cpu_core_id, cpu_smt_id, 0);
pmap_md_alloc_ephemeral_address_space(ci);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu_topology.c,v 1.18 2020/01/20 06:50:34 mlelstv Exp $ */
/* $NetBSD: cpu_topology.c,v 1.19 2020/02/15 07:20:41 skrll Exp $ */
/*-
* Copyright (c) 2009 Mindaugas Rasiukevicius <rmind at NetBSD org>,
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.18 2020/01/20 06:50:34 mlelstv Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu_topology.c,v 1.19 2020/02/15 07:20:41 skrll Exp $");
#include "acpica.h"
@ -95,14 +95,14 @@ x86_cpu_topology(struct cpu_info *ci)
case CPUVENDOR_INTEL:
if (cpu_family < 6) {
cpu_topology_set(ci, package_id, core_id, smt_id,
numa_id, false);
numa_id);
return;
}
break;
case CPUVENDOR_AMD:
if (cpu_family < 0xf) {
cpu_topology_set(ci, package_id, core_id, smt_id,
numa_id, false);
numa_id);
return;
}
break;
@ -211,5 +211,5 @@ x86_cpu_topology(struct cpu_info *ci)
smt_id = __SHIFTOUT(apic_id, smt_mask);
}
cpu_topology_set(ci, package_id, core_id, smt_id, numa_id, false);
cpu_topology_set(ci, package_id, core_id, smt_id, numa_id);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_cpu.c,v 1.12 2020/02/09 09:30:22 skrll Exp $ */
/* $NetBSD: subr_cpu.c,v 1.13 2020/02/15 07:20:40 skrll Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019, 2020
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.12 2020/02/09 09:30:22 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.13 2020/02/15 07:20:40 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -142,23 +142,33 @@ cpu_softintr_p(void)
*/
void
cpu_topology_set(struct cpu_info *ci, u_int package_id, u_int core_id,
u_int smt_id, u_int numa_id, bool slow)
u_int smt_id, u_int numa_id)
{
enum cpu_rel rel;
cpu_topology_present = true;
cpu_topology_haveslow |= slow;
ci->ci_package_id = package_id;
ci->ci_core_id = core_id;
ci->ci_smt_id = smt_id;
ci->ci_numa_id = numa_id;
ci->ci_is_slow = slow;
ci->ci_is_slow = false;
for (rel = 0; rel < __arraycount(ci->ci_sibling); rel++) {
ci->ci_sibling[rel] = ci;
ci->ci_nsibling[rel] = 1;
}
}
/*
* Collect CPU relative speed
*/
void
cpu_topology_setspeed(struct cpu_info *ci, bool slow)
{
cpu_topology_haveslow |= slow;
ci->ci_is_slow = slow;
}
/*
* Link a CPU into the given circular list.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.49 2020/02/09 09:29:50 skrll Exp $ */
/* $NetBSD: cpu.h,v 1.50 2020/02/15 07:20:40 skrll Exp $ */
/*-
* Copyright (c) 2007 YAMAMOTO Takashi,
@ -90,7 +90,8 @@ bool cpu_kpreempt_disabled(void);
int cpu_lwp_setprivate(struct lwp *, void *);
void cpu_intr_redistribute(void);
u_int cpu_intr_count(struct cpu_info *);
void cpu_topology_set(struct cpu_info *, u_int, u_int, u_int, u_int, bool);
void cpu_topology_set(struct cpu_info *, u_int, u_int, u_int, u_int);
void cpu_topology_setspeed(struct cpu_info *, bool);
void cpu_topology_init(void);
#endif