diff options
Diffstat (limited to 'include/litmus')
-rw-r--r-- | include/litmus/fpmath.h | 21 | ||||
-rw-r--r-- | include/litmus/gpu_affinity.h | 16 | ||||
-rw-r--r-- | include/litmus/kexclu_affinity.h | 4 | ||||
-rw-r--r-- | include/litmus/litmus.h | 3 | ||||
-rw-r--r-- | include/litmus/nvidia_info.h | 2 | ||||
-rw-r--r-- | include/litmus/rt_param.h | 8 |
6 files changed, 39 insertions, 15 deletions
diff --git a/include/litmus/fpmath.h b/include/litmus/fpmath.h index 35f81683d6ab..d062b5ab5dc2 100644 --- a/include/litmus/fpmath.h +++ b/include/litmus/fpmath.h | |||
@@ -1,6 +1,11 @@ | |||
1 | #ifndef __FP_MATH_H__ | 1 | #ifndef __FP_MATH_H__ |
2 | #define __FP_MATH_H__ | 2 | #define __FP_MATH_H__ |
3 | 3 | ||
4 | #ifndef __KERNEL__ | ||
5 | #include <stdint.h> | ||
6 | #define abs(x) (((x) < 0) ? -(x) : x) | ||
7 | #endif | ||
8 | |||
4 | // Use 64-bit because we want to track things at the nanosecond scale. | 9 | // Use 64-bit because we want to track things at the nanosecond scale. |
5 | // This can lead to very large numbers. | 10 | // This can lead to very large numbers. |
6 | typedef int64_t fpbuf_t; | 11 | typedef int64_t fpbuf_t; |
@@ -11,7 +16,6 @@ typedef struct | |||
11 | 16 | ||
12 | #define FP_SHIFT 10 | 17 | #define FP_SHIFT 10 |
13 | #define ROUND_BIT (FP_SHIFT - 1) | 18 | #define ROUND_BIT (FP_SHIFT - 1) |
14 | #define ONE FP(1) | ||
15 | 19 | ||
16 | #define _fp(x) ((fp_t) {x}) | 20 | #define _fp(x) ((fp_t) {x}) |
17 | 21 | ||
@@ -29,8 +33,6 @@ static inline fp_t _frac(fpbuf_t a, fpbuf_t b) | |||
29 | return _fp(FP(a).val / (b)); | 33 | return _fp(FP(a).val / (b)); |
30 | } | 34 | } |
31 | 35 | ||
32 | #ifdef __KERNEL__ | ||
33 | |||
34 | static inline fpbuf_t _point(fp_t x) | 36 | static inline fpbuf_t _point(fp_t x) |
35 | { | 37 | { |
36 | return (x.val % (1 << FP_SHIFT)); | 38 | return (x.val % (1 << FP_SHIFT)); |
@@ -60,11 +62,19 @@ static inline fp_t _mul(fp_t a, fp_t b) | |||
60 | 62 | ||
61 | static inline fp_t _div(fp_t a, fp_t b) | 63 | static inline fp_t _div(fp_t a, fp_t b) |
62 | { | 64 | { |
63 | /* try not to overflow */ | 65 | #if !defined(__KERNEL__) && !defined(unlikely) |
64 | if (unlikely( a.val > (2l << (BITS_PER_LONG - FP_SHIFT)) )) | 66 | #define unlikely(x) (x) |
67 | #define DO_UNDEF_UNLIKELY | ||
68 | #endif | ||
69 | /* try not to overflow */ | ||
70 | if (unlikely( a.val > (2l << ((sizeof(fpbuf_t)*8) - FP_SHIFT)) )) | ||
65 | return _fp((a.val / b.val) << FP_SHIFT); | 71 | return _fp((a.val / b.val) << FP_SHIFT); |
66 | else | 72 | else |
67 | return _fp((a.val << FP_SHIFT) / b.val); | 73 | return _fp((a.val << FP_SHIFT) / b.val); |
74 | #ifdef DO_UNDEF_UNLIKELY | ||
75 | #undef unlikely | ||
76 | #undef DO_UNDEF_UNLIKELY | ||
77 | #endif | ||
68 | } | 78 | } |
69 | 79 | ||
70 | static inline fp_t _add(fp_t a, fp_t b) | 80 | static inline fp_t _add(fp_t a, fp_t b) |
@@ -131,4 +141,3 @@ static inline fp_t _max(fp_t a, fp_t b) | |||
131 | return a; | 141 | return a; |
132 | } | 142 | } |
133 | #endif | 143 | #endif |
134 | #endif | ||
diff --git a/include/litmus/gpu_affinity.h b/include/litmus/gpu_affinity.h index c29ff3de997c..ca4d10b93203 100644 --- a/include/litmus/gpu_affinity.h +++ b/include/litmus/gpu_affinity.h | |||
@@ -31,9 +31,21 @@ static inline lt_t get_gpu_time(struct task_struct* t) | |||
31 | 31 | ||
32 | static inline lt_t get_gpu_estimate(struct task_struct* t, gpu_migration_dist_t dist) | 32 | static inline lt_t get_gpu_estimate(struct task_struct* t, gpu_migration_dist_t dist) |
33 | { | 33 | { |
34 | lt_t val = _fp_to_integer(t->rt_param.gpu_migration_est[dist].est); | 34 | int i; |
35 | fpbuf_t temp = _fp_to_integer(t->rt_param.gpu_migration_est[dist].est); | ||
36 | lt_t val = (temp >= 0) ? temp : 0; // never allow negative estimates... | ||
35 | 37 | ||
36 | // minimum value is 1. | 38 | WARN_ON(temp < 0); |
39 | |||
40 | // lower-bound a distant migration to be at least equal to the level | ||
41 | // below it. | ||
42 | for(i = dist-1; (val == 0) && (i >= MIG_LOCAL); --i) { | ||
43 | val = _fp_to_integer(t->rt_param.gpu_migration_est[i].est); | ||
44 | } | ||
45 | |||
46 | // minimum value is 1 (val is 0 if we haven't run with local affinity yet) | ||
47 | // TODO: pick a better default min-value. 1 is too small. perhaps | ||
48 | // task execution time? | ||
37 | return ((val > 0) ? val : 1); | 49 | return ((val > 0) ? val : 1); |
38 | } | 50 | } |
39 | 51 | ||
diff --git a/include/litmus/kexclu_affinity.h b/include/litmus/kexclu_affinity.h index f5b5e7b1f359..51e097f8ec54 100644 --- a/include/litmus/kexclu_affinity.h +++ b/include/litmus/kexclu_affinity.h | |||
@@ -28,4 +28,8 @@ struct affinity_observer_ops | |||
28 | 28 | ||
29 | struct litmus_lock* get_lock_from_od(int od); | 29 | struct litmus_lock* get_lock_from_od(int od); |
30 | 30 | ||
31 | void affinity_observer_new(struct affinity_observer* aff, | ||
32 | struct affinity_observer_ops* ops, | ||
33 | struct affinity_observer_args* args); | ||
34 | |||
31 | #endif | 35 | #endif |
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index e2df49b171c5..71df378236f5 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h | |||
@@ -125,9 +125,6 @@ static inline lt_t litmus_clock(void) | |||
125 | #define earlier_release(a, b) (lt_before(\ | 125 | #define earlier_release(a, b) (lt_before(\ |
126 | (a)->rt_param.job_params.release,\ | 126 | (a)->rt_param.job_params.release,\ |
127 | (b)->rt_param.job_params.release)) | 127 | (b)->rt_param.job_params.release)) |
128 | #define shorter_period(a, b) (lt_before(\ | ||
129 | (a)->rt_param.task_params.period,\ | ||
130 | (b)->rt_param.task_params.period)) | ||
131 | void preempt_if_preemptable(struct task_struct* t, int on_cpu); | 128 | void preempt_if_preemptable(struct task_struct* t, int on_cpu); |
132 | 129 | ||
133 | #ifdef CONFIG_LITMUS_LOCKING | 130 | #ifdef CONFIG_LITMUS_LOCKING |
diff --git a/include/litmus/nvidia_info.h b/include/litmus/nvidia_info.h index dd41c4c72b85..856c575374d3 100644 --- a/include/litmus/nvidia_info.h +++ b/include/litmus/nvidia_info.h | |||
@@ -26,7 +26,7 @@ int init_nv_device_reg(void); | |||
26 | //int get_nv_device_id(struct task_struct* owner); | 26 | //int get_nv_device_id(struct task_struct* owner); |
27 | 27 | ||
28 | 28 | ||
29 | int reg_nv_device(int reg_device_id, int register_device); | 29 | int reg_nv_device(int reg_device_id, int register_device, struct task_struct *t); |
30 | 30 | ||
31 | struct task_struct* get_nv_max_device_owner(u32 target_device_id); | 31 | struct task_struct* get_nv_max_device_owner(u32 target_device_id); |
32 | //int is_nv_device_owner(u32 target_device_id); | 32 | //int is_nv_device_owner(u32 target_device_id); |
diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index ad46ab4c64cc..11f081527545 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h | |||
@@ -126,12 +126,14 @@ enum klitirqd_sem_status | |||
126 | 126 | ||
127 | typedef enum gpu_migration_dist | 127 | typedef enum gpu_migration_dist |
128 | { | 128 | { |
129 | // TODO: Make this variable against NR_NVIDIA_GPUS | ||
129 | MIG_LOCAL = 0, | 130 | MIG_LOCAL = 0, |
130 | MIG_NEAR = 1, | 131 | MIG_NEAR = 1, |
131 | MIG_MED = 2, | 132 | MIG_MED = 2, |
132 | MIG_FAR = 3, | 133 | MIG_FAR = 3, // 8 GPUs in a binary tree hierarchy |
134 | MIG_NONE = 4, | ||
133 | 135 | ||
134 | MIG_LAST = MIG_FAR | 136 | MIG_LAST = MIG_NONE |
135 | } gpu_migration_dist_t; | 137 | } gpu_migration_dist_t; |
136 | 138 | ||
137 | typedef struct feedback_est{ | 139 | typedef struct feedback_est{ |
@@ -190,7 +192,7 @@ struct rt_param { | |||
190 | 192 | ||
191 | gpu_migration_dist_t gpu_migration; | 193 | gpu_migration_dist_t gpu_migration; |
192 | int last_gpu; | 194 | int last_gpu; |
193 | feedback_est_t gpu_migration_est[MIG_LAST]; // local, near, med, far | 195 | feedback_est_t gpu_migration_est[MIG_LAST+1]; // local, near, med, far |
194 | 196 | ||
195 | lt_t accum_gpu_time; | 197 | lt_t accum_gpu_time; |
196 | lt_t gpu_time_stamp; | 198 | lt_t gpu_time_stamp; |