Page MenuHomeFreeBSD

D35645.id108145.diff
No OneTemporary

D35645.id108145.diff

Index: sys/kern/sched_4bsd.c
===================================================================
--- sys/kern/sched_4bsd.c
+++ sys/kern/sched_4bsd.c
@@ -703,6 +703,10 @@
return (imax(1, (sched_slice * hz + realstathz / 2) / realstathz));
}
+SCHED_STAT_DEFINE(ithread_demotions, "Interrupt thread priority demotions");
+SCHED_STAT_DEFINE(ithread_preemptions,
+ "Interrupt thread preemptions due to time-sharing");
+
/*
* We adjust the priority of the current process. The priority of a
* process gets worse as it accumulates CPU time. The cpu usage
@@ -739,7 +743,20 @@
*/
if (!TD_IS_IDLETHREAD(td) && --ts->ts_slice <= 0) {
ts->ts_slice = sched_slice;
- td->td_flags |= TDF_NEEDRESCHED | TDF_SLICEEND;
+
+ /*
+ * If an ithread uses a full quantum, demote its
+ * priority and preempt it.
+ */
+ if (PRI_BASE(td->td_pri_class) == PRI_ITHD) {
+ SCHED_STAT_INC(ithread_preemptions);
+ td->td_owepreempt = 1;
+ if (td->td_base_pri + RQ_PPQ < PRI_MAX_ITHD) {
+ SCHED_STAT_INC(ithread_demotions);
+ sched_prio(td, td->td_base_pri + RQ_PPQ);
+ }
+ } else
+ td->td_flags |= TDF_NEEDRESCHED | TDF_SLICEEND;
}
stat = DPCPU_PTR(idlestat);
@@ -1134,6 +1151,15 @@
td->td_slptick = 0;
ts->ts_slptime = 0;
ts->ts_slice = sched_slice;
+
+ /*
+ * When resuming an idle ithread, restore its base ithread
+ * priority.
+ */
+ if (PRI_BASE(td->td_pri_class) == PRI_ITHD &&
+ td->td_base_pri != td->td_base_ithread_pri)
+ sched_prio(td, td->td_base_ithread_pri);
+
sched_add(td, srqflags);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 1, 3:10 PM (7 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27439077
Default Alt Text
D35645.id108145.diff (1 KB)

Event Timeline