summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2007-01-25 23:51:59 +0000
committerjeff <jeff@FreeBSD.org>2007-01-25 23:51:59 +0000
commit0f05ca9b5b593c42440fc5ee93fadb5f64ef9dc7 (patch)
tree7844e7701d94f004195bed597681f78bbebcb90f
parentdcb92392a2fb78cb4be4b29cb05b52def7f508a0 (diff)
downloadFreeBSD-src-0f05ca9b5b593c42440fc5ee93fadb5f64ef9dc7.zip
FreeBSD-src-0f05ca9b5b593c42440fc5ee93fadb5f64ef9dc7.tar.gz
- Implement much more intelligent ipi sending. This algorithm tries to
minimize IPIs and rescheduling when scheduling like tasks while keeping latency low for important threads. 1) An idle thread is running. 2) The current thread is worse than realtime and the new thread is better than realtime. Realtime to realtime doesn't preempt. 3) The new thread's priority is less than the threshold.
-rw-r--r--sys/kern/sched_ule.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 68a4522..5ddd415 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -700,31 +700,43 @@ steal:
static void
tdq_notify(struct td_sched *ts)
{
- struct thread *td;
+ struct thread *ctd;
struct pcpu *pcpu;
- int prio;
+ int cpri;
+ int pri;
int cpu;
- prio = ts->ts_thread->td_priority;
cpu = ts->ts_cpu;
+ pri = ts->ts_thread->td_priority;
pcpu = pcpu_find(cpu);
- td = pcpu->pc_curthread;
+ ctd = pcpu->pc_curthread;
+ cpri = ctd->td_priority;
/*
* If our priority is not better than the current priority there is
* nothing to do.
*/
- if (prio > td->td_priority)
+ if (pri > cpri)
return;
- /* Always set NEEDRESCHED. */
- td->td_flags |= TDF_NEEDRESCHED;
/*
- * IPI if we exceed the threshold or if the target cpu is running an
- * idle thread.
+ * Always IPI idle.
+ */
+ if (cpri > PRI_MIN_IDLE)
+ goto sendipi;
+ /*
+ * If we're realtime or better and there is timeshare or worse running
+ * send an IPI.
+ */
+ if (pri < PRI_MAX_REALTIME && cpri > PRI_MAX_REALTIME)
+ goto sendipi;
+ /*
+ * Otherwise only IPI if we exceed the threshold.
*/
- if (prio > ipi_thresh && td->td_priority < PRI_MIN_IDLE)
+ if (pri > ipi_thresh)
return;
- if (td->td_priority < PRI_MIN_IDLE) {
+sendipi:
+ ctd->td_flags |= TDF_NEEDRESCHED;
+ if (cpri < PRI_MIN_IDLE) {
if (ipi_ast)
ipi_selected(1 << cpu, IPI_AST);
else if (ipi_preempt)
OpenPOWER on IntegriCloud