svn commit: r247325 - projects/calloutng/sys/kern

Alexander Motin mav at FreeBSD.org
Tue Feb 26 17:49:08 UTC 2013


Author: mav
Date: Tue Feb 26 17:49:06 2013
New Revision: 247325
URL: http://svnweb.freebsd.org/changeset/base/247325

Log:
  Fix lock recursion during AP startup, triggered by attempt to reliably
  kick-start callout first time after AP startup, made at r247319.
  It was about hypotethical case when callout somehow scheduled on cold AP
  before SMP startup.
  
  Also rework r246205 SMP startup fix in different way.

Modified:
  projects/calloutng/sys/kern/kern_clocksource.c

Modified: projects/calloutng/sys/kern/kern_clocksource.c
==============================================================================
--- projects/calloutng/sys/kern/kern_clocksource.c	Tue Feb 26 17:33:18 2013	(r247324)
+++ projects/calloutng/sys/kern/kern_clocksource.c	Tue Feb 26 17:49:06 2013	(r247325)
@@ -236,10 +236,6 @@ handleevents(sbintime_t now, int fake)
 #endif
 
 	t = getnextcpuevent(0);
-	if (fake == 2) {
-		state->nextevent = t;
-		return (done);
-	}
 	ET_HW_LOCK(state);
 	if (!busy) {
 		state->idle = 0;
@@ -307,7 +303,7 @@ getnextevent(void)
 	event = state->nextevent;
 	c = curcpu;
 #ifdef SMP
-	if ((timer->et_flags & ET_FLAGS_PERCPU) == 0 && smp_started) {
+	if ((timer->et_flags & ET_FLAGS_PERCPU) == 0) {
 		CPU_FOREACH(cpu) {
 			state = DPCPU_ID_PTR(cpu, timerstate);
 			if (event > state->nextevent) {
@@ -517,7 +513,10 @@ configtimer(int start)
 		CPU_FOREACH(cpu) {
 			state = DPCPU_ID_PTR(cpu, timerstate);
 			state->now = now;
-			state->nextevent = next;
+			if (!smp_started && cpu != CPU_FIRST())
+				state->nextevent = INT64_MAX;
+			else
+				state->nextevent = next;
 			if (periodic)
 				state->nexttick = next;
 			else
@@ -689,16 +688,20 @@ cpu_initclocks_ap(void)
 {
 	sbintime_t now;
 	struct pcpu_state *state;
+	struct thread *td;
 
 	state = DPCPU_PTR(timerstate);
 	sbinuptime(&now);
 	ET_HW_LOCK(state);
 	state->now = now;
 	hardclock_sync(curcpu);
-	handleevents(state->now, 2);
-	if (timer->et_flags & ET_FLAGS_PERCPU)
-		loadtimer(now, 1);
+	spinlock_enter();
 	ET_HW_UNLOCK(state);
+	td = curthread;
+	td->td_intr_nesting_level++;
+	handleevents(state->now, 2);
+	td->td_intr_nesting_level--;
+	spinlock_exit();
 }
 
 /*


More information about the svn-src-projects mailing list