Author: scottl
Date: Wed May  7 20:28:27 2014
New Revision: 265606
URL: http://svnweb.freebsd.org/changeset/base/265606

Log:
  Merge r264984
  
  Retire smp_active.  It was racey and caused demonstrated problems with
  the cpufreq code.  Replace its use with smp_started.  There's at least
  one userland tool that still looks at the kern.smp.active sysctl, so
  preserve it but point it to smp_started as well.
  
  Obtained from:        Netflix, Inc.

Modified:
  stable/10/sys/amd64/amd64/mp_machdep.c
  stable/10/sys/amd64/amd64/vm_machdep.c
  stable/10/sys/arm/arm/mp_machdep.c
  stable/10/sys/i386/i386/mp_machdep.c
  stable/10/sys/i386/i386/vm_machdep.c
  stable/10/sys/i386/xen/mp_machdep.c
  stable/10/sys/ia64/ia64/mp_machdep.c
  stable/10/sys/kern/kern_cpu.c
  stable/10/sys/kern/subr_smp.c
  stable/10/sys/mips/mips/mp_machdep.c
  stable/10/sys/powerpc/powerpc/mp_machdep.c
  stable/10/sys/sparc64/sparc64/mp_machdep.c
  stable/10/sys/sys/smp.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/amd64/mp_machdep.c
==============================================================================
--- stable/10/sys/amd64/amd64/mp_machdep.c      Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/amd64/amd64/mp_machdep.c      Wed May  7 20:28:27 2014        
(r265606)
@@ -771,7 +771,6 @@ init_secondary(void)
        if (smp_cpus == mp_ncpus) {
                /* enable IPI's, tlb shootdown, freezes etc */
                atomic_store_rel_int(&smp_started, 1);
-               smp_active = 1;  /* historic */
        }
 
        /*

Modified: stable/10/sys/amd64/amd64/vm_machdep.c
==============================================================================
--- stable/10/sys/amd64/amd64/vm_machdep.c      Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/amd64/amd64/vm_machdep.c      Wed May  7 20:28:27 2014        
(r265606)
@@ -597,7 +597,7 @@ cpu_reset()
        cpuset_t map;
        u_int cnt;
 
-       if (smp_active) {
+       if (smp_started) {
                map = all_cpus;
                CPU_CLR(PCPU_GET(cpuid), &map);
                CPU_NAND(&map, &stopped_cpus);

Modified: stable/10/sys/arm/arm/mp_machdep.c
==============================================================================
--- stable/10/sys/arm/arm/mp_machdep.c  Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/arm/arm/mp_machdep.c  Wed May  7 20:28:27 2014        
(r265606)
@@ -212,7 +212,6 @@ init_secondary(int cpu)
        if (smp_cpus == mp_ncpus) {
                /* enable IPI's, tlb shootdown, freezes etc */
                atomic_store_rel_int(&smp_started, 1);
-               smp_active = 1;
        }
 
        mtx_unlock_spin(&ap_boot_mtx);

Modified: stable/10/sys/i386/i386/mp_machdep.c
==============================================================================
--- stable/10/sys/i386/i386/mp_machdep.c        Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/i386/i386/mp_machdep.c        Wed May  7 20:28:27 2014        
(r265606)
@@ -805,7 +805,6 @@ init_secondary(void)
        if (smp_cpus == mp_ncpus) {
                /* enable IPI's, tlb shootdown, freezes etc */
                atomic_store_rel_int(&smp_started, 1);
-               smp_active = 1;  /* historic */
        }
 
        mtx_unlock_spin(&ap_boot_mtx);

Modified: stable/10/sys/i386/i386/vm_machdep.c
==============================================================================
--- stable/10/sys/i386/i386/vm_machdep.c        Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/i386/i386/vm_machdep.c        Wed May  7 20:28:27 2014        
(r265606)
@@ -619,7 +619,7 @@ cpu_reset()
        cpuset_t map;
        u_int cnt;
 
-       if (smp_active) {
+       if (smp_started) {
                map = all_cpus;
                CPU_CLR(PCPU_GET(cpuid), &map);
                CPU_NAND(&map, &stopped_cpus);

Modified: stable/10/sys/i386/xen/mp_machdep.c
==============================================================================
--- stable/10/sys/i386/xen/mp_machdep.c Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/i386/xen/mp_machdep.c Wed May  7 20:28:27 2014        
(r265606)
@@ -655,7 +655,6 @@ init_secondary(void)
        if (smp_cpus == mp_ncpus) {
                /* enable IPI's, tlb shootdown, freezes etc */
                atomic_store_rel_int(&smp_started, 1);
-               smp_active = 1;  /* historic */
        }
 
        mtx_unlock_spin(&ap_boot_mtx);

Modified: stable/10/sys/ia64/ia64/mp_machdep.c
==============================================================================
--- stable/10/sys/ia64/ia64/mp_machdep.c        Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/ia64/ia64/mp_machdep.c        Wed May  7 20:28:27 2014        
(r265606)
@@ -455,7 +455,7 @@ cpu_mp_unleash(void *dummy)
                    mp_ncpus, cpus, smp_cpus);
        }
 
-       smp_active = 1;
+       /* XXX Atomic set operation? */
        smp_started = 1;
 
        /*

Modified: stable/10/sys/kern/kern_cpu.c
==============================================================================
--- stable/10/sys/kern/kern_cpu.c       Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/kern/kern_cpu.c       Wed May  7 20:28:27 2014        
(r265606)
@@ -268,7 +268,7 @@ cf_set_method(device_t dev, const struct
         * switching the main CPU.  XXXTODO: Need to think more about how to
         * handle having different CPUs at different frequencies.  
         */
