Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2011 13:59:48 +0000 (UTC)
From:      Fabien Thomas <fabient@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r220198 - head/sys/kern
Message-ID:  <201103311359.p2VDxmOI008483@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: fabient
Date: Thu Mar 31 13:59:47 2011
New Revision: 220198
URL: http://svn.freebsd.org/changeset/base/220198

Log:
  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.
  
  Reviewed by:	jhb, jeff
  MFC after:	1 month

Modified:
  head/sys/kern/sched_4bsd.c
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_4bsd.c
==============================================================================
--- head/sys/kern/sched_4bsd.c	Thu Mar 31 13:36:31 2011	(r220197)
+++ head/sys/kern/sched_4bsd.c	Thu Mar 31 13:59:47 2011	(r220198)
@@ -940,13 +940,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: head/sys/kern/sched_ule.c
==============================================================================
--- head/sys/kern/sched_ule.c	Thu Mar 31 13:36:31 2011	(r220197)
+++ head/sys/kern/sched_ule.c	Thu Mar 31 13:59:47 2011	(r220198)
@@ -1783,7 +1783,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++;
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103311359.p2VDxmOI008483>