diff options
author | ChengYang Fu <chengyangfu@gmail.com> | 2015-01-27 12:23:44 -0500 |
---|---|---|
committer | Namhoon Kim <namhoonk@cs.unc.edu> | 2015-01-28 09:38:25 -0500 |
commit | d7f8145b8a0525dccd2990fd0739012d04f3d978 (patch) | |
tree | f54d8e2c23570028caf4c083b3fdb1c70ca5ec84 | |
parent | f9b8ce9e2c06fe8ecd3141837da910675af238c3 (diff) |
Provide interface to let litmus ask new pages by bank number
-rw-r--r-- | litmus/bank_proc.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/litmus/bank_proc.c b/litmus/bank_proc.c index 2c69657b53bd..ec04626b43ec 100644 --- a/litmus/bank_proc.c +++ b/litmus/bank_proc.c | |||
@@ -131,7 +131,6 @@ out: | |||
131 | * node = 3 for Level A, B tasks in Cpu 3 | 131 | * node = 3 for Level A, B tasks in Cpu 3 |
132 | * node = 4 for Level C tasks | 132 | * node = 4 for Level C tasks |
133 | */ | 133 | */ |
134 | #if 1 | ||
135 | struct page *new_alloc_page(struct page *page, unsigned long node, int **x) | 134 | struct page *new_alloc_page(struct page *page, unsigned long node, int **x) |
136 | { | 135 | { |
137 | printk("allocate new page node = %d\n", node); | 136 | printk("allocate new page node = %d\n", node); |
@@ -194,9 +193,44 @@ out_unlock: | |||
194 | out: | 193 | out: |
195 | do_add_pages(); | 194 | do_add_pages(); |
196 | return rPage; | 195 | return rPage; |
197 | //return alloc_page(GFP_HIGHUSER_MOVABLE); | ||
198 | } | 196 | } |
199 | #endif | 197 | |
198 | struct page *new_alloc_page_banknr(struct page *page, unsigned long banknr, int **x) | ||
199 | { | ||
200 | printk("allocate new page bank = %d\n", banknr); | ||
201 | struct color_group *cgroup; | ||
202 | struct page *rPage = NULL; | ||
203 | unsigned int color; | ||
204 | get_random_bytes(&color, sizeof(unsigned int)); | ||
205 | |||
206 | if((banknr<= 7) && (banknr>=0)){ | ||
207 | color = (color%2) * 8 + banknr; | ||
208 | }else{ | ||
209 | goto out; | ||
210 | } | ||
211 | |||
212 | cgroup = &color_groups[color]; | ||
213 | spin_lock(&cgroup->lock); | ||
214 | if (unlikely(!atomic_read(&cgroup->nr_pages))) { | ||
215 | TRACE_CUR("No free %lu colored pages.\n", color); | ||
216 | printk(KERN_WARNING "no free %lu colored pages.\n", color); | ||
217 | goto out_unlock; | ||
218 | } | ||
219 | rPage = list_first_entry(&cgroup->list, struct page, lru); | ||
220 | BUG_ON(page_count(rPage) > 1); | ||
221 | get_page(rPage); | ||
222 | list_del(&rPage->lru); | ||
223 | atomic_dec(&cgroup->nr_pages); | ||
224 | // ClearPageLRU(rPage); | ||
225 | out_unlock: | ||
226 | spin_unlock(&cgroup->lock); | ||
227 | out: | ||
228 | do_add_pages(); | ||
229 | return rPage; | ||
230 | |||
231 | |||
232 | |||
233 | } | ||
200 | 234 | ||
201 | static int __init init_variables(void) | 235 | static int __init init_variables(void) |
202 | { | 236 | { |