aboutsummaryrefslogtreecommitdiffstats
path: root/litmus
diff options
context:
space:
mode:
authorNamhoon Kim <namhoonk@cs.unc.edu>2016-03-31 14:53:23 -0400
committerNamhoon Kim <namhoonk@cs.unc.edu>2016-03-31 14:53:23 -0400
commit95d1cb634561b6716e6909b956d12177e508c1b0 (patch)
treef03dd5e4b87d84c14ed50e43b1c8cc2646959593 /litmus
parenta0039b91f779ab88e3c9acd6a2f237e24001c1e9 (diff)
Add syscall defs.
Diffstat (limited to 'litmus')
-rw-r--r--litmus/litmus.c156
1 files changed, 155 insertions, 1 deletions
diff --git a/litmus/litmus.c b/litmus/litmus.c
index 27efb22d1d2f..6d5f317e7537 100644
--- a/litmus/litmus.c
+++ b/litmus/litmus.c
@@ -14,6 +14,10 @@
14#include <linux/sched/rt.h> 14#include <linux/sched/rt.h>
15#include <linux/rwsem.h> 15#include <linux/rwsem.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/migrate.h>
18#include <linux/mm.h>
19#include <linux/memcontrol.h>
20#include <linux/mm_inline.h>
17 21
18#include <litmus/litmus.h> 22#include <litmus/litmus.h>
19#include <litmus/bheap.h> 23#include <litmus/bheap.h>
@@ -21,6 +25,8 @@
21#include <litmus/rt_domain.h> 25#include <litmus/rt_domain.h>
22#include <litmus/litmus_proc.h> 26#include <litmus/litmus_proc.h>
23#include <litmus/sched_trace.h> 27#include <litmus/sched_trace.h>
28#include <litmus/cache_proc.h>
29#include <litmus/mc2_common.h>
24 30
25#ifdef CONFIG_SCHED_CPU_AFFINITY 31#ifdef CONFIG_SCHED_CPU_AFFINITY
26#include <litmus/affinity.h> 32#include <litmus/affinity.h>
@@ -316,6 +322,144 @@ asmlinkage long sys_null_call(cycles_t __user *ts)
316 return ret; 322 return ret;
317} 323}
318 324
325asmlinkage long sys_reservation_create(int type, void __user *config)
326{
327 return litmus->reservation_create(type, config);
328}
329
330asmlinkage long sys_reservation_destroy(unsigned int reservation_id, int cpu)
331{
332 return litmus->reservation_destroy(reservation_id, cpu);
333}
334
335static unsigned long color_mask;
336
337static inline unsigned long page_color(struct page *page)
338{
339 return ((page_to_phys(page) & color_mask) >> PAGE_SHIFT);
340}
341
342extern int isolate_lru_page(struct page *page);
343extern void putback_movable_page(struct page *page);
344extern struct page *new_alloc_page(struct page *page, unsigned long node, int **x);
345
346asmlinkage long sys_set_page_color(int cpu)
347{
348 long ret = 0;
349 //struct page *page_itr = NULL;
350 struct vm_area_struct *vma_itr = NULL;
351 int nr_pages = 0, nr_shared_pages = 0, nr_failed = 0;
352 unsigned long node;
353 enum crit_level lv;
354
355 LIST_HEAD(pagelist);
356 LIST_HEAD(shared_pagelist);
357
358
359 down_read(&current->mm->mmap_sem);
360 TRACE_TASK(current, "SYSCALL set_page_color\n");
361 vma_itr = current->mm->mmap;
362 while (vma_itr != NULL) {
363 unsigned int num_pages = 0, i;
364 struct page *old_page = NULL;
365
366 num_pages = (vma_itr->vm_end - vma_itr->vm_start) / PAGE_SIZE;
367 // print vma flags
368 //printk(KERN_INFO "flags: 0x%lx\n", vma_itr->vm_flags);
369 //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);
370 //printk(KERN_INFO "vm_page_prot: 0x%lx\n", vma_itr->vm_page_prot);
371
372 for (i = 0; i < num_pages; i++) {
373 old_page = follow_page(vma_itr, vma_itr->vm_start + PAGE_SIZE*i, FOLL_GET|FOLL_SPLIT);
374
375 if (IS_ERR(old_page))
376 continue;
377 if (!old_page)
378 continue;
379
380 if (PageReserved(old_page)) {
381 TRACE("Reserved Page!\n");
382 put_page(old_page);
383 continue;
384 }
385
386 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));
387
388 if (page_mapcount(old_page) == 1) {
389 ret = isolate_lru_page(old_page);
390 if (!ret) {
391 list_add_tail(&old_page->lru, &pagelist);
392 inc_zone_page_state(old_page, NR_ISOLATED_ANON + !PageSwapBacked(old_page));
393 nr_pages++;
394 } else {
395 TRACE_TASK(current, "isolate_lru_page failed\n");
396 TRACE_TASK(current, "page_lru = %d PageLRU = %d\n", page_lru(old_page), PageLRU(old_page));
397 nr_failed++;
398 }
399 //printk(KERN_INFO "PRIVATE _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page));
400 put_page(old_page);
401 }
402 else {
403 nr_shared_pages++;
404 //printk(KERN_INFO "SHARED _mapcount = %d, _count = %d\n", page_mapcount(old_page), page_count(old_page));
405 put_page(old_page);
406 }
407 }
408
409 vma_itr = vma_itr->vm_next;
410 }
411
412 //list_for_each_entry(page_itr, &pagelist, lru) {
413// printk(KERN_INFO "B _mapcount = %d, _count = %d\n", page_mapcount(page_itr), page_count(page_itr));
414// }
415
416 ret = 0;
417 if (!is_realtime(current))
418 lv = 1;
419 else {
420 lv = tsk_rt(current)->mc2_data->crit;
421 }
422
423 if (cpu == -1)
424 node = 8;
425 else
426 node = cpu*2 + lv;
427 //node= 0;
428
429 if (!list_empty(&pagelist)) {
430 ret = migrate_pages(&pagelist, new_alloc_page, NULL, node, MIGRATE_ASYNC, MR_SYSCALL);
431 TRACE_TASK(current, "%ld pages not migrated.\n", ret);
432 if (ret) {
433 putback_movable_pages(&pagelist);
434 }
435 }
436
437 /* handle sigpage and litmus ctrl_page */
438/* vma_itr = current->mm->mmap;
439 while (vma_itr != NULL) {
440 if (vma_itr->vm_start == tsk_rt(current)->addr_ctrl_page) {
441 TRACE("litmus ctrl_page = %08x\n", vma_itr->vm_start);
442 vma_itr->vm_page_prot = PAGE_SHARED;
443 break;
444 }
445 vma_itr = vma_itr->vm_next;
446 }
447*/
448 up_read(&current->mm->mmap_sem);
449
450/*
451 list_for_each_entry(page_itr, &shared_pagelist, lru) {
452 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));
453 }
454*/
455 TRACE_TASK(current, "nr_pages = %d nr_failed = %d\n", nr_pages, nr_failed);
456 printk(KERN_INFO "node = %ld, nr_pages = %d, nr_shared_pages = %d, nr_failed = %d\n", node, nr_pages, nr_shared_pages, nr_failed);
457 //printk(KERN_INFO "node = %d\n", cpu_to_node(smp_processor_id()));
458 flush_cache(1);
459
460 return ret;
461}
462
319/* sys_test_call() is a test system call for developing */ 463/* sys_test_call() is a test system call for developing */
320asmlinkage long sys_test_call(unsigned int param) 464asmlinkage long sys_test_call(unsigned int param)
321{ 465{
@@ -690,6 +834,12 @@ static int __init _init_litmus(void)
690 * mode change lock is used to enforce single mode change 834 * mode change lock is used to enforce single mode change
691 * operation. 835 * operation.
692 */ 836 */
837#if defined(CONFIG_CPU_V7)
838 unsigned int line_size_log = 5; // 2^5 = 32 byte
839 unsigned int cache_info_sets = 2048; // 64KB (way_size) / 32B (line_size) = 2048
840 printk("LITMIS^RT-ARM kernel\n");
841#endif
842
693 printk("Starting LITMUS^RT kernel\n"); 843 printk("Starting LITMUS^RT kernel\n");
694 844
695 register_sched_plugin(&linux_sched_plugin); 845 register_sched_plugin(&linux_sched_plugin);
@@ -704,11 +854,15 @@ static int __init _init_litmus(void)
704 else 854 else
705 printk("Could not register kill rt tasks magic sysrq.\n"); 855 printk("Could not register kill rt tasks magic sysrq.\n");
706#endif 856#endif
707
708 init_litmus_proc(); 857 init_litmus_proc();
709 858
710 register_reboot_notifier(&shutdown_notifier); 859 register_reboot_notifier(&shutdown_notifier);
711 860
861#if defined(CONFIG_CPU_V7)
862 color_mask = ((cache_info_sets << line_size_log) - 1) ^ (PAGE_SIZE - 1);
863 printk("Page color mask %lx\n", color_mask);
864#endif
865
712 return 0; 866 return 0;
713} 867}
714 868