diff options
| -rw-r--r-- | include/asm_x86.h | 22 | ||||
| -rw-r--r-- | pm_test/pm_task.c | 24 |
2 files changed, 30 insertions, 16 deletions
diff --git a/include/asm_x86.h b/include/asm_x86.h index b5bf166..6636abb 100644 --- a/include/asm_x86.h +++ b/include/asm_x86.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Intel ia32 assembly. | 1 | /* Intel ia32 assembly. |
| 2 | * Don't include directly, use asm.h instead. | 2 | * Don't include directly, use asm.h instead. |
| 3 | * | 3 | * |
| 4 | * Most of this code comes straight out of the Linux kernel. | 4 | * Most of this code comes straight out of the Linux kernel. |
| @@ -16,6 +16,16 @@ static __inline__ void cpu_relax(void) | |||
| 16 | __asm__ __volatile("pause"); | 16 | __asm__ __volatile("pause"); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | /* please, use these only if you _really_ know what you're doing | ||
| 20 | * ... and remember iopl(3) first!! (include sys/io.h) | ||
| 21 | */ | ||
| 22 | static inline void cli(void) { | ||
| 23 | asm volatile("cli": : :"memory"); | ||
| 24 | } | ||
| 25 | |||
| 26 | static inline void sti(void) { | ||
| 27 | asm volatile("sti": : :"memory"); | ||
| 28 | } | ||
| 19 | 29 | ||
| 20 | #ifdef __i386__ | 30 | #ifdef __i386__ |
| 21 | 31 | ||
| @@ -26,18 +36,18 @@ typedef struct { int counter; } atomic_t; | |||
| 26 | /** | 36 | /** |
| 27 | * atomic_read - read atomic variable | 37 | * atomic_read - read atomic variable |
| 28 | * @v: pointer of type atomic_t | 38 | * @v: pointer of type atomic_t |
| 29 | * | 39 | * |
| 30 | * Atomically reads the value of @v. | 40 | * Atomically reads the value of @v. |
| 31 | */ | 41 | */ |
| 32 | #define atomic_read(v) ((v)->counter) | 42 | #define atomic_read(v) ((v)->counter) |
| 33 | 43 | ||
| 34 | /** | 44 | /** |
| 35 | * atomic_set - set atomic variable | 45 | * atomic_set - set atomic variable |
| 36 | * @v: pointer of type atomic_t | 46 | * @v: pointer of type atomic_t |
| 37 | * @i: required value | 47 | * @i: required value |
| 38 | * | 48 | * |
| 39 | * Atomically sets the value of @v to @i. | 49 | * Atomically sets the value of @v to @i. |
| 40 | */ | 50 | */ |
| 41 | #define atomic_set(v,i) (((v)->counter) = (i)) | 51 | #define atomic_set(v,i) (((v)->counter) = (i)) |
| 42 | 52 | ||
| 43 | static __inline__ void atomic_add(int i, atomic_t *v) | 53 | static __inline__ void atomic_add(int i, atomic_t *v) |
| @@ -65,7 +75,7 @@ static __inline__ int atomic_add_return(int i, atomic_t *v) | |||
| 65 | : : "memory"); | 75 | : : "memory"); |
| 66 | return i + __i; | 76 | return i + __i; |
| 67 | } | 77 | } |
| 68 | 78 | ||
| 69 | #define atomic_inc_return(v) (atomic_add_return(1,v)) | 79 | #define atomic_inc_return(v) (atomic_add_return(1,v)) |
| 70 | 80 | ||
| 71 | 81 | ||
diff --git a/pm_test/pm_task.c b/pm_test/pm_task.c index b1158b0..71d5690 100644 --- a/pm_test/pm_task.c +++ b/pm_test/pm_task.c | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | /* architectural dependend code for pm measurement */ | 21 | /* architectural dependend code for pm measurement */ |
| 22 | #include "pm_arch.h" | 22 | #include "pm_arch.h" |
| 23 | 23 | ||
| 24 | #include <sys/io.h> | ||
| 25 | |||
| 24 | int mem_block[NUMWS][INTS_PER_WSS] __attribute__ ((aligned(CACHEALIGNMENT))); | 26 | int mem_block[NUMWS][INTS_PER_WSS] __attribute__ ((aligned(CACHEALIGNMENT))); |
| 25 | 27 | ||
| 26 | /* Setup flags, then enter loop to measure costs. */ | 28 | /* Setup flags, then enter loop to measure costs. */ |
| @@ -105,6 +107,7 @@ int main(int argc, char **argv) | |||
| 105 | saved_ctrl_page_ptr = ctrl; | 107 | saved_ctrl_page_ptr = ctrl; |
| 106 | #endif | 108 | #endif |
| 107 | 109 | ||
| 110 | iopl(3); | ||
| 108 | /* Enter loop that measures preemption and migration costs. */ | 111 | /* Enter loop that measures preemption and migration costs. */ |
| 109 | while (curr_job_count * task_period < SIMRUNTIME) { | 112 | while (curr_job_count * task_period < SIMRUNTIME) { |
| 110 | #ifdef DEBUG | 113 | #ifdef DEBUG |
| @@ -117,6 +120,9 @@ int main(int argc, char **argv) | |||
| 117 | #endif | 120 | #endif |
| 118 | if (curr_job_count != ctrl->job_count) { | 121 | if (curr_job_count != ctrl->job_count) { |
| 119 | 122 | ||
| 123 | /* G-EDF with np sections while reading our samples */ | ||
| 124 | cli(); | ||
| 125 | |||
| 120 | /* ok, this is a new job. Get info from kernel */ | 126 | /* ok, this is a new job. Get info from kernel */ |
| 121 | 127 | ||
| 122 | curr_job_count = ctrl->job_count; | 128 | curr_job_count = ctrl->job_count; |
| @@ -126,9 +132,6 @@ int main(int argc, char **argv) | |||
| 126 | 132 | ||
| 127 | barrier(); | 133 | barrier(); |
| 128 | 134 | ||
| 129 | /* G-EDF with np sections while reading our samples */ | ||
| 130 | enter_np(); | ||
| 131 | |||
| 132 | /* job's portion of the mem_block */ | 135 | /* job's portion of the mem_block */ |
| 133 | curr_ws = curr_job_count % NUMWS; | 136 | curr_ws = curr_job_count % NUMWS; |
| 134 | 137 | ||
| @@ -213,11 +216,17 @@ int main(int argc, char **argv) | |||
| 213 | * FIXME this is a very long np section, we may think | 216 | * FIXME this is a very long np section, we may think |
| 214 | * about splitting it in two: C + H,H | 217 | * about splitting it in two: C + H,H |
| 215 | */ | 218 | */ |
| 216 | exit_np(); | 219 | sti(); |
| 217 | 220 | ||
| 218 | } else if (mem_ptr && mem_ptr_end && | 221 | } else if (mem_ptr && mem_ptr_end && |
| 219 | (curr_sched_count != ctrl->sched_count || | 222 | (curr_sched_count != ctrl->sched_count || |
| 220 | curr_cpu != ctrl->cpu)) { | 223 | curr_cpu != ctrl->cpu)) { |
| 224 | |||
| 225 | /* we are after a preemption / migration: | ||
| 226 | * enter NP before reading | ||
| 227 | */ | ||
| 228 | cli(); | ||
| 229 | |||
| 221 | /* we have done at least one go in the "best case". | 230 | /* we have done at least one go in the "best case". |
| 222 | * job is the same => preempted / migrated | 231 | * job is the same => preempted / migrated |
| 223 | */ | 232 | */ |
| @@ -230,11 +239,6 @@ int main(int argc, char **argv) | |||
| 230 | 239 | ||
| 231 | barrier(); | 240 | barrier(); |
| 232 | 241 | ||
| 233 | /* we are after a preemption / migration: | ||
| 234 | * enter NP before reading | ||
| 235 | */ | ||
| 236 | enter_np(); | ||
| 237 | |||
| 238 | /* Measure preemption or migration cost. */ | 242 | /* Measure preemption or migration cost. */ |
| 239 | mem_ptr = &mem_block[curr_ws][0]; | 243 | mem_ptr = &mem_block[curr_ws][0]; |
| 240 | 244 | ||
| @@ -256,7 +260,7 @@ int main(int argc, char **argv) | |||
| 256 | data_points[data_count].access_type = 'P'; | 260 | data_points[data_count].access_type = 'P'; |
| 257 | 261 | ||
| 258 | /* exit NP now */ | 262 | /* exit NP now */ |
| 259 | exit_np(); | 263 | sti(); |
| 260 | 264 | ||
| 261 | data_points[data_count].access_time = | 265 | data_points[data_count].access_time = |
| 262 | end_time - start_time; | 266 | end_time - start_time; |
