Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Remove the 'slow' argument from cpu_topology_set and cre...



details:   https://anonhg.NetBSD.org/src/rev/5cbce493b2bb
branches:  trunk
changeset: 744872:5cbce493b2bb
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Feb 15 07:20:40 2020 +0000

description:
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@

diffstat:

 sys/arch/arm/arm/arm_cpu_topology.c |  13 ++++++-------
 sys/arch/macppc/macppc/cpu.c        |   6 +++---
 sys/arch/mips/mips/cpu_subr.c       |   6 +++---
 sys/arch/x86/x86/cpu_topology.c     |  10 +++++-----
 sys/kern/subr_cpu.c                 |  20 +++++++++++++++-----
 sys/sys/cpu.h                       |   5 +++--
 6 files changed, 35 insertions(+), 25 deletions(-)

diffs (219 lines):

diff -r 0b12b18fc11d -r 5cbce493b2bb sys/arch/arm/arm/arm_cpu_topology.c
--- a/sys/arch/arm/arm/arm_cpu_topology.c       Sat Feb 15 03:27:58 2020 +0000
+++ b/sys/arch/arm/arm/arm_cpu_topology.c       Sat Feb 15 07:20:40 2020 +0000
@@ -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 @@
                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 @@
         * 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 @@
        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 */
 }
diff -r 0b12b18fc11d -r 5cbce493b2bb sys/arch/macppc/macppc/cpu.c
--- a/sys/arch/macppc/macppc/cpu.c      Sat Feb 15 03:27:58 2020 +0000
+++ b/sys/arch/macppc/macppc/cpu.c      Sat Feb 15 07:20:40 2020 +0000
@@ -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 @@
                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);
diff -r 0b12b18fc11d -r 5cbce493b2bb sys/arch/mips/mips/cpu_subr.c
--- a/sys/arch/mips/mips/cpu_subr.c     Sat Feb 15 03:27:58 2020 +0000
+++ b/sys/arch/mips/mips/cpu_subr.c     Sat Feb 15 07:20:40 2020 +0000
@@ -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 @@
        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);
 
diff -r 0b12b18fc11d -r 5cbce493b2bb sys/arch/x86/x86/cpu_topology.c
--- a/sys/arch/x86/x86/cpu_topology.c   Sat Feb 15 03:27:58 2020 +0000
+++ b/sys/arch/x86/x86/cpu_topology.c   Sat Feb 15 07:20:40 2020 +0000
@@ -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 @@
        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 @@
                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);
 }
diff -r 0b12b18fc11d -r 5cbce493b2bb sys/kern/subr_cpu.c
--- a/sys/kern/subr_cpu.c       Sat Feb 15 03:27:58 2020 +0000
+++ b/sys/kern/subr_cpu.c       Sat Feb 15 07:20:40 2020 +0000
@@ -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 @@
  */
 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 @@
 }
 
 /*
+ * 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
diff -r 0b12b18fc11d -r 5cbce493b2bb sys/sys/cpu.h
--- a/sys/sys/cpu.h     Sat Feb 15 03:27:58 2020 +0000
+++ b/sys/sys/cpu.h     Sat Feb 15 07:20:40 2020 +0000
@@ -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 @@
 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
 



Home | Main Index | Thread Index | Old Index