diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-10-08 20:24:20 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-10-08 20:24:20 -0400 |
| commit | 729c2d3b077bf90d1c4e32dcb047e25cf5d9f684 (patch) | |
| tree | 496c57a3b51e287cf29d7381aced70a43ddc5a90 /include/linux | |
| parent | 0b57fb8bf75f9ab8e8378238b71f3c983afc5fa5 (diff) | |
adaptive: debugging
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/fpmath.h | 16 | ||||
| -rw-r--r-- | include/linux/sched_adaptive.h | 15 |
2 files changed, 27 insertions, 4 deletions
diff --git a/include/linux/fpmath.h b/include/linux/fpmath.h index 7489bb8dec..9e97eb6991 100644 --- a/include/linux/fpmath.h +++ b/include/linux/fpmath.h | |||
| @@ -7,9 +7,19 @@ | |||
| 7 | 7 | ||
| 8 | #define _fp(x) ((fp_t) {x}) | 8 | #define _fp(x) ((fp_t) {x}) |
| 9 | 9 | ||
| 10 | static inline long _point(fp_t x) | ||
| 11 | { | ||
| 12 | return (x.val % (1 << FP_SHIFT)); | ||
| 13 | |||
| 14 | } | ||
| 15 | |||
| 16 | #define fp2str(x) (x.val / (1 << FP_SHIFT)), (x.val % (1 << FP_SHIFT)) | ||
| 17 | #define _FP_ "%d%+d/1024" | ||
| 18 | |||
| 19 | |||
| 10 | static inline fp_t FP(long x) | 20 | static inline fp_t FP(long x) |
| 11 | { | 21 | { |
| 12 | return _fp(((long long) x) << FP_SHIFT); | 22 | return _fp(((long) x) << FP_SHIFT); |
| 13 | } | 23 | } |
| 14 | 24 | ||
| 15 | static inline long _floor(fp_t x) | 25 | static inline long _floor(fp_t x) |
| @@ -84,5 +94,9 @@ static inline int _gt(fp_t a, fp_t b) | |||
| 84 | return a.val > b.val; | 94 | return a.val > b.val; |
| 85 | } | 95 | } |
| 86 | 96 | ||
| 97 | static inline int _eq(fp_t a, fp_t b) | ||
| 98 | { | ||
| 99 | return a.val == b.val; | ||
| 100 | } | ||
| 87 | 101 | ||
| 88 | #endif | 102 | #endif |
diff --git a/include/linux/sched_adaptive.h b/include/linux/sched_adaptive.h index 4e73568e1e..7f8d5da841 100644 --- a/include/linux/sched_adaptive.h +++ b/include/linux/sched_adaptive.h | |||
| @@ -25,6 +25,7 @@ static inline fp_t weight_transfer(fp_t from_val, fp_t to_val, | |||
| 25 | fp_t rel_from, rel_to; | 25 | fp_t rel_from, rel_to; |
| 26 | rel_from = _add(intercept, _mul(from_val, slope)); | 26 | rel_from = _add(intercept, _mul(from_val, slope)); |
| 27 | rel_to = _add(intercept, _mul(to_val, slope)); | 27 | rel_to = _add(intercept, _mul(to_val, slope)); |
| 28 | BUG_ON(_eq(rel_from, FP(0))); | ||
| 28 | return _div(_mul(act_weight, rel_to), rel_from); | 29 | return _div(_mul(act_weight, rel_to), rel_from); |
| 29 | } | 30 | } |
| 30 | 31 | ||
| @@ -74,6 +75,8 @@ static fp_t linear_metric(struct task_struct* t) | |||
| 74 | gmax = weight_transfer(vcur, vmax, | 75 | gmax = weight_transfer(vcur, vmax, |
| 75 | t->rt_param.wt_slope, t->rt_param.wt_y, | 76 | t->rt_param.wt_slope, t->rt_param.wt_y, |
| 76 | est_w); | 77 | est_w); |
| 78 | |||
| 79 | BUG_ON(_eq(_sub(gmax, g1), FP(0))); | ||
| 77 | return _div(_sub(vmax, v1), | 80 | return _div(_sub(vmax, v1), |
| 78 | _sub(gmax, g1)); | 81 | _sub(gmax, g1)); |
| 79 | } | 82 | } |
| @@ -95,9 +98,15 @@ static inline int is_under_allocated(struct task_struct* t) | |||
| 95 | 98 | ||
| 96 | static inline jiffie_t equal_point(struct task_struct* t) | 99 | static inline jiffie_t equal_point(struct task_struct* t) |
| 97 | { | 100 | { |
| 98 | return _round(_div( FP(t->rt_param.times.exec_time), | 101 | if (_lt(FP(0), get_est_weight(t))) |
| 99 | get_est_weight(t))) - | 102 | return _round(_div( FP(t->rt_param.times.exec_time), |
| 100 | (opt_time - get_last_release(t)); | 103 | get_est_weight(t))) - |
| 104 | (opt_time - get_last_release(t)); | ||
| 105 | else | ||
| 106 | /* if the weight is zero we just take the | ||
| 107 | * deadline | ||
| 108 | */ | ||
| 109 | return t->rt_param.times.deadline; | ||
| 101 | } | 110 | } |
| 102 | 111 | ||
| 103 | static jiffie_t decrease_enactment_time(struct task_struct* t) | 112 | static jiffie_t decrease_enactment_time(struct task_struct* t) |
