summaryrefslogtreecommitdiffstats
path: root/sys/kern/sched_ule.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/sched_ule.c')
-rw-r--r--sys/kern/sched_ule.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 726362d..719592a 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -189,6 +189,9 @@ static struct td_sched td_sched0;
#define SCHED_INTERACT_HALF (SCHED_INTERACT_MAX / 2)
#define SCHED_INTERACT_THRESH (30)
+/* Flags kept in td_flags. */
+#define TDF_SLICEEND TDF_SCHED2 /* Thread time slice is over. */
+
/*
* tickincr: Converts a stathz tick into a hz domain scaled by
* the shift factor. Without the shift the error rate
@@ -1841,7 +1844,7 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
struct td_sched *ts;
struct mtx *mtx;
int srqflag;
- int cpuid;
+ int cpuid, preempted;
THREAD_LOCK_ASSERT(td, MA_OWNED);
KASSERT(newtd == NULL, ("sched_switch: Unsupported newtd argument"));
@@ -1854,8 +1857,8 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
ts->ts_rltick = ticks;
td->td_lastcpu = td->td_oncpu;
td->td_oncpu = NOCPU;
- if (!(flags & SW_PREEMPT))
- td->td_flags &= ~TDF_NEEDRESCHED;
+ preempted = !(td->td_flags & TDF_SLICEEND);
+ td->td_flags &= ~(TDF_NEEDRESCHED | TDF_SLICEEND);
td->td_owepreempt = 0;
tdq->tdq_switchcnt++;
/*
@@ -1867,7 +1870,7 @@ sched_switch(struct thread *td, struct thread *newtd, int flags)
TD_SET_CAN_RUN(td);
} else if (TD_IS_RUNNING(td)) {
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
- srqflag = (flags & SW_PREEMPT) ?
+ srqflag = preempted ?
SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED :
SRQ_OURSELF|SRQ_YIELDING;
#ifdef SMP
@@ -2237,7 +2240,7 @@ sched_clock(struct thread *td)
* We're out of time, force a requeue at userret().
*/
ts->ts_slice = sched_slice;
- td->td_flags |= TDF_NEEDRESCHED;
+ td->td_flags |= TDF_NEEDRESCHED | TDF_SLICEEND;
}
/*
OpenPOWER on IntegriCloud