diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-10-17 18:07:16 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-10-17 18:07:16 -0400 |
commit | d59fb6371fd1234760b0bd89e10846d500f5d13c (patch) | |
tree | b25b8b8429e07d8187a39d3c8d653c85e83fbe7c /include/linux/sched_adaptive.h | |
parent | dfac87bb28e96c7de2771451ffaf2738911db324 (diff) |
adaptive: Aaron's fixes, clean out debug, and merge header
This patch is a collection of several changes. It includes Aaron's fixes
to prevent division by zero, makes it possible to disable the optimizer
debug output, and merges the header file into the scheduler implementation
since it is not being used anywhere else.
Diffstat (limited to 'include/linux/sched_adaptive.h')
-rw-r--r-- | include/linux/sched_adaptive.h | 161 |
1 files changed, 0 insertions, 161 deletions
diff --git a/include/linux/sched_adaptive.h b/include/linux/sched_adaptive.h deleted file mode 100644 index 81b803ad31..0000000000 --- a/include/linux/sched_adaptive.h +++ /dev/null | |||
@@ -1,161 +0,0 @@ | |||
1 | #ifndef __ADAPTIVE_H__ | ||
2 | #define __ADAPTIVE_H__ | ||
3 | |||
4 | /* All time dependent functions | ||
5 | * rely on this field. | ||
6 | * Update in the optimizer before use! | ||
7 | */ | ||
8 | extern jiffie_t opt_time; | ||
9 | |||
10 | |||
11 | static inline fp_t ideal(fp_t weight, jiffie_t delta_t) | ||
12 | { | ||
13 | return _mul(weight, FP(delta_t)); | ||
14 | } | ||
15 | |||
16 | static noinline long ideal_exec_time(struct task_struct* t) | ||
17 | { | ||
18 | jiffie_t delta = opt_time - get_last_release(t); | ||
19 | return _round(ideal(get_est_weight(t), delta)); | ||
20 | } | ||
21 | |||
22 | /* this makes a whole bunch of linearity assumptions */ | ||
23 | static noinline fp_t weight_transfer(struct task_struct* t, | ||
24 | unsigned int from, unsigned int to, | ||
25 | fp_t act_weight) | ||
26 | { | ||
27 | fp_t rel_from, rel_to, ret; | ||
28 | rel_from = get_sl(t, from).weight; | ||
29 | rel_to = get_sl(t, to).weight; | ||
30 | ret.val = (act_weight.val * rel_to.val) / rel_from.val; | ||
31 | /*_div(_mul(act_weight, rel_to), rel_from);*/ | ||
32 | TRACE("weight_transfer(%ld, %ld, %ld) => %ld to=%u from=%u\n", | ||
33 | rel_from.val, rel_to.val, act_weight.val, ret.val, from, to); | ||
34 | return ret; | ||
35 | } | ||
36 | |||
37 | static noinline fp_t est_weight_at(struct task_struct* t, unsigned int level) | ||
38 | { | ||
39 | if (t->rt_param.no_service_levels) | ||
40 | return weight_transfer(t, get_cur_sl(t), level, | ||
41 | get_est_weight(t)); | ||
42 | else | ||
43 | return get_est_weight(t); | ||
44 | |||
45 | } | ||
46 | |||
47 | static noinline void update_estimate(predictor_state_t *state, fp_t actual_weight, | ||
48 | fp_t a, fp_t b) | ||
49 | { | ||
50 | fp_t err, new; | ||
51 | |||
52 | TRACE("OLD ESTIMATE Weight" _FP_ " ActWt " _FP_ " A:" _FP_ ", B:" _FP_ | ||
53 | "\n", fp2str(state->estimate), fp2str(actual_weight), fp2str(a), | ||
54 | fp2str(b)); | ||
55 | |||
56 | err = _sub(actual_weight, state->estimate); | ||
57 | new = _add(_mul(a, err), | ||
58 | _mul(b, state->accumulated)); | ||
59 | state->estimate = new; | ||
60 | state->accumulated = _add(state->accumulated, err); | ||
61 | TRACE("ERROR " _FP_ ", NEW " _FP_ ", ACC" _FP_ "\n", fp2str(err), | ||
62 | fp2str(new), fp2str(state->accumulated)); | ||
63 | } | ||
64 | |||
65 | static noinline fp_t linear_metric(struct task_struct* t) | ||
66 | { | ||
67 | fp_t v1, vmax, g1, gmax; | ||
68 | fp_t est_w; | ||
69 | unsigned int l = t->rt_param.no_service_levels; | ||
70 | unsigned int lcur; | ||
71 | |||
72 | if (l <= 1) | ||
73 | return FP(0); | ||
74 | |||
75 | lcur = get_cur_sl(t);; | ||
76 | est_w = get_est_weight(t); | ||
77 | |||
78 | TRACE_TASK(t, " linear_metric: lcur=%u l=%u est_w=" _FP_ "\n", | ||
79 | lcur, l, est_w); | ||
80 | /* TRACE_TASK(t, " linear_metric: est_w.val=%ld\n", est_w.val); */ | ||
81 | |||
82 | |||
83 | v1 = t->rt_param.service_level[0].value; | ||
84 | vmax = t->rt_param.service_level[l - 1].value; | ||
85 | |||
86 | TRACE_TASK(t, " linear_metric: v1=" _FP_ " vmax=" _FP_ "\n", v1, vmax); | ||
87 | /* TRACE_TASK(t, " linear_metric: v1=%ld vmax=%ld\n", v1.val, vmax.val);*/ | ||
88 | |||
89 | |||
90 | g1 = weight_transfer(t, lcur, 0, est_w); | ||
91 | gmax = weight_transfer(t, lcur, l - 1, est_w); | ||
92 | |||
93 | TRACE_TASK(t, " linear_metric: g1=" _FP_ " gmax=" _FP_ "\n", g1, gmax); | ||
94 | /* TRACE_TASK(t, " linear_metric: g1=%ld gmax=%ld\n", g1, gmax); */ | ||
95 | |||
96 | |||
97 | TRACE_BUG_ON(_eq(_sub(gmax, g1), FP(0))); | ||
98 | if (_eq(_sub(gmax, g1), FP(0))) | ||
99 | return FP(0); | ||
100 | return _div(_sub(vmax, v1), | ||
101 | _sub(gmax, g1)); | ||
102 | } | ||
103 | |||
104 | static noinline unsigned long reweighted_period(fp_t ow, fp_t nw, unsigned long alloc, | ||
105 | jiffie_t deadline, jiffie_t release) | ||
106 | { | ||
107 | fp_t dl; | ||
108 | dl = _mul(FP(deadline - release), ow); | ||
109 | dl = _sub(dl, FP(alloc)); | ||
110 | dl = _div(dl, nw); | ||
111 | return _round(dl); | ||
112 | } | ||
113 | |||
114 | static noinline int is_under_allocated(struct task_struct* t) | ||
115 | { | ||
116 | return ideal_exec_time(t) >= t->rt_param.times.exec_time; | ||
117 | } | ||
118 | |||
119 | static noinline jiffie_t dec_equal_point_delay(struct task_struct* t) | ||
120 | { | ||
121 | if (_lt(FP(0), get_est_weight(t))) | ||
122 | /* when t was released plus time needed to equalize | ||
123 | * minus now | ||
124 | */ | ||
125 | return get_last_release(t) + | ||
126 | _round(_div( FP(t->rt_param.times.exec_time), | ||
127 | get_est_weight(t))) - | ||
128 | opt_time; | ||
129 | else | ||
130 | /* if the weight is zero we just take the | ||
131 | * deadline | ||
132 | */ | ||
133 | return t->rt_param.times.deadline; | ||
134 | } | ||
135 | |||
136 | static noinline jiffie_t inc_equal_point_delay(struct task_struct* t) | ||
137 | { | ||
138 | if (_lt(FP(0), t->rt_param.opt_nw)) | ||
139 | /* when t was released plus time needed to equalize | ||
140 | * minus now | ||
141 | */ | ||
142 | return get_last_release(t) + | ||
143 | _round(_div( FP(t->rt_param.times.exec_time), | ||
144 | t->rt_param.opt_nw)) - | ||
145 | opt_time; | ||
146 | else | ||
147 | /* if the weight is zero we just take the | ||
148 | * deadline | ||
149 | */ | ||
150 | return t->rt_param.times.deadline; | ||
151 | } | ||
152 | |||
153 | static noinline jiffie_t decrease_delay(struct task_struct* t) | ||
154 | { | ||
155 | if (has_active_job(t) && !is_under_allocated(t)) | ||
156 | return dec_equal_point_delay(t); | ||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | |||
161 | #endif | ||