Module Name: src Committed By: skrll Date: Sat Feb 15 07:20:41 UTC 2020
Modified Files: src/sys/arch/arm/arm: arm_cpu_topology.c src/sys/arch/macppc/macppc: cpu.c src/sys/arch/mips/mips: cpu_subr.c src/sys/arch/x86/x86: cpu_topology.c src/sys/kern: subr_cpu.c src/sys/sys: cpu.h Log Message: 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@ To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/arm/arm_cpu_topology.c cvs rdiff -u -r1.71 -r1.72 src/sys/arch/macppc/macppc/cpu.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/mips/mips/cpu_subr.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/x86/cpu_topology.c cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_cpu.c cvs rdiff -u -r1.49 -r1.50 src/sys/sys/cpu.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/arm/arm_cpu_topology.c diff -u src/sys/arch/arm/arm/arm_cpu_topology.c:1.2 src/sys/arch/arm/arm/arm_cpu_topology.c:1.3 --- src/sys/arch/arm/arm/arm_cpu_topology.c:1.2 Thu Jan 16 06:34:24 2020 +++ src/sys/arch/arm/arm/arm_cpu_topology.c Sat Feb 15 07:20:41 2020 @@ -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 * c 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 *con * 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 *con 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 */ } Index: src/sys/arch/macppc/macppc/cpu.c diff -u src/sys/arch/macppc/macppc/cpu.c:1.71 src/sys/arch/macppc/macppc/cpu.c:1.72 --- src/sys/arch/macppc/macppc/cpu.c:1.71 Sun Feb 9 09:30:37 2020 +++ src/sys/arch/macppc/macppc/cpu.c Sat Feb 15 07:20:41 2020 @@ -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 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); Index: src/sys/arch/mips/mips/cpu_subr.c diff -u src/sys/arch/mips/mips/cpu_subr.c:1.45 src/sys/arch/mips/mips/cpu_subr.c:1.46 --- src/sys/arch/mips/mips/cpu_subr.c:1.45 Thu Jan 9 16:35:03 2020 +++ src/sys/arch/mips/mips/cpu_subr.c Sat Feb 15 07:20:41 2020 @@ -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, 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); Index: src/sys/arch/x86/x86/cpu_topology.c diff -u src/sys/arch/x86/x86/cpu_topology.c:1.18 src/sys/arch/x86/x86/cpu_topology.c:1.19 --- src/sys/arch/x86/x86/cpu_topology.c:1.18 Mon Jan 20 06:50:34 2020 +++ src/sys/arch/x86/x86/cpu_topology.c Sat Feb 15 07:20:41 2020 @@ -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); } Index: src/sys/kern/subr_cpu.c diff -u src/sys/kern/subr_cpu.c:1.12 src/sys/kern/subr_cpu.c:1.13 --- src/sys/kern/subr_cpu.c:1.12 Sun Feb 9 09:30:22 2020 +++ src/sys/kern/subr_cpu.c Sat Feb 15 07:20:40 2020 @@ -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,17 +142,16 @@ 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; @@ -160,6 +159,17 @@ cpu_topology_set(struct cpu_info *ci, u_ } /* + * 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. */ static void Index: src/sys/sys/cpu.h diff -u src/sys/sys/cpu.h:1.49 src/sys/sys/cpu.h:1.50 --- src/sys/sys/cpu.h:1.49 Sun Feb 9 09:29:50 2020 +++ src/sys/sys/cpu.h Sat Feb 15 07:20:40 2020 @@ -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