aboutsummaryrefslogtreecommitdiffstats
path: root/litmus
diff options
context:
space:
mode:
authorChristopher Kenna <cjk@cs.unc.edu>2012-04-26 11:09:44 -0400
committerChristopher Kenna <cjk@cs.unc.edu>2012-04-26 11:09:44 -0400
commitfc19a148b4b286dfe80bc0e0c2cfc193e1405059 (patch)
tree244b3f7bf69735ff853db781879aca97d0a8e2f2 /litmus
parent221741e9a87b20741ffccbd7d9b3e637ccc276ce (diff)
Use a typedef for the color number.
Diffstat (limited to 'litmus')
-rw-r--r--litmus/color_dev.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/litmus/color_dev.c b/litmus/color_dev.c
index 414f4d7f1082..e1404142c18a 100644
--- a/litmus/color_dev.c
+++ b/litmus/color_dev.c
@@ -146,37 +146,33 @@ out:
146#define vma_nr_pages(vma) \ 146#define vma_nr_pages(vma) \
147 ({unsigned long v = ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); v;}) 147 ({unsigned long v = ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); v;})
148 148
149#define next_color(c) ({unsigned long _x = (c + 1) % nr_colors; _x;})
150
151static int do_map_colored_pages(struct vm_area_struct *vma) 149static int do_map_colored_pages(struct vm_area_struct *vma)
152{ 150{
153 const unsigned long nr_pages = vma_nr_pages(vma); 151 const unsigned long nr_pages = vma_nr_pages(vma);
154 unsigned long mapped; 152 unsigned long nr_mapped;
155 uint16_t *cur_color; 153 color_t *cur_color;
156 int err; 154 int err;
157 155
158 TRACE_CUR(ALLOC_NAME ": allocating %lu pages\n", nr_pages); 156 TRACE_CUR(ALLOC_NAME ": allocating %lu pages\n", nr_pages);
159 157
160 for (mapped = 0, cur_color = tsk_rt(current)->color_ctrl_page->colors; 158 for ( nr_mapped = 0,
161 mapped < nr_pages; 159 cur_color = tsk_rt(current)->color_ctrl_page->colors;
162 mapped++, cur_color++) 160 nr_mapped < nr_pages;
161 nr_mapped++, cur_color++)
163 { 162 {
164 const unsigned long color = *cur_color; 163 const unsigned long this_color = *cur_color;
165 const unsigned long addr = vma->vm_start + (mapped << PAGE_SHIFT); 164 const unsigned long addr = vma->vm_start + (nr_mapped << PAGE_SHIFT);
166 struct page *page = get_colored_page(color); 165 struct page *page = get_colored_page(this_color);
167 166
168 if (!page) { 167 if (!page) {
169 TRACE_CUR(ALLOC_NAME ": Could not get page with " 168 TRACE_CUR(ALLOC_NAME ": Could not get page with "
170 " color %lu.\n", color); 169 " color %lu.\n", this_color);
171 /* TODO unmap mapped pages */ 170 /* TODO unmap mapped pages */
172 break; 171 break;
173 } 172 }
174 TRACE_CUR(ALLOC_NAME ": insert page (pa:0x%llx, pfn:%lu, " 173 TRACE_CUR(ALLOC_NAME ": insert page (pa:0x%10llx, pfn:%8lu, "
175 "color:%lu count:%d LRU:%d) at 0x%lx " 174 "color:%3lu) at 0x%lx\n", page_to_phys(page),
176 "(prot: 0x%lx)\n", 175 page_to_pfn(page), this_color, addr);
177 page_to_phys(page), page_to_pfn(page), color,
178 page_count(page), PageLRU(page), addr,
179 pgprot_val(vma->vm_page_prot));
180 err = vm_insert_page(vma, addr, page); 176 err = vm_insert_page(vma, addr, page);
181 if (err) { 177 if (err) {
182 TRACE_CUR(ALLOC_NAME ": vm_insert_page() failed " 178 TRACE_CUR(ALLOC_NAME ": vm_insert_page() failed "