summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_4bsd.c
diff options
context:
space:
mode:
authorfabient <fabient@FreeBSD.org>2011-03-31 13:59:47 +0000
committerfabient <fabient@FreeBSD.org>2011-03-31 13:59:47 +0000
commite0588db8d22fa2514698e48727b291a5bca65dbf (patch)
treeff69eb812c81c5fd3f17576f198670edff277f82 /sys/kern/sched_4bsd.c
parent94327c73822769aa17f717f6edbf6e54159cc288 (diff)
downloadFreeBSD-src-e0588db8d22fa2514698e48727b291a5bca65dbf.zip
FreeBSD-src-e0588db8d22fa2514698e48727b291a5bca65dbf.tar.gz
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
Diffstat (limited to 'sys/kern/sched_4bsd.c')
-rw-r--r--sys/kern/sched_4bsd.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index f7025b0..c96d7b5 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -940,13 +940,9 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
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;
OpenPOWER on IntegriCloud