-       if (mp_ncpus > 1 && !smp_active) {
+       if (mp_ncpus > 1 && !smp_started) {
                device_printf(dev, "rejecting change, SMP not started yet\n");
                error = ENXIO;
                goto out;

Modified: stable/10/sys/kern/subr_smp.c
==============================================================================
--- stable/10/sys/kern/subr_smp.c       Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/kern/subr_smp.c       Wed May  7 20:28:27 2014        
(r265606)
@@ -59,6 +59,9 @@ cpuset_t logical_cpus_mask;
 
 void (*cpustop_restartfunc)(void);
 #endif
+
+static int sysctl_kern_smp_active(SYSCTL_HANDLER_ARGS);
+
 /* This is used in modules that need to work in both SMP and UP. */
 cpuset_t all_cpus;
 
@@ -78,9 +81,8 @@ SYSCTL_INT(_kern_smp, OID_AUTO, maxid, C
 SYSCTL_INT(_kern_smp, OID_AUTO, maxcpus, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_maxcpus,
     0, "Max number of CPUs that the system was compiled for.");
 
-int smp_active = 0;    /* are the APs allowed to run? */
-SYSCTL_INT(_kern_smp, OID_AUTO, active, CTLFLAG_RW, &smp_active, 0,
-    "Number of Auxillary Processors (APs) that were successfully started");
+SYSCTL_PROC(_kern_smp, OID_AUTO, active, CTLFLAG_RD | CTLTYPE_INT, NULL, 0,
+    sysctl_kern_smp_active, "I", "Indicates system is running in SMP mode");
 
 int smp_disabled = 0;  /* has smp been disabled? */
 SYSCTL_INT(_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD,
@@ -831,3 +833,15 @@ quiesce_all_cpus(const char *wmesg, int 
 
        return quiesce_cpus(all_cpus, wmesg, prio);
 }
+
+/* Extra care is taken with this sysctl because the data type is volatile */
+static int
+sysctl_kern_smp_active(SYSCTL_HANDLER_ARGS)
+{
+       int error, active;
+
+       active = smp_started;
+       error = SYSCTL_OUT(req, &active, sizeof(active));
+       return (error);
+}
+

Modified: stable/10/sys/mips/mips/mp_machdep.c
==============================================================================
--- stable/10/sys/mips/mips/mp_machdep.c        Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/mips/mips/mp_machdep.c        Wed May  7 20:28:27 2014        
(r265606)
@@ -317,7 +317,6 @@ smp_init_secondary(u_int32_t cpuid)
 
        if (smp_cpus == mp_ncpus) {
                atomic_store_rel_int(&smp_started, 1);
-               smp_active = 1;
        }
 
        mtx_unlock_spin(&ap_boot_mtx);

Modified: stable/10/sys/powerpc/powerpc/mp_machdep.c
==============================================================================
--- stable/10/sys/powerpc/powerpc/mp_machdep.c  Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/powerpc/powerpc/mp_machdep.c  Wed May  7 20:28:27 2014        
(r265606)
@@ -267,7 +267,7 @@ cpu_mp_unleash(void *dummy)
        /* Let the APs get into the scheduler */
        DELAY(10000);
 
-       smp_active = 1;
+       /* XXX Atomic set operation? */
        smp_started = 1;
 }
 

Modified: stable/10/sys/sparc64/sparc64/mp_machdep.c
==============================================================================
--- stable/10/sys/sparc64/sparc64/mp_machdep.c  Wed May  7 20:27:57 2014        
(r265605)
+++ stable/10/sys/sparc64/sparc64/mp_machdep.c  Wed May  7 20:28:27 2014        
(r265606)
@@ -291,7 +291,6 @@ cpu_mp_start(void)
        KASSERT(!isjbus || mp_ncpus <= IDR_JALAPENO_MAX_BN_PAIRS,
            ("%s: can only IPI a maximum of %d JBus-CPUs",
            __func__, IDR_JALAPENO_MAX_BN_PAIRS));
-       smp_active = 1;
 }
 
 static void

Modified: stable/10/sys/sys/smp.h
==============================================================================
--- stable/10/sys/sys/smp.h     Wed May  7 20:27:57 2014        (r265605)
+++ stable/10/sys/sys/smp.h     Wed May  7 20:28:27 2014        (r265606)
@@ -71,7 +71,6 @@ struct cpu_group *smp_topo_2level(int l2
 struct cpu_group *smp_topo_find(struct cpu_group *top, int cpu);
 
 extern void (*cpustop_restartfunc)(void);
-extern int smp_active;
 extern int smp_cpus;
 extern volatile cpuset_t started_cpus;
 extern volatile cpuset_t stopped_cpus;
@@ -141,7 +140,7 @@ cpu_next(int i)
  * cpu_mp_start() will be called so that MP can be enabled.  This function
  * should do things such as startup secondary processors.  It should also
  * setup mp_ncpus, all_cpus, and smp_cpus.  It should also ensure that
- * smp_active and smp_started are initialized at the appropriate time.
+ * smp_started is initialized at the appropriate time.
  * Once cpu_mp_start() returns, machine independent MP startup code will be
  * executed and a simple message will be output to the console.  Finally,
  * cpu_mp_announce() will be called so that machine dependent messages about
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to