Source-Changes-HG archive

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

[src/trunk]: src/sys cpu topology:



details:   https://anonhg.NetBSD.org/src/rev/cbbca59d0123
branches:  trunk
changeset: 467059:cbbca59d0123
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Jan 12 13:29:24 2020 +0000

description:
cpu topology:

- Fix a stupid bug where it complained about non-existent SMT on assymetric
  systems.

- Give each CPU a pointer back to the first CPU in same package.

diffstat:

 sys/kern/subr_cpu.c |  12 ++++++++----
 sys/sys/cpu_data.h  |   4 +++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diffs (80 lines):

diff -r 5528b39ec9a1 -r cbbca59d0123 sys/kern/subr_cpu.c
--- a/sys/kern/subr_cpu.c       Sun Jan 12 13:19:32 2020 +0000
+++ b/sys/kern/subr_cpu.c       Sun Jan 12 13:29:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_cpu.c,v 1.7 2020/01/12 09:29:18 mrg Exp $ */
+/*     $NetBSD: subr_cpu.c,v 1.8 2020/01/12 13:29:24 ad 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.7 2020/01/12 09:29:18 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.8 2020/01/12 13:29:24 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -207,6 +207,8 @@
                        }
                        printf("\n");
                }
+               printf("%s first in package: %s\n", cpu_name(ci),
+                   cpu_name(ci->ci_package1st));
        }
 #endif /* DEBUG */
 }
@@ -229,6 +231,7 @@
        }
        ci->ci_schedstate.spc_flags |=
            (SPCF_CORE1ST | SPCF_PACKAGE1ST | SPCF_1STCLASS);
+       ci->ci_package1st = ci;
 }
 
 /*
@@ -338,8 +341,9 @@
                ci3->ci_schedstate.spc_flags |= SPCF_PACKAGE1ST;
 
                /* Walk through all CPUs in package and point to first. */
-               ci2 = ci;
+               ci2 = ci3;
                do {
+                       ci2->ci_package1st = ci3;
                        ci2->ci_sibling[CPUREL_PACKAGE1ST] = ci3;
                        ci2 = ci2->ci_sibling[CPUREL_PACKAGE];
                } while (ci2 != ci);
@@ -376,7 +380,7 @@
                 * others, mark first class CPUs for the scheduler.  This
                 * conflicts with SMT right now so whinge if observed.
                 */
-               if (curcpu()->ci_nsibling[CPUREL_CORE] == 1) {
+               if (curcpu()->ci_nsibling[CPUREL_CORE] > 1) {
                        printf("cpu_topology_init: asymmetric & SMT??\n");
                }
                for (CPU_INFO_FOREACH(cii, ci)) {
diff -r 5528b39ec9a1 -r cbbca59d0123 sys/sys/cpu_data.h
--- a/sys/sys/cpu_data.h        Sun Jan 12 13:19:32 2020 +0000
+++ b/sys/sys/cpu_data.h        Sun Jan 12 13:29:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_data.h,v 1.47 2020/01/09 16:35:03 ad Exp $ */
+/*     $NetBSD: cpu_data.h,v 1.48 2020/01/12 13:29:24 ad Exp $ */
 
 /*-
  * Copyright (c) 2004, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -151,6 +151,7 @@
        bool            cpu_is_slow;
        u_int           cpu_nsibling[CPUREL_COUNT];
        struct cpu_info *cpu_sibling[CPUREL_COUNT];
+       struct cpu_info *cpu_package1st;        /* 1st CPU in our package */
 
        /*
         * This section is mostly CPU-private.
@@ -203,6 +204,7 @@
 #define        ci_is_slow              ci_data.cpu_is_slow
 #define        ci_nsibling             ci_data.cpu_nsibling
 #define        ci_sibling              ci_data.cpu_sibling
+#define        ci_package1st           ci_data.cpu_package1st
 #define        ci_faultrng             ci_data.cpu_faultrng
 #define        ci_counts               ci_data.cpu_counts
 



Home | Main Index | Thread Index | Old Index