svn commit: r221528 - stable/8/sys/kern

Fabien Thomas fabient at FreeBSD.org
Fri May 6 14:05:33 UTC 2011


Author: fabient
Date: Fri May  6 14:05:32 2011
New Revision: 221528
URL: http://svn.freebsd.org/changeset/base/221528

Log:
  MFC r220198:
  Clearing the flag when preempting will let the preempted thread run
  too much time. This can finish in a scheduler deadlock with ping-pong
  between two threads.
  
  One sample of this is:
   - device lapic (to have a preemption point on critical_exit())
   - options DEVICE_POLLING with HZ>1499 (to have lapic freq = hardclock freq)
   - running a cpu intensive task (that does not enter the kernel)
   - only one CPU on SMP or no SMP.
  
  As requested by jhb@ 4BSD have received the same type of fix instead of
  propagating the flag to the new thread.

Modified:
  stable/8/sys/kern/sched_4bsd.c
  stable/8/sys/kern/sched_ule.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/kern/sched_4bsd.c
==============================================================================
--- stable/8/sys/kern/sched_4bsd.c	Fri May  6 13:51:54 2011	(r221527)
+++ stable/8/sys/kern/sched_4bsd.c	Fri May  6 14:05:32 2011	(r221528)
@@ -944,13 +944,9 @@ sched_switch(struct thread *td, struct t
 	if ((td->td_flags & TDF_NOLOAD) == 0)
 		sched_load_rem();
 
-	if (newtd) {
-		MPASS(newtd->td_lock == &sched_lock);
-		newtd->td_flags |= (td->td_flags & TDF_NEEDRESCHED);
-	}
-
 	td->td_lastcpu = td->td_oncpu;
-	td->td_flags &= ~TDF_NEEDRESCHED;
+	if (!(flags & SW_PREEMPT))
+		td->td_flags &= ~TDF_NEEDRESCHED;
 	td->td_owepreempt = 0;
 	td->td_oncpu = NOCPU;
 

Modified: stable/8/sys/kern/sched_ule.c
==============================================================================
--- stable/8/sys/kern/sched_ule.c	Fri May  6 13:51:54 2011	(r221527)
+++ stable/8/sys/kern/sched_ule.c	Fri May  6 14:05:32 2011	(r221528)
@@ -1795,7 +1795,8 @@ sched_switch(struct thread *td, struct t
 	ts->ts_rltick = ticks;
 	td->td_lastcpu = td->td_oncpu;
 	td->td_oncpu = NOCPU;
-	td->td_flags &= ~TDF_NEEDRESCHED;
+	if (!(flags & SW_PREEMPT))
+		td->td_flags &= ~TDF_NEEDRESCHED;
 	td->td_owepreempt = 0;
 	tdq->tdq_switchcnt++;
 	/*


More information about the svn-src-all mailing list