diff options
author | Christopher Kenna <cjk@cs.unc.edu> | 2012-10-18 19:24:26 -0400 |
---|---|---|
committer | Christopher Kenna <cjk@cs.unc.edu> | 2012-10-18 19:51:32 -0400 |
commit | e371352875eae24b984ae6675969ad1dfb7b9599 (patch) | |
tree | 5bbb611a1253cee4044556d7ca82c25003e7eb4a | |
parent | 0b0b594394ad472c745b3c19315a7a92217bb292 (diff) |
Turn color_ctrl_page into a system call.
Conflicts:
include/litmus/color.h
Signed-off-by: Christopher Kenna <cjk@cs.unc.edu>
-rw-r--r-- | arch/arm/kernel/calls.S | 2 | ||||
-rw-r--r-- | arch/x86/kernel/syscall_table_32.S | 1 | ||||
-rw-r--r-- | include/litmus/color.h | 8 | ||||
-rw-r--r-- | include/litmus/color_queue.h | 2 | ||||
-rw-r--r-- | include/litmus/rt_param.h | 5 | ||||
-rw-r--r-- | include/litmus/unistd_32.h | 3 | ||||
-rw-r--r-- | include/litmus/unistd_64.h | 4 | ||||
-rw-r--r-- | litmus/color.c | 33 | ||||
-rw-r--r-- | litmus/color_dev.c | 171 | ||||
-rw-r--r-- | litmus/color_queue.c | 30 | ||||
-rw-r--r-- | litmus/ctrldev.c | 12 | ||||
-rw-r--r-- | litmus/litmus.c | 25 | ||||
-rw-r--r-- | litmus/sched_color.c | 2 | ||||
-rw-r--r-- | litmus/sched_mc.c | 2 |
14 files changed, 104 insertions, 196 deletions
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index ed2ae934127..09595644f8f 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S | |||
@@ -397,6 +397,8 @@ | |||
397 | /* 385 */ CALL(sys_wait_for_ts_release) | 397 | /* 385 */ CALL(sys_wait_for_ts_release) |
398 | CALL(sys_release_ts) | 398 | CALL(sys_release_ts) |
399 | CALL(sys_null_call) | 399 | CALL(sys_null_call) |
400 | CALL(sys_set_rt_task_mc_param) | ||
401 | CALL(sys_set_color_page_info) | ||
400 | #ifndef syscalls_counted | 402 | #ifndef syscalls_counted |
401 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls | 403 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls |
402 | #define syscalls_counted | 404 | #define syscalls_counted |
diff --git a/arch/x86/kernel/syscall_table_32.S b/arch/x86/kernel/syscall_table_32.S index a40c1597042..21791aa0779 100644 --- a/arch/x86/kernel/syscall_table_32.S +++ b/arch/x86/kernel/syscall_table_32.S | |||
@@ -359,3 +359,4 @@ ENTRY(sys_call_table) | |||
359 | .long sys_release_ts /* +10 */ | 359 | .long sys_release_ts /* +10 */ |
360 | .long sys_null_call | 360 | .long sys_null_call |
361 | .long sys_set_rt_task_mc_param | 361 | .long sys_set_rt_task_mc_param |
362 | .long sys_set_color_page_info | ||
diff --git a/include/litmus/color.h b/include/litmus/color.h index d6d04f082ac..525e5c1c7d1 100644 --- a/include/litmus/color.h +++ b/include/litmus/color.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #ifdef __KERNEL__ | 4 | #ifdef __KERNEL__ |
5 | 5 | ||
6 | #include <asm/page.h> | ||
6 | #include <litmus/color_queue.h> | 7 | #include <litmus/color_queue.h> |
7 | 8 | ||
8 | #define ONE_COLOR_LEN 11 | 9 | #define ONE_COLOR_LEN 11 |
@@ -41,6 +42,10 @@ struct color_page_info { | |||
41 | /* changes from job to job */ | 42 | /* changes from job to job */ |
42 | }; | 43 | }; |
43 | 44 | ||
45 | /* Pre-declare */ | ||
46 | struct ctl_table; | ||
47 | struct vm_area_struct; | ||
48 | |||
44 | #ifdef CONFIG_CPU_V7 | 49 | #ifdef CONFIG_CPU_V7 |
45 | int litmus_test_prefetch_proc_handler(struct ctl_table *, int, | 50 | int litmus_test_prefetch_proc_handler(struct ctl_table *, int, |
46 | void __user *, size_t *, loff_t *); | 51 | void __user *, size_t *, loff_t *); |
@@ -64,9 +69,6 @@ extern int lock_cache; | |||
64 | 69 | ||
65 | void litmus_setup_lockdown(void __iomem*, u32); | 70 | void litmus_setup_lockdown(void __iomem*, u32); |
66 | 71 | ||
67 | struct vm_area_struct; | ||
68 | struct ctl_table; | ||
69 | |||
70 | struct page* get_colored_page(unsigned long); | 72 | struct page* get_colored_page(unsigned long); |
71 | void add_page_to_color_list(struct page*); | 73 | void add_page_to_color_list(struct page*); |
72 | void add_page_to_alloced_list(struct page*, struct vm_area_struct*); | 74 | void add_page_to_alloced_list(struct page*, struct vm_area_struct*); |
diff --git a/include/litmus/color_queue.h b/include/litmus/color_queue.h index 969095f8ff3..80976c539b1 100644 --- a/include/litmus/color_queue.h +++ b/include/litmus/color_queue.h | |||
@@ -78,4 +78,6 @@ int setup_flusher_array(void); | |||
78 | void color_queue_enqueue_read(struct task_struct *ts); | 78 | void color_queue_enqueue_read(struct task_struct *ts); |
79 | void color_queue_enqueue_flush(struct task_struct *ts); | 79 | void color_queue_enqueue_flush(struct task_struct *ts); |
80 | 80 | ||
81 | void cleanup_color_page_infos(struct list_head *head); | ||
82 | |||
81 | #endif | 83 | #endif |
diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index c13ca2c8ae9..103b03f4e67 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h | |||
@@ -279,10 +279,7 @@ struct rt_param { | |||
279 | lt_t tot_exec_time; | 279 | lt_t tot_exec_time; |
280 | lt_t last_exec_time; | 280 | lt_t last_exec_time; |
281 | lt_t orig_cost; | 281 | lt_t orig_cost; |
282 | struct color_ctrl_page *color_ctrl_page; | 282 | struct color_ctrl_page color_ctrl_page; |
283 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | ||
284 | void *color_ctrl_page_orig; | ||
285 | #endif | ||
286 | struct dgl_group_req *req; | 283 | struct dgl_group_req *req; |
287 | enum server_state state; | 284 | enum server_state state; |
288 | struct list_head color_page_info_list; | 285 | struct list_head color_page_info_list; |
diff --git a/include/litmus/unistd_32.h b/include/litmus/unistd_32.h index 71be3cd8d46..eab81ab4200 100644 --- a/include/litmus/unistd_32.h +++ b/include/litmus/unistd_32.h | |||
@@ -18,5 +18,6 @@ | |||
18 | #define __NR_release_ts __LSC(10) | 18 | #define __NR_release_ts __LSC(10) |
19 | #define __NR_null_call __LSC(11) | 19 | #define __NR_null_call __LSC(11) |
20 | #define __NR_set_rt_task_mc_param __LSC(12) | 20 | #define __NR_set_rt_task_mc_param __LSC(12) |
21 | #define __NR_set_color_page_info __LSC(13) | ||
21 | 22 | ||
22 | #define NR_litmus_syscalls 13 | 23 | #define NR_litmus_syscalls 14 |
diff --git a/include/litmus/unistd_64.h b/include/litmus/unistd_64.h index 95cb7449510..4c1695a5b80 100644 --- a/include/litmus/unistd_64.h +++ b/include/litmus/unistd_64.h | |||
@@ -31,5 +31,7 @@ __SYSCALL(__NR_release_ts, sys_release_ts) | |||
31 | __SYSCALL(__NR_null_call, sys_null_call) | 31 | __SYSCALL(__NR_null_call, sys_null_call) |
32 | #define __NR_set_rt_task_mc_param __LSC(12) | 32 | #define __NR_set_rt_task_mc_param __LSC(12) |
33 | __SYSCALL(__NR_set_rt_task_mc_param, sys_set_rt_task_mc_param) | 33 | __SYSCALL(__NR_set_rt_task_mc_param, sys_set_rt_task_mc_param) |
34 | #define __NR_set_color_page_info __LSC(13) | ||
35 | __SYSCALL(__NR_set_color_page_info, sys_set_color_page_info) | ||
34 | 36 | ||
35 | #define NR_litmus_syscalls 13 | 37 | #define NR_litmus_syscalls 14 |
diff --git a/litmus/color.c b/litmus/color.c index 9888c3f1599..5cbaada233e 100644 --- a/litmus/color.c +++ b/litmus/color.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/slab.h> | 5 | #include <linux/slab.h> |
6 | #include <linux/sysctl.h> | 6 | #include <linux/sysctl.h> |
7 | #include <linux/lockdep.h> | 7 | #include <linux/lockdep.h> |
8 | #include <linux/uaccess.h> | ||
8 | #include <linux/sched.h> /* required by litmus.h */ | 9 | #include <linux/sched.h> /* required by litmus.h */ |
9 | #include <asm/io.h> /* page_to_phys on SPARC */ | 10 | #include <asm/io.h> /* page_to_phys on SPARC */ |
10 | 11 | ||
@@ -213,6 +214,38 @@ void reclaim_pages(struct vm_area_struct *vma) | |||
213 | TRACE_CUR("Reclaimed %lu pages.\n", nr_reclaimed); | 214 | TRACE_CUR("Reclaimed %lu pages.\n", nr_reclaimed); |
214 | } | 215 | } |
215 | 216 | ||
217 | asmlinkage long sys_set_color_page_info(struct color_ctrl_page __user *user_color_ctrl) | ||
218 | { | ||
219 | struct color_ctrl_page *color_page = &tsk_rt(current)->color_ctrl_page; | ||
220 | color_t color_val, page_val; | ||
221 | long err = 0; | ||
222 | int i; | ||
223 | |||
224 | BUILD_BUG_ON(PAGE_SIZE < sizeof(struct color_ctrl_page)); | ||
225 | |||
226 | if (0 == user_color_ctrl) { | ||
227 | err = -EINVAL; | ||
228 | TRACE_CUR("User color ctrl page was null.\n"); | ||
229 | goto out; | ||
230 | } | ||
231 | |||
232 | if (copy_from_user(color_page, user_color_ctrl, sizeof(*color_page))) | ||
233 | { | ||
234 | err = -EINVAL; | ||
235 | TRACE_CUR("Couln't copy color control page from user space.\n"); | ||
236 | goto out; | ||
237 | } | ||
238 | |||
239 | TRACE_CUR("Printing first ten values (for checking):\n"); | ||
240 | for (i = 0; i < 10; i++) { | ||
241 | color_val = color_page->colors[i]; | ||
242 | page_val = color_page->pages[i]; | ||
243 | TRACE_CUR("for i:%d color:%hu page:%hu\n", i, color_val, page_val); | ||
244 | } | ||
245 | out: | ||
246 | return err; | ||
247 | } | ||
248 | |||
216 | /*********************************************************** | 249 | /*********************************************************** |
217 | * Proc | 250 | * Proc |
218 | ***********************************************************/ | 251 | ***********************************************************/ |
diff --git a/litmus/color_dev.c b/litmus/color_dev.c index 0efaa7f2b62..96e0edc54b2 100644 --- a/litmus/color_dev.c +++ b/litmus/color_dev.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <litmus/color_queue.h> | 15 | #include <litmus/color_queue.h> |
16 | 16 | ||
17 | #define ALLOC_NAME "litmus/color_alloc" | 17 | #define ALLOC_NAME "litmus/color_alloc" |
18 | #define CTRL_NAME "litmus/color_ctrl" | ||
19 | 18 | ||
20 | extern unsigned long nr_colors; | 19 | extern unsigned long nr_colors; |
21 | 20 | ||
@@ -53,137 +52,6 @@ static void mmap_common_vma_flags(struct vm_area_struct *vma) | |||
53 | } | 52 | } |
54 | 53 | ||
55 | /*********************************************************** | 54 | /*********************************************************** |
56 | * Control device | ||
57 | ***********************************************************/ | ||
58 | |||
59 | static void litmus_color_ctrl_vm_close(struct vm_area_struct *vma) | ||
60 | { | ||
61 | TRACE_CUR("flags=0x%lx prot=0x%lx\n", | ||
62 | vma->vm_flags, pgprot_val(vma->vm_page_prot)); | ||
63 | |||
64 | TRACE_CUR("%p:%p vma:%p vma->vm_private_data:%p closed.\n", | ||
65 | (void*) vma->vm_start, (void*) vma->vm_end, vma, | ||
66 | vma->vm_private_data); | ||
67 | } | ||
68 | |||
69 | static int litmus_color_ctrl_vm_fault(struct vm_area_struct *vma, | ||
70 | struct vm_fault *vmf) | ||
71 | { | ||
72 | /* This function should never be called, since | ||
73 | * all pages should have been mapped by mmap() | ||
74 | * already. */ | ||
75 | TRACE_CUR("flags=0x%lx (off:%ld)\n", vma->vm_flags, vmf->pgoff); | ||
76 | |||
77 | WARN(1, "Page fault in color ctrl page! flags=0x%lx\n", vma->vm_flags); | ||
78 | |||
79 | return VM_FAULT_SIGBUS; | ||
80 | } | ||
81 | |||
82 | static struct vm_operations_struct litmus_color_ctrl_vm_ops = { | ||
83 | .close = litmus_color_ctrl_vm_close, | ||
84 | .fault = litmus_color_ctrl_vm_fault, | ||
85 | }; | ||
86 | |||
87 | static int alloc_color_ctrl_page(void) | ||
88 | { | ||
89 | void *mem; | ||
90 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | ||
91 | void *mem_remap; | ||
92 | #endif | ||
93 | struct task_struct *t = current; | ||
94 | int err = 0; | ||
95 | |||
96 | /* only allocate if the task doesn't have one yet */ | ||
97 | if (!tsk_rt(t)->color_ctrl_page) { | ||
98 | mem = (void*) get_zeroed_page(GFP_KERNEL); | ||
99 | if (!mem) { | ||
100 | TRACE_TASK(t, "cannot allocate color control page\n"); | ||
101 | err = -ENOMEM; | ||
102 | goto out; | ||
103 | } | ||
104 | |||
105 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | ||
106 | mem_remap = remap_noncached(mem, PAGE_SIZE); | ||
107 | if (IS_ERR(mem_remap)) { | ||
108 | err = PTR_ERR(mem_remap); | ||
109 | free_page((unsigned long) mem); | ||
110 | goto out; | ||
111 | } | ||
112 | tsk_rt(t)->color_ctrl_page_orig = mem; | ||
113 | tsk_rt(t)->color_ctrl_page = mem_remap; | ||
114 | #else | ||
115 | tsk_rt(t)->color_ctrl_page = mem; | ||
116 | #endif | ||
117 | |||
118 | /* will get de-allocated in task teardown */ | ||
119 | TRACE_TASK(t, "color_ctrl_page = %p\n", | ||
120 | tsk_rt(t)->color_ctrl_page); | ||
121 | } | ||
122 | out: | ||
123 | return err; | ||
124 | } | ||
125 | |||
126 | static int map_color_ctrl_page(struct vm_area_struct *vma) | ||
127 | { | ||
128 | int err = 0; | ||
129 | struct task_struct *t = current; | ||
130 | struct page *color_ctrl; | ||
131 | |||
132 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | ||
133 | /* vm_insert_page() using the "real" vaddr, not the shadow mapping. */ | ||
134 | color_ctrl = virt_to_page(tsk_rt(t)->color_ctrl_page_orig); | ||
135 | #else | ||
136 | color_ctrl = virt_to_page(tsk_rt(t)->color_ctrl_page); | ||
137 | #endif | ||
138 | |||
139 | TRACE_CUR("mapping %p (pfn:%lx) to 0x%lx (flags:%lx prot:%lx)\n", | ||
140 | tsk_rt(t)->color_ctrl_page, page_to_pfn(color_ctrl), | ||
141 | vma->vm_start, vma->vm_flags, pgprot_val(vma->vm_page_prot)); | ||
142 | |||
143 | /* Map it into the vma. */ | ||
144 | err = vm_insert_page(vma, vma->vm_start, color_ctrl); | ||
145 | if (err) | ||
146 | TRACE_CUR("vm_insert_page() failed (%d)\n", err); | ||
147 | |||
148 | return err; | ||
149 | } | ||
150 | |||
151 | static int litmus_color_ctrl_mmap(struct file *filp, struct vm_area_struct *vma) | ||
152 | { | ||
153 | int err = 0; | ||
154 | |||
155 | /* you can only get one page */ | ||
156 | if (vma->vm_end - vma->vm_start != PAGE_SIZE) { | ||
157 | TRACE_CUR("must allocate a multiple of PAGE_SIZE\n"); | ||
158 | err = -EINVAL; | ||
159 | goto out; | ||
160 | } | ||
161 | |||
162 | err = mmap_common_checks(vma); | ||
163 | if (err) { | ||
164 | TRACE_CUR("failed common mmap checks.\n"); | ||
165 | goto out; | ||
166 | } | ||
167 | |||
168 | vma->vm_ops = &litmus_color_ctrl_vm_ops; | ||
169 | mmap_common_vma_flags(vma); | ||
170 | |||
171 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | ||
172 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | ||
173 | #endif | ||
174 | |||
175 | err = alloc_color_ctrl_page(); | ||
176 | if (!err) | ||
177 | err = map_color_ctrl_page(vma); | ||
178 | |||
179 | TRACE_CUR("flags=0x%lx prot=0x%lx\n", vma->vm_flags, | ||
180 | pgprot_val(vma->vm_page_prot)); | ||
181 | out: | ||
182 | return err; | ||
183 | } | ||
184 | |||
185 | |||
186 | /*********************************************************** | ||
187 | * Allocation device | 55 | * Allocation device |
188 | ***********************************************************/ | 56 | ***********************************************************/ |
189 | 57 | ||
@@ -218,7 +86,15 @@ static int create_color_page_info(int color, struct page *page) | |||
218 | req->request_type = COLOR_QUEUE_IDLE; | 86 | req->request_type = COLOR_QUEUE_IDLE; |
219 | } | 87 | } |
220 | 88 | ||
89 | if (NULL == tsk_rt(current)->color_page_info_list.next || | ||
90 | NULL == tsk_rt(current)->color_page_info_list.prev) { | ||
91 | INIT_LIST_HEAD(&tsk_rt(current)->color_page_info_list); | ||
92 | TRACE_CUR("Initialized the color_page_info_list\n"); | ||
93 | } | ||
94 | |||
221 | list_add_tail(&info->list, &tsk_rt(current)->color_page_info_list); | 95 | list_add_tail(&info->list, &tsk_rt(current)->color_page_info_list); |
96 | TRACE_CUR("Added color_page_info %p to list.\n", info); | ||
97 | |||
222 | out: | 98 | out: |
223 | return err; | 99 | return err; |
224 | } | 100 | } |
@@ -278,7 +154,7 @@ out: | |||
278 | static int do_map_colored_pages(struct vm_area_struct *vma) | 154 | static int do_map_colored_pages(struct vm_area_struct *vma) |
279 | { | 155 | { |
280 | const unsigned long nr_pages = vma_nr_pages(vma); | 156 | const unsigned long nr_pages = vma_nr_pages(vma); |
281 | struct color_ctrl_page *color_ctrl = tsk_rt(current)->color_ctrl_page; | 157 | struct color_ctrl_page *color_ctrl = &tsk_rt(current)->color_ctrl_page; |
282 | unsigned long nr_mapped; | 158 | unsigned long nr_mapped; |
283 | int i, err = 0; | 159 | int i, err = 0; |
284 | 160 | ||
@@ -329,12 +205,6 @@ static int map_colored_pages(struct vm_area_struct *vma) | |||
329 | { | 205 | { |
330 | int err = 0; | 206 | int err = 0; |
331 | 207 | ||
332 | if (!tsk_rt(current)->color_ctrl_page) { | ||
333 | TRACE_CUR("Process has no color control page.\n"); | ||
334 | err = -EINVAL; | ||
335 | goto out; | ||
336 | } | ||
337 | |||
338 | if (COLORS_PER_CONTROL_PAGE < vma_nr_pages(vma)) { | 208 | if (COLORS_PER_CONTROL_PAGE < vma_nr_pages(vma)) { |
339 | TRACE_CUR("Max page request %lu but want %lu.\n", | 209 | TRACE_CUR("Max page request %lu but want %lu.\n", |
340 | COLORS_PER_CONTROL_PAGE, vma_nr_pages(vma)); | 210 | COLORS_PER_CONTROL_PAGE, vma_nr_pages(vma)); |
@@ -348,7 +218,6 @@ out: | |||
348 | 218 | ||
349 | static void litmus_color_alloc_vm_close(struct vm_area_struct *vma) | 219 | static void litmus_color_alloc_vm_close(struct vm_area_struct *vma) |
350 | { | 220 | { |
351 | struct color_page_info *cur, *tmp; | ||
352 | 221 | ||
353 | TRACE_CUR("flags=0x%lx prot=0x%lx\n", | 222 | TRACE_CUR("flags=0x%lx prot=0x%lx\n", |
354 | vma->vm_flags, pgprot_val(vma->vm_page_prot)); | 223 | vma->vm_flags, pgprot_val(vma->vm_page_prot)); |
@@ -357,14 +226,12 @@ static void litmus_color_alloc_vm_close(struct vm_area_struct *vma) | |||
357 | (void*) vma->vm_start, (void*) vma->vm_end, vma, | 226 | (void*) vma->vm_start, (void*) vma->vm_end, vma, |
358 | vma->vm_private_data); | 227 | vma->vm_private_data); |
359 | 228 | ||
360 | /* clean up the color_page_infos */ | 229 | TRACE_CUR("color_page_info_list head: %p, next: %p, prev: %p\n", |
361 | list_for_each_entry_safe(cur, tmp, | ||
362 | &tsk_rt(current)->color_page_info_list, | 230 | &tsk_rt(current)->color_page_info_list, |
363 | list) | 231 | tsk_rt(current)->color_page_info_list.next, |
364 | { | 232 | tsk_rt(current)->color_page_info_list.prev); |
365 | kfree(cur); | ||
366 | } | ||
367 | 233 | ||
234 | cleanup_color_page_infos(&tsk_rt(current)->color_page_info_list); | ||
368 | reclaim_pages(vma); | 235 | reclaim_pages(vma); |
369 | } | 236 | } |
370 | 237 | ||
@@ -417,17 +284,6 @@ out: | |||
417 | * Initilization | 284 | * Initilization |
418 | ***********************************************************/ | 285 | ***********************************************************/ |
419 | 286 | ||
420 | static struct file_operations litmus_color_ctrl_fops = { | ||
421 | .owner = THIS_MODULE, | ||
422 | .mmap = litmus_color_ctrl_mmap, | ||
423 | }; | ||
424 | |||
425 | static struct miscdevice litmus_color_ctrl_dev = { | ||
426 | .name = CTRL_NAME, | ||
427 | .minor = MISC_DYNAMIC_MINOR, | ||
428 | .fops = &litmus_color_ctrl_fops, | ||
429 | }; | ||
430 | |||
431 | static struct file_operations litmus_color_alloc_fops = { | 287 | static struct file_operations litmus_color_alloc_fops = { |
432 | .owner = THIS_MODULE, | 288 | .owner = THIS_MODULE, |
433 | .mmap = litmus_color_alloc_mmap, | 289 | .mmap = litmus_color_alloc_mmap, |
@@ -457,7 +313,6 @@ static int __init init_color_devices(void) | |||
457 | err = init_dev(ALLOC_NAME, &litmus_color_alloc_dev); | 313 | err = init_dev(ALLOC_NAME, &litmus_color_alloc_dev); |
458 | if (err) | 314 | if (err) |
459 | goto out; | 315 | goto out; |
460 | err = init_dev(CTRL_NAME, &litmus_color_ctrl_dev); | ||
461 | out: | 316 | out: |
462 | return err; | 317 | return err; |
463 | } | 318 | } |
diff --git a/litmus/color_queue.c b/litmus/color_queue.c index a5a702332da..c266e3aa0da 100644 --- a/litmus/color_queue.c +++ b/litmus/color_queue.c | |||
@@ -41,7 +41,7 @@ static u32 lockdown_value_idle = UNLOCK_ALL; | |||
41 | * if we choose to. | 41 | * if we choose to. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | static void ***flusher_pages; | 44 | static void ***flusher_pages = NULL; |
45 | /* One page per [way, color] pair used for flushing. */ | 45 | /* One page per [way, color] pair used for flushing. */ |
46 | 46 | ||
47 | /* | 47 | /* |
@@ -63,8 +63,7 @@ static void cpu_add_work(struct color_queue_request *req) | |||
63 | * | 63 | * |
64 | * @vaddr_start changes depending upon if this is a read-in or a "flush". | 64 | * @vaddr_start changes depending upon if this is a read-in or a "flush". |
65 | */ | 65 | */ |
66 | static void color_page_info_add_work(struct color_page_info *info, | 66 | static void color_page_info_add_work(struct color_page_info *info, void *vaddr_start) |
67 | void *vaddr_start) | ||
68 | { | 67 | { |
69 | int i; | 68 | int i; |
70 | 69 | ||
@@ -278,6 +277,27 @@ static void color_queue_submit_work(void) | |||
278 | color_queue_loop(); | 277 | color_queue_loop(); |
279 | } | 278 | } |
280 | 279 | ||
280 | void cleanup_color_page_infos(struct list_head *head) | ||
281 | { | ||
282 | struct color_page_info *cur, *tmp; | ||
283 | |||
284 | if (NULL == head) { | ||
285 | TRACE("Head was null.\n"); | ||
286 | return; | ||
287 | } | ||
288 | |||
289 | if (NULL == head->next || NULL == head->prev) { | ||
290 | TRACE_CUR("next or prev was null\n"); | ||
291 | return; | ||
292 | } | ||
293 | |||
294 | list_for_each_entry_safe(cur, tmp, head, list) { | ||
295 | TRACE_CUR("cleanup color_queue_info %p\n", cur); | ||
296 | list_del(cur); | ||
297 | kfree(cur); | ||
298 | } | ||
299 | } | ||
300 | |||
281 | /* called when user does add_pages proc handler */ | 301 | /* called when user does add_pages proc handler */ |
282 | int setup_flusher_array(void) | 302 | int setup_flusher_array(void) |
283 | { | 303 | { |
@@ -290,6 +310,9 @@ int setup_flusher_array(void) | |||
290 | goto out; | 310 | goto out; |
291 | } | 311 | } |
292 | 312 | ||
313 | if (flusher_pages != NULL) | ||
314 | goto out; | ||
315 | |||
293 | flusher_pages = (void***) kmalloc(color_cache_info.ways | 316 | flusher_pages = (void***) kmalloc(color_cache_info.ways |
294 | * sizeof(*flusher_pages), GFP_KERNEL); | 317 | * sizeof(*flusher_pages), GFP_KERNEL); |
295 | if (!flusher_pages) { | 318 | if (!flusher_pages) { |
@@ -335,6 +358,7 @@ out_free: | |||
335 | kfree(flusher_pages[way]); | 358 | kfree(flusher_pages[way]); |
336 | } | 359 | } |
337 | kfree(flusher_pages); | 360 | kfree(flusher_pages); |
361 | flusher_pages = NULL; | ||
338 | return ret; | 362 | return ret; |
339 | } | 363 | } |
340 | 364 | ||
diff --git a/litmus/ctrldev.c b/litmus/ctrldev.c index 87c21609964..1d19e208ecd 100644 --- a/litmus/ctrldev.c +++ b/litmus/ctrldev.c | |||
@@ -19,10 +19,8 @@ static struct workqueue_struct *wq_litmus_dealloc; | |||
19 | struct litmus_dealloc_work { | 19 | struct litmus_dealloc_work { |
20 | struct work_struct work_struct; | 20 | struct work_struct work_struct; |
21 | void *ctrl_page_mem; | 21 | void *ctrl_page_mem; |
22 | void *color_ctrl_page_mem; | ||
23 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | 22 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE |
24 | void *ctrl_page_unmap; | 23 | void *ctrl_page_unmap; |
25 | void *color_ctrl_page_unmap; | ||
26 | #endif | 24 | #endif |
27 | }; | 25 | }; |
28 | 26 | ||
@@ -34,15 +32,10 @@ static void litmus_dealloc(struct work_struct *work_in) | |||
34 | TRACE("vunmap() control page %p.\n", work->ctrl_page_unmap); | 32 | TRACE("vunmap() control page %p.\n", work->ctrl_page_unmap); |
35 | vunmap(work->ctrl_page_unmap); | 33 | vunmap(work->ctrl_page_unmap); |
36 | 34 | ||
37 | TRACE("vunmap() color control page %p.\n", work->color_ctrl_page_unmap); | ||
38 | vunmap(work->color_ctrl_page_unmap); | ||
39 | #endif | 35 | #endif |
40 | TRACE("freeing ctrl_page %p\n", work->ctrl_page_mem); | 36 | TRACE("freeing ctrl_page %p\n", work->ctrl_page_mem); |
41 | free_page((unsigned long) work->ctrl_page_mem); | 37 | free_page((unsigned long) work->ctrl_page_mem); |
42 | 38 | ||
43 | TRACE("freeing color_ctrl_page %p\n", work->color_ctrl_page_mem); | ||
44 | free_page((unsigned long) work->color_ctrl_page_mem); | ||
45 | |||
46 | kfree((void*) work); | 39 | kfree((void*) work); |
47 | } | 40 | } |
48 | 41 | ||
@@ -50,7 +43,7 @@ void litmus_schedule_deallocation(struct task_struct *t) | |||
50 | { | 43 | { |
51 | struct litmus_dealloc_work *work; | 44 | struct litmus_dealloc_work *work; |
52 | 45 | ||
53 | if (NULL == tsk_rt(t)->ctrl_page && NULL == tsk_rt(t)->color_ctrl_page) | 46 | if (NULL == tsk_rt(t)->ctrl_page) |
54 | return; | 47 | return; |
55 | 48 | ||
56 | work = kmalloc(sizeof(*work), GFP_ATOMIC); | 49 | work = kmalloc(sizeof(*work), GFP_ATOMIC); |
@@ -64,11 +57,8 @@ void litmus_schedule_deallocation(struct task_struct *t) | |||
64 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | 57 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE |
65 | work->ctrl_page_mem = tsk_rt(t)->ctrl_page_orig; | 58 | work->ctrl_page_mem = tsk_rt(t)->ctrl_page_orig; |
66 | work->ctrl_page_unmap = tsk_rt(t)->ctrl_page; | 59 | work->ctrl_page_unmap = tsk_rt(t)->ctrl_page; |
67 | work->color_ctrl_page_mem = tsk_rt(t)->color_ctrl_page_orig; | ||
68 | work->color_ctrl_page_unmap = tsk_rt(t)->color_ctrl_page; | ||
69 | #else | 60 | #else |
70 | work->ctrl_page_mem = tsk_rt(t)->ctrl_page; | 61 | work->ctrl_page_mem = tsk_rt(t)->ctrl_page; |
71 | work->color_ctrl_page_mem = tsk_rt(t)->color_ctrl_page; | ||
72 | #endif | 62 | #endif |
73 | queue_work(wq_litmus_dealloc, &work->work_struct); | 63 | queue_work(wq_litmus_dealloc, &work->work_struct); |
74 | } | 64 | } |
diff --git a/litmus/litmus.c b/litmus/litmus.c index 74e798992fa..070ecefaeac 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c | |||
@@ -35,6 +35,8 @@ struct mc_task; | |||
35 | #include <litmus/affinity.h> | 35 | #include <litmus/affinity.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <litmus/color_queue.h> | ||
39 | |||
38 | /* Number of RT tasks that exist in the system */ | 40 | /* Number of RT tasks that exist in the system */ |
39 | atomic_t rt_task_count = ATOMIC_INIT(0); | 41 | atomic_t rt_task_count = ATOMIC_INIT(0); |
40 | static DEFINE_RAW_SPINLOCK(task_transition_lock); | 42 | static DEFINE_RAW_SPINLOCK(task_transition_lock); |
@@ -390,25 +392,23 @@ static void reinit_litmus_state(struct task_struct* p, int restore) | |||
390 | { | 392 | { |
391 | struct rt_task user_config = {}; | 393 | struct rt_task user_config = {}; |
392 | void* ctrl_page = NULL; | 394 | void* ctrl_page = NULL; |
395 | struct list_head color_page_info_list; | ||
393 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | 396 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE |
394 | void * ctrl_page_orig = NULL; | 397 | void * ctrl_page_orig = NULL; |
395 | #endif | 398 | #endif |
396 | 399 | ||
397 | void *color_ctrl_page = NULL; | ||
398 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | ||
399 | void *color_ctrl_page_orig = NULL; | ||
400 | #endif | ||
401 | |||
402 | if (restore) { | 400 | if (restore) { |
403 | /* Safe user-space provided configuration data. | 401 | /* Safe user-space provided configuration data. |
404 | * and allocated page. */ | 402 | * and allocated page. */ |
405 | user_config = p->rt_param.task_params; | 403 | user_config = p->rt_param.task_params; |
406 | ctrl_page = p->rt_param.ctrl_page; | 404 | ctrl_page = p->rt_param.ctrl_page; |
407 | color_ctrl_page = p->rt_param.color_ctrl_page; | ||
408 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | 405 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE |
409 | ctrl_page_orig = p->rt_param.ctrl_page_orig; | 406 | ctrl_page_orig = p->rt_param.ctrl_page_orig; |
410 | color_ctrl_page_orig = p->rt_param.color_ctrl_page_orig; | ||
411 | #endif | 407 | #endif |
408 | color_page_info_list.next = | ||
409 | p->rt_param.color_page_info_list.next; | ||
410 | color_page_info_list.prev = | ||
411 | p->rt_param.color_page_info_list.prev; | ||
412 | } | 412 | } |
413 | 413 | ||
414 | /* We probably should not be inheriting any task's priority | 414 | /* We probably should not be inheriting any task's priority |
@@ -418,16 +418,19 @@ static void reinit_litmus_state(struct task_struct* p, int restore) | |||
418 | 418 | ||
419 | /* Cleanup everything else. */ | 419 | /* Cleanup everything else. */ |
420 | memset(&p->rt_param, 0, sizeof(p->rt_param)); | 420 | memset(&p->rt_param, 0, sizeof(p->rt_param)); |
421 | INIT_LIST_HEAD(&p->rt_param.color_page_info_list); | ||
421 | 422 | ||
422 | /* Restore preserved fields. */ | 423 | /* Restore preserved fields. */ |
423 | if (restore) { | 424 | if (restore) { |
424 | p->rt_param.task_params = user_config; | 425 | p->rt_param.task_params = user_config; |
425 | p->rt_param.ctrl_page = ctrl_page; | 426 | p->rt_param.ctrl_page = ctrl_page; |
426 | p->rt_param.color_ctrl_page = color_ctrl_page; | ||
427 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | 427 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE |
428 | p->rt_param.ctrl_page_orig = ctrl_page_orig; | 428 | p->rt_param.ctrl_page_orig = ctrl_page_orig; |
429 | p->rt_param.color_ctrl_page_orig = color_ctrl_page_orig; | ||
430 | #endif | 429 | #endif |
430 | p->rt_param.color_page_info_list.next = | ||
431 | color_page_info_list.next; | ||
432 | p->rt_param.color_page_info_list.prev = | ||
433 | color_page_info_list.prev; | ||
431 | } | 434 | } |
432 | } | 435 | } |
433 | 436 | ||
@@ -578,10 +581,8 @@ void litmus_fork(struct task_struct* p) | |||
578 | } else { | 581 | } else { |
579 | /* non-rt tasks might have ctrl_page set */ | 582 | /* non-rt tasks might have ctrl_page set */ |
580 | tsk_rt(p)->ctrl_page = NULL; | 583 | tsk_rt(p)->ctrl_page = NULL; |
581 | tsk_rt(p)->color_ctrl_page = NULL; | ||
582 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | 584 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE |
583 | tsk_rt(p)->ctrl_page_orig = NULL; | 585 | tsk_rt(p)->ctrl_page_orig = NULL; |
584 | tsk_rt(p)->color_ctrl_page_orig = NULL; | ||
585 | #endif | 586 | #endif |
586 | } | 587 | } |
587 | 588 | ||
@@ -601,10 +602,8 @@ void litmus_exec(void) | |||
601 | WARN_ON(p->rt_param.inh_task); | 602 | WARN_ON(p->rt_param.inh_task); |
602 | litmus_schedule_deallocation(p); | 603 | litmus_schedule_deallocation(p); |
603 | tsk_rt(p)->ctrl_page = NULL; | 604 | tsk_rt(p)->ctrl_page = NULL; |
604 | tsk_rt(p)->color_ctrl_page = NULL; | ||
605 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE | 605 | #ifdef CONFIG_ARCH_NEEDS_UNCACHED_CONTROL_PAGE |
606 | tsk_rt(p)->ctrl_page_orig = NULL; | 606 | tsk_rt(p)->ctrl_page_orig = NULL; |
607 | tsk_rt(p)->color_ctrl_page_orig = NULL; | ||
608 | #endif | 607 | #endif |
609 | } | 608 | } |
610 | } | 609 | } |
diff --git a/litmus/sched_color.c b/litmus/sched_color.c index f7e4be70054..0fef8b5f21a 100644 --- a/litmus/sched_color.c +++ b/litmus/sched_color.c | |||
@@ -553,7 +553,7 @@ static void color_task_new(struct task_struct *t, int on_rq, int running) | |||
553 | struct cpu_entry *entry; | 553 | struct cpu_entry *entry; |
554 | struct dgl_group_req *req; | 554 | struct dgl_group_req *req; |
555 | struct control_page *cp = tsk_rt(t)->ctrl_page; | 555 | struct control_page *cp = tsk_rt(t)->ctrl_page; |
556 | struct color_ctrl_page *ccp = tsk_rt(t)->color_ctrl_page; | 556 | struct color_ctrl_page *ccp = &tsk_rt(t)->color_ctrl_page; |
557 | 557 | ||
558 | 558 | ||
559 | TRACE_TASK(t, "New colored task\n"); | 559 | TRACE_TASK(t, "New colored task\n"); |
diff --git a/litmus/sched_mc.c b/litmus/sched_mc.c index 288578767d2..0394618dbc9 100644 --- a/litmus/sched_mc.c +++ b/litmus/sched_mc.c | |||
@@ -959,7 +959,7 @@ static void mc_task_new(struct task_struct *t, int on_rq, int running) | |||
959 | enum crit_level level = tsk_mc_crit(t); | 959 | enum crit_level level = tsk_mc_crit(t); |
960 | struct dgl_group_req *req; | 960 | struct dgl_group_req *req; |
961 | struct control_page *cp = tsk_rt(t)->ctrl_page; | 961 | struct control_page *cp = tsk_rt(t)->ctrl_page; |
962 | struct color_ctrl_page *ccp = tsk_rt(t)->color_ctrl_page; | 962 | struct color_ctrl_page *ccp = &tsk_rt(t)->color_ctrl_page; |
963 | 963 | ||
964 | local_irq_save(flags); | 964 | local_irq_save(flags); |
965 | TRACE("New mixed criticality task %d\n", t->pid); | 965 | TRACE("New mixed criticality task %d\n", t->pid); |