diff options
Diffstat (limited to 'litmus/litmus.c')
-rw-r--r-- | litmus/litmus.c | 95 |
1 files changed, 60 insertions, 35 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c index 0f122e1e7ec1..ddb80e1aae12 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c | |||
@@ -356,17 +356,26 @@ asmlinkage long sys_set_page_color(int cpu) | |||
356 | long ret = 0; | 356 | long ret = 0; |
357 | //struct page *page_itr = NULL; | 357 | //struct page *page_itr = NULL; |
358 | struct vm_area_struct *vma_itr = NULL; | 358 | struct vm_area_struct *vma_itr = NULL; |
359 | int nr_pages = 0, nr_shared_pages = 0, nr_failed = 0; | 359 | int nr_pages = 0, nr_shared_pages = 0, nr_failed = 0, nr_not_migrated = 0; |
360 | unsigned long node; | 360 | unsigned long node; |
361 | enum crit_level lv; | 361 | enum crit_level lv; |
362 | struct mm_struct *mm; | ||
362 | 363 | ||
363 | LIST_HEAD(pagelist); | 364 | LIST_HEAD(pagelist); |
364 | LIST_HEAD(shared_pagelist); | 365 | LIST_HEAD(shared_pagelist); |
365 | 366 | ||
367 | migrate_prep(); | ||
366 | 368 | ||
367 | down_read(¤t->mm->mmap_sem); | 369 | rcu_read_lock(); |
370 | get_task_struct(current); | ||
371 | rcu_read_unlock(); | ||
372 | mm = get_task_mm(current); | ||
373 | put_task_struct(current); | ||
374 | |||
375 | //down_read(¤t->mm->mmap_sem); | ||
376 | down_read(&mm->mmap_sem); | ||
368 | TRACE_TASK(current, "SYSCALL set_page_color\n"); | 377 | TRACE_TASK(current, "SYSCALL set_page_color\n"); |
369 | vma_itr = current->mm->mmap; | 378 | vma_itr = mm->mmap; |
370 | while (vma_itr != NULL) { | 379 | while (vma_itr != NULL) { |
371 | unsigned int num_pages = 0, i; | 380 | unsigned int num_pages = 0, i; |
372 | struct page *old_page = NULL; | 381 | struct page *old_page = NULL; |
@@ -376,7 +385,6 @@ asmlinkage long sys_set_page_color(int cpu) | |||
376 | //printk(KERN_INFO "flags: 0x%lx\n", vma_itr->vm_flags); | 385 | //printk(KERN_INFO "flags: 0x%lx\n", vma_itr->vm_flags); |
377 | //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); | 386 | //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); |
378 | //printk(KERN_INFO "vm_page_prot: 0x%lx\n", vma_itr->vm_page_prot); | 387 | //printk(KERN_INFO "vm_page_prot: 0x%lx\n", vma_itr->vm_page_prot); |
379 | |||
380 | for (i = 0; i < num_pages; i++) { | 388 | for (i = 0; i < num_pages; i++) { |
381 | old_page = follow_page(vma_itr, vma_itr->vm_start + PAGE_SIZE*i, FOLL_GET|FOLL_SPLIT); | 389 | old_page = follow_page(vma_itr, vma_itr->vm_start + PAGE_SIZE*i, FOLL_GET|FOLL_SPLIT); |
382 | 390 | ||
@@ -393,7 +401,7 @@ asmlinkage long sys_set_page_color(int cpu) | |||
393 | 401 | ||
394 | 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)); | 402 | 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)); |
395 | 403 | ||
396 | if (page_mapcount(old_page) == 1) { | 404 | //if (page_mapcount(old_page) == 1) { |
397 | ret = isolate_lru_page(old_page); | 405 | ret = isolate_lru_page(old_page); |
398 | if (!ret) { | 406 | if (!ret) { |
399 | list_add_tail(&old_page->lru, &pagelist); | 407 | list_add_tail(&old_page->lru, &pagelist); |
@@ -406,12 +414,14 @@ asmlinkage long sys_set_page_color(int cpu) | |||
406 | } | 414 | } |
407 | //printk(KERN_INFO "PRIVATE _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page)); | 415 | //printk(KERN_INFO "PRIVATE _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page)); |
408 | put_page(old_page); | 416 | put_page(old_page); |
409 | } | 417 | //} |
418 | /* | ||
410 | else { | 419 | else { |
411 | nr_shared_pages++; | 420 | nr_shared_pages++; |
412 | //printk(KERN_INFO "SHARED _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page)); | 421 | //printk(KERN_INFO "SHARED _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page)); |
413 | put_page(old_page); | 422 | put_page(old_page); |
414 | } | 423 | } |
424 | */ | ||
415 | } | 425 | } |
416 | 426 | ||
417 | vma_itr = vma_itr->vm_next; | 427 | vma_itr = vma_itr->vm_next; |
@@ -432,11 +442,12 @@ asmlinkage long sys_set_page_color(int cpu) | |||
432 | node = 8; | 442 | node = 8; |
433 | else | 443 | else |
434 | node = cpu*2 + lv; | 444 | node = cpu*2 + lv; |
435 | //node= 0; | ||
436 | 445 | ||
437 | if (!list_empty(&pagelist)) { | 446 | if (!list_empty(&pagelist)) { |
438 | ret = migrate_pages(&pagelist, new_alloc_page, NULL, node, MIGRATE_ASYNC, MR_SYSCALL); | 447 | ret = migrate_pages(&pagelist, new_alloc_page, NULL, node, MIGRATE_SYNC, MR_SYSCALL); |
439 | TRACE_TASK(current, "%ld pages not migrated.\n", ret); | 448 | TRACE_TASK(current, "%ld pages not migrated.\n", ret); |
449 | printk(KERN_INFO "%ld pages not migrated.\n", ret); | ||
450 | nr_not_migrated = ret; | ||
440 | if (ret) { | 451 | if (ret) { |
441 | putback_movable_pages(&pagelist); | 452 | putback_movable_pages(&pagelist); |
442 | } | 453 | } |
@@ -453,7 +464,7 @@ asmlinkage long sys_set_page_color(int cpu) | |||
453 | vma_itr = vma_itr->vm_next; | 464 | vma_itr = vma_itr->vm_next; |
454 | } | 465 | } |
455 | */ | 466 | */ |
456 | up_read(¤t->mm->mmap_sem); | 467 | up_read(&mm->mmap_sem); |
457 | 468 | ||
458 | /* | 469 | /* |
459 | list_for_each_entry(page_itr, &shared_pagelist, lru) { | 470 | list_for_each_entry(page_itr, &shared_pagelist, lru) { |
@@ -461,7 +472,7 @@ asmlinkage long sys_set_page_color(int cpu) | |||
461 | } | 472 | } |
462 | */ | 473 | */ |
463 | TRACE_TASK(current, "nr_pages = %d nr_failed = %d\n", nr_pages, nr_failed); | 474 | TRACE_TASK(current, "nr_pages = %d nr_failed = %d\n", nr_pages, nr_failed); |
464 | printk(KERN_INFO "node = %ld, nr_pages = %d, nr_shared_pages = %d, nr_failed = %d\n", node, nr_pages, nr_shared_pages, nr_failed); | 475 | 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); |
465 | //printk(KERN_INFO "node = %d\n", cpu_to_node(smp_processor_id())); | 476 | //printk(KERN_INFO "node = %d\n", cpu_to_node(smp_processor_id())); |
466 | flush_cache(1); | 477 | flush_cache(1); |
467 | 478 | ||
@@ -477,34 +488,48 @@ asmlinkage long sys_test_call(unsigned int param) | |||
477 | 488 | ||
478 | TRACE_CUR("test_call param = %d\n", param); | 489 | TRACE_CUR("test_call param = %d\n", param); |
479 | 490 | ||
480 | down_read(¤t->mm->mmap_sem); | 491 | if (param == 0) { |
481 | vma_itr = current->mm->mmap; | 492 | down_read(¤t->mm->mmap_sem); |
482 | while (vma_itr != NULL) { | 493 | vma_itr = current->mm->mmap; |
483 | printk(KERN_INFO "--------------------------------------------\n"); | 494 | while (vma_itr != NULL) { |
484 | printk(KERN_INFO "vm_start : %lx\n", vma_itr->vm_start); | 495 | printk(KERN_INFO "--------------------------------------------\n"); |
485 | printk(KERN_INFO "vm_end : %lx\n", vma_itr->vm_end); | 496 | printk(KERN_INFO "vm_start : %lx\n", vma_itr->vm_start); |
486 | printk(KERN_INFO "vm_flags : %lx\n", vma_itr->vm_flags); | 497 | printk(KERN_INFO "vm_end : %lx\n", vma_itr->vm_end); |
487 | printk(KERN_INFO "vm_prot : %x\n", pgprot_val(vma_itr->vm_page_prot)); | 498 | printk(KERN_INFO "vm_flags : %lx\n", vma_itr->vm_flags); |
488 | printk(KERN_INFO "VM_SHARED? %ld\n", vma_itr->vm_flags & VM_SHARED); | 499 | printk(KERN_INFO "vm_prot : %x\n", pgprot_val(vma_itr->vm_page_prot)); |
489 | /* if (vma_itr->vm_file) { | 500 | printk(KERN_INFO "VM_SHARED? %ld\n", vma_itr->vm_flags & VM_SHARED); |
490 | struct file *fp = vma_itr->vm_file; | 501 | /* if (vma_itr->vm_file) { |
491 | unsigned long fcount = atomic_long_read(&(fp->f_count)); | 502 | struct file *fp = vma_itr->vm_file; |
492 | printk(KERN_INFO "f_count : %ld\n", fcount); | 503 | unsigned long fcount = atomic_long_read(&(fp->f_count)); |
493 | if (fcount > 1) { | 504 | printk(KERN_INFO "f_count : %ld\n", fcount); |
494 | vma_itr->vm_page_prot = pgprot_noncached(vma_itr->vm_page_prot); | 505 | if (fcount > 1) { |
506 | vma_itr->vm_page_prot = pgprot_noncached(vma_itr->vm_page_prot); | ||
507 | } | ||
495 | } | 508 | } |
509 | printk(KERN_INFO "vm_prot2 : %x\n", pgprot_val(vma_itr->vm_page_prot)); | ||
510 | */ | ||
511 | vma_itr = vma_itr->vm_next; | ||
512 | } | ||
513 | printk(KERN_INFO "--------------------------------------------\n"); | ||
514 | up_read(¤t->mm->mmap_sem); | ||
515 | |||
516 | local_irq_save(flags); | ||
517 | l2c310_flush_all(); | ||
518 | local_irq_restore(flags); | ||
519 | } | ||
520 | else if (param == 1) { | ||
521 | int i; | ||
522 | flush_cache(1); | ||
523 | for (i = 0; i < 4; i++) { | ||
524 | lock_cache(i, 0x00003fff); | ||
525 | } | ||
526 | } | ||
527 | else if (param == 2) { | ||
528 | int i; | ||
529 | for (i = 0; i < 4; i++) { | ||
530 | lock_cache(i, 0xffffffff); | ||
496 | } | 531 | } |
497 | printk(KERN_INFO "vm_prot2 : %x\n", pgprot_val(vma_itr->vm_page_prot)); | ||
498 | */ | ||
499 | vma_itr = vma_itr->vm_next; | ||
500 | } | 532 | } |
501 | printk(KERN_INFO "--------------------------------------------\n"); | ||
502 | up_read(¤t->mm->mmap_sem); | ||
503 | |||
504 | local_irq_save(flags); | ||
505 | l2c310_flush_all(); | ||
506 | local_irq_restore(flags); | ||
507 | |||
508 | return ret; | 533 | return ret; |
509 | } | 534 | } |
510 | 535 | ||