aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/litmus.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/litmus.c')
-rw-r--r--litmus/litmus.c111
1 files changed, 28 insertions, 83 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c
index 90e21eeadabb..400fd1472705 100644
--- a/litmus/litmus.c
+++ b/litmus/litmus.c
@@ -37,9 +37,6 @@
37#include <trace/events/litmus.h> 37#include <trace/events/litmus.h>
38#endif 38#endif
39 39
40//#define TRACE(fmt, args...) do {} while (false)
41//#define TRACE_TASK(fmt, args...) do {} while (false)
42
43extern void l2c310_flush_all(void); 40extern void l2c310_flush_all(void);
44 41
45/* Number of RT tasks that exist in the system */ 42/* Number of RT tasks that exist in the system */
@@ -354,12 +351,24 @@ extern int isolate_lru_page(struct page *page);
354extern void putback_movable_page(struct page *page); 351extern void putback_movable_page(struct page *page);
355extern struct page *new_alloc_page(struct page *page, unsigned long node, int **x); 352extern struct page *new_alloc_page(struct page *page, unsigned long node, int **x);
356 353
354/*
355 * sys_set_page_color
356 * @cpu: CPU number to assign page colors.
357 * Syscall for recoloring pages
358 * Returns -1 on error.
359 * N on success. N is the number of pages that could not
360 * be moved. A return of zero means that all pages
361 * were successfully moved. Currently, two pages
362 * cannot be moved, signal handler and litmus ctrl
363 * pages.
364 * Only mc2 tasks may be configured with this system call.
365 * Use static linking to isolate all pages.
366 */
357asmlinkage long sys_set_page_color(int cpu) 367asmlinkage long sys_set_page_color(int cpu)
358{ 368{
359 long ret = 0; 369 long ret = 0;
360 //struct page *page_itr = NULL;
361 struct vm_area_struct *vma_itr = NULL; 370 struct vm_area_struct *vma_itr = NULL;
362 int nr_pages = 0, nr_shared_pages = 0, nr_failed = 0, nr_not_migrated = 0; 371 int nr_pages = 0, nr_failed = 0, nr_not_migrated = 0;
363 unsigned long node; 372 unsigned long node;
364 enum crit_level lv; 373 enum crit_level lv;
365 struct mm_struct *mm; 374 struct mm_struct *mm;
@@ -375,19 +384,13 @@ asmlinkage long sys_set_page_color(int cpu)
375 mm = get_task_mm(current); 384 mm = get_task_mm(current);
376 put_task_struct(current); 385 put_task_struct(current);
377 386
378 //down_read(&current->mm->mmap_sem);
379 down_read(&mm->mmap_sem); 387 down_read(&mm->mmap_sem);
380 //TRACE_TASK(current, "SYSCALL set_page_color\n");
381 vma_itr = mm->mmap; 388 vma_itr = mm->mmap;
382 while (vma_itr != NULL) { 389 while (vma_itr != NULL) {
383 unsigned int num_pages = 0, i; 390 unsigned int num_pages = 0, i;
384 struct page *old_page = NULL; 391 struct page *old_page = NULL;
385 392
386 num_pages = (vma_itr->vm_end - vma_itr->vm_start) / PAGE_SIZE; 393 num_pages = (vma_itr->vm_end - vma_itr->vm_start) / PAGE_SIZE;
387 // print vma flags
388 //printk(KERN_INFO "flags: 0x%lx\n", vma_itr->vm_flags);
389 //printk(KERN_INFO "start - end: 0x%lx - 0x%lx (%lu)\n", vma_itr->vm_start, vma_itr->vm_end, (vma_itr->vm_end - vma_itr->vm_start)/PAGE_SIZE);
390 //printk(KERN_INFO "vm_page_prot: 0x%lx\n", vma_itr->vm_page_prot);
391 for (i = 0; i < num_pages; i++) { 394 for (i = 0; i < num_pages; i++) {
392 old_page = follow_page(vma_itr, vma_itr->vm_start + PAGE_SIZE*i, FOLL_GET|FOLL_SPLIT); 395 old_page = follow_page(vma_itr, vma_itr->vm_start + PAGE_SIZE*i, FOLL_GET|FOLL_SPLIT);
393 396
@@ -401,30 +404,15 @@ asmlinkage long sys_set_page_color(int cpu)
401 put_page(old_page); 404 put_page(old_page);
402 continue; 405 continue;
403 } 406 }
404 407 ret = isolate_lru_page(old_page);
405 //TRACE_TASK(current, "addr: %08x, pfn: %x, _mapcount: %d, _count: %d\n", vma_itr->vm_start + PAGE_SIZE*i, __page_to_pfn(old_page), page_mapcount(old_page), page_count(old_page)); 408 if (!ret) {
406 409 list_add_tail(&old_page->lru, &pagelist);
407 //if (page_mapcount(old_page) == 1) { 410 inc_zone_page_state(old_page, NR_ISOLATED_ANON + !PageSwapBacked(old_page));
408 ret = isolate_lru_page(old_page); 411 nr_pages++;
409 if (!ret) { 412 } else {
410 list_add_tail(&old_page->lru, &pagelist); 413 nr_failed++;
411 inc_zone_page_state(old_page, NR_ISOLATED_ANON + !PageSwapBacked(old_page));
412 nr_pages++;
413 } else {
414 //TRACE_TASK(current, "isolate_lru_page failed\n");
415 //TRACE_TASK(current, "page_lru = %d PageLRU = %d\n", page_lru(old_page), PageLRU(old_page));
416 nr_failed++;
417 }
418 //printk(KERN_INFO "PRIVATE _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page));
419 put_page(old_page);
420 //}
421 /*
422 else {
423 nr_shared_pages++;
424 //printk(KERN_INFO "SHARED _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page));
425 put_page(old_page);
426 } 414 }
427 */ 415 put_page(old_page);
428 } 416 }
429 417
430 vma_itr = vma_itr->vm_next; 418 vma_itr = vma_itr->vm_next;
@@ -434,7 +422,7 @@ asmlinkage long sys_set_page_color(int cpu)
434 if (tsk_rt(current)->mc2_data) 422 if (tsk_rt(current)->mc2_data)
435 lv = tsk_rt(current)->mc2_data->crit; 423 lv = tsk_rt(current)->mc2_data->crit;
436 else 424 else
437 BUG();//lv = 0; 425 BUG(); //lv = 0;
438 426
439 if (cpu == -1) 427 if (cpu == -1)
440 node = 8; 428 node = 8;
@@ -444,34 +432,16 @@ asmlinkage long sys_set_page_color(int cpu)
444 if (!list_empty(&pagelist)) { 432 if (!list_empty(&pagelist)) {
445 ret = migrate_pages(&pagelist, new_alloc_page, NULL, node, MIGRATE_SYNC, MR_SYSCALL); 433 ret = migrate_pages(&pagelist, new_alloc_page, NULL, node, MIGRATE_SYNC, MR_SYSCALL);
446 TRACE_TASK(current, "%ld pages not migrated.\n", ret); 434 TRACE_TASK(current, "%ld pages not migrated.\n", ret);
447 printk(KERN_INFO "%ld pages not migrated.\n", ret);
448 nr_not_migrated = ret; 435 nr_not_migrated = ret;
449 if (ret) { 436 if (ret) {
450 putback_movable_pages(&pagelist); 437 putback_movable_pages(&pagelist);
451 } 438 }
452 } 439 }
453 440
454 /* handle sigpage and litmus ctrl_page */
455/* vma_itr = current->mm->mmap;
456 while (vma_itr != NULL) {
457 if (vma_itr->vm_start == tsk_rt(current)->addr_ctrl_page) {
458 TRACE("litmus ctrl_page = %08x\n", vma_itr->vm_start);
459 vma_itr->vm_page_prot = PAGE_SHARED;
460 break;
461 }
462 vma_itr = vma_itr->vm_next;
463 }
464*/
465 up_read(&mm->mmap_sem); 441 up_read(&mm->mmap_sem);
466 442
467/* 443 TRACE_TASK(current, "node = %ld, nr_migrated_pages = %d, nr_pages = %d nr_failed = %d\n", node, nr_pages-nr_not_migrated, nr_pages, nr_failed);
468 list_for_each_entry(page_itr, &shared_pagelist, lru) { 444
469 TRACE("S Anon=%d, pfn = %lu, _mapcount = %d, _count = %d\n", PageAnon(page_itr), __page_to_pfn(page_itr), page_mapcount(page_itr), page_count(page_itr));
470 }
471*/
472 TRACE_TASK(current, "nr_pages = %d nr_failed = %d\n", nr_pages, nr_failed);
473 printk(KERN_INFO "node = %ld, nr_migrated_pages = %d, nr_shared_pages = %d, nr_failed = %d\n", node, nr_pages-nr_not_migrated, nr_failed-2, nr_failed);
474 //printk(KERN_INFO "node = %d\n", cpu_to_node(smp_processor_id()));
475 return ret; 445 return ret;
476} 446}
477 447
@@ -479,12 +449,12 @@ asmlinkage long sys_set_page_color(int cpu)
479asmlinkage long sys_test_call(unsigned int param) 449asmlinkage long sys_test_call(unsigned int param)
480{ 450{
481 long ret = 0; 451 long ret = 0;
482 unsigned long flags;
483 struct vm_area_struct *vma_itr = NULL; 452 struct vm_area_struct *vma_itr = NULL;
484 453
485 TRACE_CUR("test_call param = %d\n", param); 454 TRACE_CUR("test_call param = %d\n", param);
486 455
487 if (param == 0) { 456 if (param == 0) {
457 /* Print page information */
488 down_read(&current->mm->mmap_sem); 458 down_read(&current->mm->mmap_sem);
489 vma_itr = current->mm->mmap; 459 vma_itr = current->mm->mmap;
490 while (vma_itr != NULL) { 460 while (vma_itr != NULL) {
@@ -494,37 +464,12 @@ asmlinkage long sys_test_call(unsigned int param)
494 printk(KERN_INFO "vm_flags : %lx\n", vma_itr->vm_flags); 464 printk(KERN_INFO "vm_flags : %lx\n", vma_itr->vm_flags);
495 printk(KERN_INFO "vm_prot : %x\n", pgprot_val(vma_itr->vm_page_prot)); 465 printk(KERN_INFO "vm_prot : %x\n", pgprot_val(vma_itr->vm_page_prot));
496 printk(KERN_INFO "VM_SHARED? %ld\n", vma_itr->vm_flags & VM_SHARED); 466 printk(KERN_INFO "VM_SHARED? %ld\n", vma_itr->vm_flags & VM_SHARED);
497 /* if (vma_itr->vm_file) {
498 struct file *fp = vma_itr->vm_file;
499 unsigned long fcount = atomic_long_read(&(fp->f_count));
500 printk(KERN_INFO "f_count : %ld\n", fcount);
501 if (fcount > 1) {
502 vma_itr->vm_page_prot = pgprot_noncached(vma_itr->vm_page_prot);
503 }
504 }
505 printk(KERN_INFO "vm_prot2 : %x\n", pgprot_val(vma_itr->vm_page_prot));
506 */
507 vma_itr = vma_itr->vm_next; 467 vma_itr = vma_itr->vm_next;
508 } 468 }
509 printk(KERN_INFO "--------------------------------------------\n"); 469 printk(KERN_INFO "--------------------------------------------\n");
510 up_read(&current->mm->mmap_sem); 470 up_read(&current->mm->mmap_sem);
511
512 local_irq_save(flags);
513 l2c310_flush_all();
514 local_irq_restore(flags);
515 }
516 else if (param == 1) {
517 int i;
518 for (i = 0; i < 4; i++) {
519 lock_cache(i, 0x00003fff);
520 }
521 }
522 else if (param == 2) {
523 int i;
524 for (i = 0; i < 4; i++) {
525 lock_cache(i, 0xffffffff);
526 }
527 } 471 }
472
528 return ret; 473 return ret;
529} 474}
530 475