aboutsummaryrefslogtreecommitdiffstats
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
parenta0039b91f779ab88e3c9acd6a2f237e24001c1e9 (diff)
Add syscall defs.
-rw-r--r--arch/arm/kernel/calls.S6
-rw-r--r--arch/x86/syscalls/syscall_32.tbl6
-rw-r--r--arch/x86/syscalls/syscall_64.tbl6
-rw-r--r--include/litmus/unistd_32.h8
-rw-r--r--litmus/litmus.c156
5 files changed, 176 insertions, 6 deletions
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index a272b84a2fe7..6c2ad82fd2c8 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -410,7 +410,11 @@
410 CALL(sys_release_ts) 410 CALL(sys_release_ts)
411 CALL(sys_null_call) 411 CALL(sys_null_call)
412/* 400 */ CALL(sys_get_current_budget) 412/* 400 */ CALL(sys_get_current_budget)
413 CALL(sys_test_call) 413 CALL(sys_reservation_create)
414 CALL(sys_reservation_destroy)
415 CALL(sys_set_mc2_task_param)
416 CALL(sys_set_page_color)
417/* 405 */ CALL(sys_test_call)
414 418
415 419
416#ifndef syscalls_counted 420#ifndef syscalls_counted
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl
index af5e3ccf8b31..075709a93d34 100644
--- a/arch/x86/syscalls/syscall_32.tbl
+++ b/arch/x86/syscalls/syscall_32.tbl
@@ -378,4 +378,8 @@
378369 i386 release_ts sys_release_ts 378369 i386 release_ts sys_release_ts
379370 i386 null_call sys_null_call 379370 i386 null_call sys_null_call
380371 i386 get_current_budget sys_get_current_budget 380371 i386 get_current_budget sys_get_current_budget
381372 i386 test_call sys_test_call \ No newline at end of file 381372 i386 reservation_create sys_reservation_create
382373 i386 reservation_destroy sys_reservation_destroy
383374 i386 set_mc2_task_param sys_set_mc2_task_param
384375 i386 set_page_color sys_set_page_color
385376 i386 test_call sys_test_call
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
index e87042d413e9..e8fdeecd3d21 100644
--- a/arch/x86/syscalls/syscall_64.tbl
+++ b/arch/x86/syscalls/syscall_64.tbl
@@ -343,7 +343,11 @@
343361 common release_ts sys_release_ts 343361 common release_ts sys_release_ts
344362 common null_call sys_null_call 344362 common null_call sys_null_call
345363 common get_current_budget sys_get_current_budget 345363 common get_current_budget sys_get_current_budget
346364 common test_call sys_test_call 346364 common reservation_create sys_reservation_create
347365 common reservation_destroy sys_reservation_destroy
348366 common set_mc2_task_param sys_set_mc2_task_param
349367 common set_page_color sys_set_page_color
350368 common test_call sys_test_call
347 351
348 352
349# 353#
diff --git a/include/litmus/unistd_32.h b/include/litmus/unistd_32.h
index 43527ee2f6b6..0000010f7d95 100644
--- a/include/litmus/unistd_32.h
+++ b/include/litmus/unistd_32.h
@@ -18,6 +18,10 @@
18#define __NR_release_ts __LSC(10) 18#define __NR_release_ts __LSC(10)
19#define __NR_null_call __LSC(11) 19#define __NR_null_call __LSC(11)
20#define __NR_get_current_budget __LSC(12) 20#define __NR_get_current_budget __LSC(12)
21#define __NR_test_call __LSC(13) 21#define __NR_reservation_create __LSC(13)
22#define __NR_reservation_destroy __LSC(14)
23#define __NR_set_mc2_task_param __LSC(15)
24#define __NR_set_page_color __LSC(16)
25#define __NR_test_call __LSC(17)
22 26
23#define NR_litmus_syscalls 14 27#define NR_litmus_syscalls 18
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