aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2007-10-26 11:27:02 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2007-10-26 11:27:02 -0400
commit2e4b97e2e722699fe2ce2699714887eac0ff84cc (patch)
tree4c386b2d1dd6fa9816c4c81136c2ef43cdd59a21
parent33fad37e4f1b023ddfea00c066b529dc670de684 (diff)
adaptive: reweight if the total system capacity is exceeded.RTAS08
Track total utilization for the task set.
-rw-r--r--kernel/sched_adaptive.c21
1 files 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
216 err = _sub(actual_weight, state->estimate); 216 err = _sub(actual_weight, state->estimate);
217 new = _add(_mul(a, err), 217 new = _add(_mul(a, err),
218 _mul(b, state->accumulated)); 218 _mul(b, state->accumulated));
219
220 total_weight = _sub(total_weight, state->estimate);
219 state->estimate = new; 221 state->estimate = new;
222 total_weight = _add(total_weight, state->estimate);
223
220 state->accumulated = _add(state->accumulated, err); 224 state->accumulated = _add(state->accumulated, err);
221 OPT_DBG("ERROR " _FP_ ", NEW " _FP_ ", ACC" _FP_ "\n", fp2str(err), 225 OPT_DBG("ERROR " _FP_ ", NEW " _FP_ ", ACC" _FP_ "\n", fp2str(err),
222 fp2str(new), fp2str(state->accumulated)); 226 fp2str(new), fp2str(state->accumulated));
@@ -393,10 +397,11 @@ static void update_weight_estimate(struct task_struct* t)
393 fp2str(FP(get_deadline(t) - get_last_release(t))), 397 fp2str(FP(get_deadline(t) - get_last_release(t))),
394 get_deadline(t), get_last_release(t), exec_time, sl_period); 398 get_deadline(t), get_last_release(t), exec_time, sl_period);
395 399
400 total_weight = _sub(total_weight, get_est_weight(t));
396 t->rt_param.predictor_state.estimate = nw; 401 t->rt_param.predictor_state.estimate = nw;
397 OPT_DBG_T(t, "update_weight_estimate from " _FP_ " to "_FP_"\n", 402 OPT_DBG_T(t, "update_weight_estimate from " _FP_ " to "_FP_"\n",
398 fp2str(ow), fp2str(nw)); 403 fp2str(ow), fp2str(nw));
399 404 total_weight = _add(total_weight, get_est_weight(t));
400 405
401 OPT_DBG_T(t, " update_weight_estimate: " _FP_ " => " _FP_ "\n", 406 OPT_DBG_T(t, " update_weight_estimate: " _FP_ " => " _FP_ "\n",
402 fp2str(ow), fp2str(get_est_weight(t))); 407 fp2str(ow), fp2str(get_est_weight(t)));
@@ -528,8 +533,7 @@ void adaptive_optimize(void)
528 struct list_head *p, *extra; 533 struct list_head *p, *extra;
529 cpu_entry_t *cpu; 534 cpu_entry_t *cpu;
530 struct task_struct* t; 535 struct task_struct* t;
531 fp_t M = FP(0), w0, wl, tmp, estU = FP(0), _M; 536 fp_t M = FP(0), w0, wl, tmp, estU = FP(0);
532 int i;
533 unsigned int l; 537 unsigned int l;
534 jiffie_t enactment_time; 538 jiffie_t enactment_time;
535 539
@@ -555,7 +559,6 @@ void adaptive_optimize(void)
555 559
556 /* 2) determine current system capacity */ 560 /* 2) determine current system capacity */
557 M = system_capacity; 561 M = system_capacity;
558 _M = M;
559 OPT_DBG("opt: system capacity: " _FP_ "\n", fp2str(M)); 562 OPT_DBG("opt: system capacity: " _FP_ "\n", fp2str(M));
560 563
561 /* 3) Compute L value for all tasks, 564 /* 3) Compute L value for all tasks,
@@ -639,7 +642,7 @@ void adaptive_optimize(void)
639 /* Very ugly jump, but we need to force enactment_time = 0 642 /* Very ugly jump, but we need to force enactment_time = 0
640 * during the first iteration. 643 * during the first iteration.
641 */ 644 */
642 M = _M; 645 M = system_capacity;
643 enactment_time = 0; 646 enactment_time = 0;
644 goto first_iteration; 647 goto first_iteration;
645 648
@@ -932,8 +935,10 @@ static noinline void adaptive_release_jobs(void)
932 queued->rt_param.times.deadline = 935 queued->rt_param.times.deadline =
933 get_last_release(queued) + 936 get_last_release(queued) +
934 get_rt_period(queued); 937 get_rt_period(queued);
938 total_weight = _sub(total_weight, get_est_weight(queued));
935 queued->rt_param.predictor_state.estimate = 939 queued->rt_param.predictor_state.estimate =
936 queued->rt_param.opt_nw; 940 queued->rt_param.opt_nw;
941 total_weight = _add(total_weight, get_est_weight(queued));
937 } 942 }
938 943
939 sched_trace_job_release(queued); 944 sched_trace_job_release(queued);
@@ -1065,6 +1070,9 @@ static noinline void job_completion(struct task_struct *t)
1065 if (exceeds_threshold) { 1070 if (exceeds_threshold) {
1066 OPT_DBG("adaptive: optimizing due to task error threshold\n"); 1071 OPT_DBG("adaptive: optimizing due to task error threshold\n");
1067 adaptive_optimize(); 1072 adaptive_optimize();
1073 } else if (_gt(total_weight, system_capacity)) {
1074 OPT_DBG("adaptive: optimizing due to system capacity exceeded\n");
1075 adaptive_optimize();
1068 } 1076 }
1069 1077
1070 1078
@@ -1238,6 +1246,7 @@ static long adaptive_prepare_task(struct task_struct * t)
1238 t->state = TASK_RUNNING; 1246 t->state = TASK_RUNNING;
1239 1247
1240 queue_lock_irqsave(&adaptive_lock, flags); 1248 queue_lock_irqsave(&adaptive_lock, flags);
1249 total_weight = _add(total_weight, get_est_weight(t));
1241 requeue(t); 1250 requeue(t);
1242 queue_unlock_irqrestore(&adaptive_lock, flags); 1251 queue_unlock_irqrestore(&adaptive_lock, flags);
1243 return 0; 1252 return 0;
@@ -1272,6 +1281,7 @@ static void adaptive_wake_up_task(struct task_struct *task)
1272 set_rt_flags(task, RT_F_RUNNING); 1281 set_rt_flags(task, RT_F_RUNNING);
1273 1282
1274 queue_lock_irqsave(&adaptive_lock, flags); 1283 queue_lock_irqsave(&adaptive_lock, flags);
1284 total_weight = _add(total_weight, get_est_weight(task));
1275 adaptive_job_arrival(task); 1285 adaptive_job_arrival(task);
1276 queue_unlock_irqrestore(&adaptive_lock, flags); 1286 queue_unlock_irqrestore(&adaptive_lock, flags);
1277} 1287}
@@ -1282,6 +1292,7 @@ static void adaptive_task_blocks(struct task_struct *t)
1282 1292
1283 /* unlink if necessary */ 1293 /* unlink if necessary */
1284 queue_lock_irqsave(&adaptive_lock, flags); 1294 queue_lock_irqsave(&adaptive_lock, flags);
1295 total_weight = _sub(total_weight, get_est_weight(t));
1285 unlink(t); 1296 unlink(t);
1286 queue_unlock_irqrestore(&adaptive_lock, flags); 1297 queue_unlock_irqrestore(&adaptive_lock, flags);
1287 1298