From 2e4b97e2e722699fe2ce2699714887eac0ff84cc Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Fri, 26 Oct 2007 11:27:02 -0400 Subject: adaptive: reweight if the total system capacity is exceeded. Track total utilization for the task set. --- kernel/sched_adaptive.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/sched_adaptive.c b/kernel/sched_adaptive.c index 1dd2b7763c..97d06b1ad4 100644 --- a/kernel/sched_adaptive.c +++ b/kernel/sched_adaptive.c @@ -216,7 +216,11 @@ static noinline void update_estimate(predictor_state_t *state, fp_t actual_weigh err = _sub(actual_weight, state->estimate); new = _add(_mul(a, err), _mul(b, state->accumulated)); + + total_weight = _sub(total_weight, state->estimate); state->estimate = new; + total_weight = _add(total_weight, state->estimate); + state->accumulated = _add(state->accumulated, err); OPT_DBG("ERROR " _FP_ ", NEW " _FP_ ", ACC" _FP_ "\n", fp2str(err), fp2str(new), fp2str(state->accumulated)); @@ -393,10 +397,11 @@ static void update_weight_estimate(struct task_struct* t) fp2str(FP(get_deadline(t) - get_last_release(t))), get_deadline(t), get_last_release(t), exec_time, sl_period); + total_weight = _sub(total_weight, get_est_weight(t)); t->rt_param.predictor_state.estimate = nw; OPT_DBG_T(t, "update_weight_estimate from " _FP_ " to "_FP_"\n", fp2str(ow), fp2str(nw)); - + total_weight = _add(total_weight, get_est_weight(t)); OPT_DBG_T(t, " update_weight_estimate: " _FP_ " => " _FP_ "\n", fp2str(ow), fp2str(get_est_weight(t))); @@ -528,8 +533,7 @@ void adaptive_optimize(void) struct list_head *p, *extra; cpu_entry_t *cpu; struct task_struct* t; - fp_t M = FP(0), w0, wl, tmp, estU = FP(0), _M; - int i; + fp_t M = FP(0), w0, wl, tmp, estU = FP(0); unsigned int l; jiffie_t enactment_time; @@ -555,7 +559,6 @@ void adaptive_optimize(void) /* 2) determine current system capacity */ M = system_capacity; - _M = M; OPT_DBG("opt: system capacity: " _FP_ "\n", fp2str(M)); /* 3) Compute L value for all tasks, @@ -639,7 +642,7 @@ void adaptive_optimize(void) /* Very ugly jump, but we need to force enactment_time = 0 * during the first iteration. */ - M = _M; + M = system_capacity; enactment_time = 0; goto first_iteration; @@ -932,8 +935,10 @@ static noinline void adaptive_release_jobs(void) queued->rt_param.times.deadline = get_last_release(queued) + get_rt_period(queued); + total_weight = _sub(total_weight, get_est_weight(queued)); queued->rt_param.predictor_state.estimate = queued->rt_param.opt_nw; + total_weight = _add(total_weight, get_est_weight(queued)); } sched_trace_job_release(queued); @@ -1065,6 +1070,9 @@ static noinline void job_completion(struct task_struct *t) if (exceeds_threshold) { OPT_DBG("adaptive: optimizing due to task error threshold\n"); adaptive_optimize(); + } else if (_gt(total_weight, system_capacity)) { + OPT_DBG("adaptive: optimizing due to system capacity exceeded\n"); + adaptive_optimize(); } @@ -1238,6 +1246,7 @@ static long adaptive_prepare_task(struct task_struct * t) t->state = TASK_RUNNING; queue_lock_irqsave(&adaptive_lock, flags); + total_weight = _add(total_weight, get_est_weight(t)); requeue(t); queue_unlock_irqrestore(&adaptive_lock, flags); return 0; @@ -1272,6 +1281,7 @@ static void adaptive_wake_up_task(struct task_struct *task) set_rt_flags(task, RT_F_RUNNING); queue_lock_irqsave(&adaptive_lock, flags); + total_weight = _add(total_weight, get_est_weight(task)); adaptive_job_arrival(task); queue_unlock_irqrestore(&adaptive_lock, flags); } @@ -1282,6 +1292,7 @@ static void adaptive_task_blocks(struct task_struct *t) /* unlink if necessary */ queue_lock_irqsave(&adaptive_lock, flags); + total_weight = _sub(total_weight, get_est_weight(t)); unlink(t); queue_unlock_irqrestore(&adaptive_lock, flags); -- cgit v1.2.2