PERFORCE change 131454 for review

John Birrell jb at FreeBSD.org
Sat Dec 22 20:32:18 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=131454

Change 131454 by jb at jb_freebsd1 on 2007/12/23 04:32:07

	Fix the test-and-set. The return type is inverted. Oops.
	
	Enable the mp_init() function so that it can be called via a 
	SYSINIT at the end of SI_SUB_SMP after the APs are launched. This
	case occurs if the cyclic module is loaded from the boot loader,
	in which case it initialises itself as early as possible to support
	tracing what happens on cpu0, in proc0 and thread0.

Affected files ...

.. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/os/cyclic.c#8 edit

Differences ...

==== //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/os/cyclic.c#8 (text) ====

@@ -610,7 +610,11 @@
 			break;
 
 		if (cyc_coverage[ndx].cyv_why != NULL ||
-		    casptr(&cyc_coverage[ndx].cyv_why, NULL, why) != 0) {
+#if defined(sun)
+		    casptr(&cyc_coverage[ndx].cyv_why, NULL, why) != NULL) {
+#else
+		    atomic_cmpset_ptr((volatile uintptr_t *) &cyc_coverage[ndx].cyv_why, (uintptr_t) NULL, (uintptr_t) why) == 0) {
+#endif
 
 			if (++ndx == CY_NCOVERAGE)
 				ndx = 0;
@@ -2866,7 +2870,11 @@
 	return (cyclic_resolution);
 }
 
+#if defined(sun)
 void
+#else
+static void
+#endif
 cyclic_init(cyc_backend_t *be, hrtime_t resolution)
 {
 	ASSERT(MUTEX_HELD(&cpu_lock));
@@ -2900,8 +2908,12 @@
  * find the already initialized CPU, and initialize every other CPU with the
  * same backend.  Finally, we register a cpu_setup function.
  */
+#if defined(sun)
 void
-cyclic_mp_init()
+#else
+static void
+#endif
+cyclic_mp_init(void)
 {
 	cpu_t *c;
 #if !defined(sun)
@@ -2926,13 +2938,11 @@
 		}
 #if defined(sun)
 	} while ((c = c->cpu_next) != cpu_list);
+
+	register_cpu_setup_func((cpu_setup_func_t *)cyclic_cpu_setup, NULL);
 #else
 	}
 #endif
-
-#if defined(sun)
-	register_cpu_setup_func((cpu_setup_func_t *)cyclic_cpu_setup, NULL);
-#endif
 	mutex_exit(&cpu_lock);
 }
 
@@ -2948,7 +2958,10 @@
 		if ((pc = pcpu_find(id)) == NULL)
 			continue;
 
-		c = &cyclic_cpu[pc->pc_cpuid];
+		c = &cyclic_cpu[id];
+
+		if (c->cpu_cyclic == NULL)
+			continue;
 
 		cyclic_offline(c);
 		cyclic_unconfigure(c);
@@ -3115,7 +3128,9 @@
 	cyc_id_t *idp;
 
 	CYC_PTRACE1("online", cpu);
+#if defined(sun)
 	ASSERT(c->cpu_flags & CPU_ENABLE);
+#endif
 	ASSERT(MUTEX_HELD(&cpu_lock));
 	ASSERT(cpu->cyp_state == CYS_OFFLINE);
 


More information about the p4-projects mailing list