Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Ensure the CPUs are all online. We take cpu...



details:   https://anonhg.NetBSD.org/src/rev/5da9562d1111
branches:  trunk
changeset: 830026:5da9562d1111
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Feb 22 11:57:39 2018 +0000

description:
Ensure the CPUs are all online. We take cpu_lock, so nobody can go offline
in the meantime.

diffstat:

 sys/arch/x86/x86/svs.c |  34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diffs (75 lines):

diff -r 99a6be2f8976 -r 5da9562d1111 sys/arch/x86/x86/svs.c
--- a/sys/arch/x86/x86/svs.c    Thu Feb 22 10:42:10 2018 +0000
+++ b/sys/arch/x86/x86/svs.c    Thu Feb 22 11:57:39 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svs.c,v 1.6 2018/02/22 10:42:11 maxv Exp $     */
+/*     $NetBSD: svs.c,v 1.7 2018/02/22 11:57:39 maxv Exp $     */
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.6 2018/02/22 10:42:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.7 2018/02/22 11:57:39 maxv Exp $");
 
 #include "opt_svs.h"
 
@@ -616,14 +616,28 @@
        x86_write_psl(psl);
 }
 
-static void
+static int
 svs_disable(void)
 {
+       struct cpu_info *ci = NULL;
+       CPU_INFO_ITERATOR cii;
        uint64_t xc;
 
+       mutex_enter(&cpu_lock);
+
        /*
-        * We expect all the CPUs to be online. XXX ensure they are.
+        * We expect all the CPUs to be online.
         */
+       for (CPU_INFO_FOREACH(cii, ci)) {
+               struct schedstate_percpu *spc = &ci->ci_schedstate;
+               if (spc->spc_flags & SPCF_OFFLINE) {
+                       printf("[!] cpu%d offline, SVS not disabled\n",
+                           cpu_index(ci));
+                       mutex_exit(&cpu_lock);
+                       return EOPNOTSUPP;
+               }
+       }
+
        svs_cpu_barrier1 = ncpu;
        svs_cpu_barrier2 = ncpu;
 
@@ -637,6 +651,10 @@
         */
 
        printf("[+] Done\n");
+
+       mutex_exit(&cpu_lock);
+
+       return 0;
 }
 
 int sysctl_machdep_svs_enabled(SYSCTLFN_ARGS);
@@ -659,10 +677,10 @@
        if (val == 1) {
                error = EINVAL;
        } else {
-               if (svs_enabled) {
-                       svs_disable();
-               }
-               error = 0;
+               if (svs_enabled)
+                       error = svs_disable();
+               else
+                       error = 0;
        }
 
        return error;



Home | Main Index | Thread Index | Old Index