diff options
author | Christopher Kenna <cjk@cs.unc.edu> | 2012-05-01 17:59:18 -0400 |
---|---|---|
committer | Christopher Kenna <cjk@cs.unc.edu> | 2012-05-01 17:59:18 -0400 |
commit | 2f50cc66b3000d1c927990c4cf7a973ee9269014 (patch) | |
tree | 11ae690042e18e44bf1284cadc6899032f3d0a36 /litmus | |
parent | fc19a148b4b286dfe80bc0e0c2cfc193e1405059 (diff) |
Add the beginings of a SPARC port. Edit page-types to work on SPARC
Diffstat (limited to 'litmus')
-rw-r--r-- | litmus/color.c | 78 | ||||
-rw-r--r-- | litmus/color_dev.c | 7 | ||||
-rw-r--r-- | litmus/sched_litmus.c | 4 |
3 files changed, 63 insertions, 26 deletions
diff --git a/litmus/color.c b/litmus/color.c index 7b23703f6206..dad2f07b154a 100644 --- a/litmus/color.c +++ b/litmus/color.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/sysctl.h> | 6 | #include <linux/sysctl.h> |
7 | #include <linux/lockdep.h> | 7 | #include <linux/lockdep.h> |
8 | #include <linux/sched.h> /* required by litmus.h */ | 8 | #include <linux/sched.h> /* required by litmus.h */ |
9 | #include <asm/io.h> /* page_to_phys on SPARC */ | ||
9 | 10 | ||
10 | #include <litmus/color.h> | 11 | #include <litmus/color.h> |
11 | #include <litmus/litmus.h> /* for in_list(...) */ | 12 | #include <litmus/litmus.h> /* for in_list(...) */ |
@@ -37,7 +38,9 @@ static struct color_group *color_groups; | |||
37 | 38 | ||
38 | /* non-static: extern'ed in various files */ | 39 | /* non-static: extern'ed in various files */ |
39 | unsigned long nr_colors; | 40 | unsigned long nr_colors; |
41 | #ifdef CONFIG_X86 | ||
40 | struct color_cache_info color_cache_info; | 42 | struct color_cache_info color_cache_info; |
43 | #endif | ||
41 | int color_sysctl_add_pages_data; | 44 | int color_sysctl_add_pages_data; |
42 | int color_sysctl_reclaim_pages_data; | 45 | int color_sysctl_reclaim_pages_data; |
43 | 46 | ||
@@ -115,8 +118,14 @@ static int do_add_pages(void) | |||
115 | int ret = 0; | 118 | int ret = 0; |
116 | 119 | ||
117 | while (smallest_nr_pages() < PAGES_PER_COLOR) { | 120 | while (smallest_nr_pages() < PAGES_PER_COLOR) { |
121 | #if defined(CONFIG_X86) | ||
118 | page = alloc_page(GFP_HIGHUSER | __GFP_ZERO | | 122 | page = alloc_page(GFP_HIGHUSER | __GFP_ZERO | |
119 | __GFP_MOVABLE); | 123 | __GFP_MOVABLE); |
124 | #elif defined(CONFIG_SPARC) /* X86 */ | ||
125 | page = alloc_page(GFP_HIGHUSER | __GFP_MOVABLE); | ||
126 | #else | ||
127 | #error What architecture are you using? | ||
128 | #endif | ||
120 | if (unlikely(!page)) { | 129 | if (unlikely(!page)) { |
121 | printk(KERN_WARNING "Could not allocate pages.\n"); | 130 | printk(KERN_WARNING "Could not allocate pages.\n"); |
122 | ret = -ENOMEM; | 131 | ret = -ENOMEM; |
@@ -147,7 +156,11 @@ static int do_reclaim_pages(void) | |||
147 | ClearPageLRU(page); | 156 | ClearPageLRU(page); |
148 | add_page_to_color_list(page); | 157 | add_page_to_color_list(page); |
149 | nr_reclaimed++; | 158 | nr_reclaimed++; |
159 | TRACE_CUR("reclaiming page (pa:0x%10llx, pfn:%8lu, " | ||
160 | "color:%3lu)\n", page_to_phys(page), | ||
161 | page_to_pfn(page), page_color(page)); | ||
150 | } | 162 | } |
163 | |||
151 | } | 164 | } |
152 | spin_unlock(&alloced_pages.lock); | 165 | spin_unlock(&alloced_pages.lock); |
153 | TRACE_CUR("Reclaimed %lu pages.\n", nr_reclaimed); | 166 | TRACE_CUR("Reclaimed %lu pages.\n", nr_reclaimed); |
@@ -212,6 +225,7 @@ out: | |||
212 | * Initialization | 225 | * Initialization |
213 | ***********************************************************/ | 226 | ***********************************************************/ |
214 | 227 | ||
228 | #if defined(CONFIG_X86) | ||
215 | /* slowest possible way to find a log, but we only do this once on boot */ | 229 | /* slowest possible way to find a log, but we only do this once on boot */ |
216 | static unsigned int __init slow_log(unsigned int v) | 230 | static unsigned int __init slow_log(unsigned int v) |
217 | { | 231 | { |
@@ -221,9 +235,24 @@ static unsigned int __init slow_log(unsigned int v) | |||
221 | return r; | 235 | return r; |
222 | } | 236 | } |
223 | 237 | ||
224 | static void __init init_mask(void) | 238 | static int __init init_mask(void) |
225 | { | 239 | { |
226 | const unsigned int line_size_log = slow_log(color_cache_info.line_size); | 240 | unsigned int line_size_log = slow_log(color_cache_info.line_size); |
241 | int err = 0; | ||
242 | |||
243 | BUG_ON(color_cache_info.size <= 1048576 || | ||
244 | color_cache_info.ways < 15 || | ||
245 | color_cache_info.line_size != 64); | ||
246 | |||
247 | printk("Cache size: %lu line-size: %lu ways: %lu sets: %lu\n", | ||
248 | color_cache_info.size, color_cache_info.line_size, | ||
249 | color_cache_info.ways, color_cache_info.sets); | ||
250 | if (!color_cache_info.size) { | ||
251 | printk(KERN_WARNING "No cache information found.\n"); | ||
252 | err = -EINVAL; | ||
253 | goto out; | ||
254 | } | ||
255 | |||
227 | 256 | ||
228 | BUG_ON(color_cache_info.size / color_cache_info.line_size / | 257 | BUG_ON(color_cache_info.size / color_cache_info.line_size / |
229 | color_cache_info.ways != color_cache_info.sets); | 258 | color_cache_info.ways != color_cache_info.sets); |
@@ -231,21 +260,31 @@ static void __init init_mask(void) | |||
231 | color_mask = ((color_cache_info.sets << line_size_log) - 1) ^ | 260 | color_mask = ((color_cache_info.sets << line_size_log) - 1) ^ |
232 | (PAGE_SIZE - 1); | 261 | (PAGE_SIZE - 1); |
233 | nr_colors = (color_mask >> PAGE_SHIFT) + 1; | 262 | nr_colors = (color_mask >> PAGE_SHIFT) + 1; |
234 | printk("Color mask: 0x%lx Total colors: %lu\n", color_mask, | 263 | out: |
235 | nr_colors); | 264 | return err; |
236 | BUG_ON(LOCKDEP_MAX_NR_COLORS < nr_colors); | 265 | } |
266 | #elif defined(CONFIG_SPARC) /* X86 */ | ||
267 | static int __init init_mask(void) | ||
268 | { | ||
269 | /* bits 17:13 */ | ||
270 | color_mask = 0x3e000UL; | ||
271 | nr_colors = (1 << hweight_long(color_mask)); | ||
272 | return 0; | ||
237 | } | 273 | } |
274 | #endif /* SPARC/X86 */ | ||
275 | |||
276 | |||
238 | 277 | ||
239 | static int __init init_color_groups(void) | 278 | static int __init init_color_groups(void) |
240 | { | 279 | { |
241 | struct color_group *cgroup; | 280 | struct color_group *cgroup; |
242 | unsigned long i; | 281 | unsigned long i; |
243 | int ret = 0; | 282 | int err = 0; |
244 | 283 | ||
245 | color_groups = kmalloc(nr_colors * sizeof(struct color_group), GFP_KERNEL); | 284 | color_groups = kmalloc(nr_colors * sizeof(struct color_group), GFP_KERNEL); |
246 | if (!color_groups) { | 285 | if (!color_groups) { |
247 | printk(KERN_WARNING "Could not allocate color groups.\n"); | 286 | printk(KERN_WARNING "Could not allocate color groups.\n"); |
248 | ret = -ENOMEM; | 287 | err = -ENOMEM; |
249 | goto out; | 288 | goto out; |
250 | } | 289 | } |
251 | 290 | ||
@@ -258,33 +297,24 @@ static int __init init_color_groups(void) | |||
258 | cgroup->_lock_name, "color%lu", i); | 297 | cgroup->_lock_name, "color%lu", i); |
259 | } | 298 | } |
260 | out: | 299 | out: |
261 | return ret; | 300 | return err; |
262 | } | 301 | } |
263 | 302 | ||
264 | static int __init init_color(void) | 303 | static int __init init_color(void) |
265 | { | 304 | { |
266 | int ret = 0; | 305 | int err = 0; |
267 | printk("Initializing LITMUS^RT cache coloring.\n"); | 306 | printk("Initializing LITMUS^RT cache coloring.\n"); |
268 | 307 | ||
269 | BUG_ON(color_cache_info.size <= 1048576 || | ||
270 | color_cache_info.ways < 15 || | ||
271 | color_cache_info.line_size != 64); | ||
272 | INIT_LIST_HEAD(&alloced_pages.list); | 308 | INIT_LIST_HEAD(&alloced_pages.list); |
273 | spin_lock_init(&alloced_pages.lock); | 309 | spin_lock_init(&alloced_pages.lock); |
274 | 310 | ||
275 | printk("Cache size: %lu line-size: %lu ways: %lu sets: %lu\n", | 311 | err = init_mask(); |
276 | color_cache_info.size, color_cache_info.line_size, | 312 | printk("PAGE_SIZE: %lu Color mask: 0x%lx Total colors: %lu\n", |
277 | color_cache_info.ways, color_cache_info.sets); | 313 | PAGE_SIZE, color_mask, nr_colors); |
278 | if (!color_cache_info.size) { | ||
279 | printk(KERN_WARNING "No cache information found.\n"); | ||
280 | ret = -EINVAL; | ||
281 | goto out; | ||
282 | } | ||
283 | 314 | ||
284 | init_mask(); | 315 | BUG_ON(LOCKDEP_MAX_NR_COLORS < nr_colors); |
285 | ret = init_color_groups(); | 316 | err = init_color_groups(); |
286 | out: | 317 | return err; |
287 | return ret; | ||
288 | } | 318 | } |
289 | 319 | ||
290 | module_init(init_color); | 320 | module_init(init_color); |
diff --git a/litmus/color_dev.c b/litmus/color_dev.c index e1404142c18a..10ab1e6b1161 100644 --- a/litmus/color_dev.c +++ b/litmus/color_dev.c | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <linux/miscdevice.h> | 4 | #include <linux/miscdevice.h> |
5 | #include <linux/spinlock.h> | 5 | #include <linux/spinlock.h> |
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
7 | #include <linux/highmem.h> | ||
8 | #include <asm/io.h> /* page_to_phys on SPARC */ | ||
7 | 9 | ||
8 | #include <litmus/litmus.h> | 10 | #include <litmus/litmus.h> |
9 | #include <litmus/color.h> | 11 | #include <litmus/color.h> |
@@ -168,8 +170,12 @@ static int do_map_colored_pages(struct vm_area_struct *vma) | |||
168 | TRACE_CUR(ALLOC_NAME ": Could not get page with " | 170 | TRACE_CUR(ALLOC_NAME ": Could not get page with " |
169 | " color %lu.\n", this_color); | 171 | " color %lu.\n", this_color); |
170 | /* TODO unmap mapped pages */ | 172 | /* TODO unmap mapped pages */ |
173 | err = -ENOMEM; | ||
171 | break; | 174 | break; |
172 | } | 175 | } |
176 | #ifdef CONFIG_SPARC | ||
177 | clear_user_highpage(page, addr); | ||
178 | #endif | ||
173 | TRACE_CUR(ALLOC_NAME ": insert page (pa:0x%10llx, pfn:%8lu, " | 179 | TRACE_CUR(ALLOC_NAME ": insert page (pa:0x%10llx, pfn:%8lu, " |
174 | "color:%3lu) at 0x%lx\n", page_to_phys(page), | 180 | "color:%3lu) at 0x%lx\n", page_to_phys(page), |
175 | page_to_pfn(page), this_color, addr); | 181 | page_to_pfn(page), this_color, addr); |
@@ -178,6 +184,7 @@ static int do_map_colored_pages(struct vm_area_struct *vma) | |||
178 | TRACE_CUR(ALLOC_NAME ": vm_insert_page() failed " | 184 | TRACE_CUR(ALLOC_NAME ": vm_insert_page() failed " |
179 | "(%d)\n", err); | 185 | "(%d)\n", err); |
180 | /* TODO unmap mapped pages */ | 186 | /* TODO unmap mapped pages */ |
187 | err = -EINVAL; | ||
181 | break; | 188 | break; |
182 | } | 189 | } |
183 | add_page_to_alloced_list(page); | 190 | add_page_to_alloced_list(page); |
diff --git a/litmus/sched_litmus.c b/litmus/sched_litmus.c index 5a15ce938984..6553948407de 100644 --- a/litmus/sched_litmus.c +++ b/litmus/sched_litmus.c | |||
@@ -102,9 +102,9 @@ litmus_schedule(struct rq *rq, struct task_struct *prev) | |||
102 | } | 102 | } |
103 | } | 103 | } |
104 | #ifdef __ARCH_WANT_UNLOCKED_CTXSW | 104 | #ifdef __ARCH_WANT_UNLOCKED_CTXSW |
105 | if (next->oncpu) | 105 | if (next->on_cpu) |
106 | TRACE_TASK(next, "waiting for !oncpu"); | 106 | TRACE_TASK(next, "waiting for !oncpu"); |
107 | while (next->oncpu) { | 107 | while (next->on_cpu) { |
108 | cpu_relax(); | 108 | cpu_relax(); |
109 | mb(); | 109 | mb(); |
110 | } | 110 | } |