diff options
author | Namhoon Kim <namhoonk@cs.unc.edu> | 2016-04-30 16:51:39 -0400 |
---|---|---|
committer | Namhoon Kim <namhoonk@cs.unc.edu> | 2016-04-30 16:51:39 -0400 |
commit | 06a7bbe199c51599622b555faad6019f5fb104a9 (patch) | |
tree | eff8661a416fd0d4a702c91a91dfc3f67bb71c4b | |
parent | d23393fdd12fd8fdc340c5a41241a4caa1bdfbf4 (diff) |
Add benchmark system call for RTSS16 paper
-rw-r--r-- | arch/arm/include/asm/unistd.h | 2 | ||||
-rw-r--r-- | arch/arm/kernel/calls.S | 1 | ||||
-rw-r--r-- | arch/x86/syscalls/syscall_32.tbl | 1 | ||||
-rw-r--r-- | arch/x86/syscalls/syscall_64.tbl | 1 | ||||
-rw-r--r-- | include/litmus/unistd_32.h | 3 | ||||
-rw-r--r-- | include/litmus/unistd_64.h | 4 | ||||
-rw-r--r-- | litmus/cache_proc.c | 111 |
7 files changed, 115 insertions, 8 deletions
diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h index 76613c47d4c3..d9b5e057d9bf 100644 --- a/arch/arm/include/asm/unistd.h +++ b/arch/arm/include/asm/unistd.h | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #include <uapi/asm/unistd.h> | 16 | #include <uapi/asm/unistd.h> |
17 | /** __NR_syscalls padding */ | 17 | /** __NR_syscalls padding */ |
18 | #define __NR_syscalls (380 + NR_litmus_syscalls + 3) | 18 | #define __NR_syscalls (380 + NR_litmus_syscalls + 2) |
19 | 19 | ||
20 | #define __ARM_NR_cmpxchg (__ARM_NR_BASE+0x00fff0) | 20 | #define __ARM_NR_cmpxchg (__ARM_NR_BASE+0x00fff0) |
21 | 21 | ||
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index 97b0c91ef12d..aa09a5d26cfc 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S | |||
@@ -406,6 +406,7 @@ | |||
406 | CALL(sys_set_mc2_task_param) | 406 | CALL(sys_set_mc2_task_param) |
407 | /* 395 */ CALL(sys_set_page_color) | 407 | /* 395 */ CALL(sys_set_page_color) |
408 | CALL(sys_run_test) | 408 | CALL(sys_run_test) |
409 | CALL(sys_lock_buffer) | ||
409 | 410 | ||
410 | #ifndef syscalls_counted | 411 | #ifndef syscalls_counted |
411 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls | 412 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls |
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl index c44bc0059cca..b73b7ff70499 100644 --- a/arch/x86/syscalls/syscall_32.tbl +++ b/arch/x86/syscalls/syscall_32.tbl | |||
@@ -375,3 +375,4 @@ | |||
375 | 365 i386 set_mc2_task_param sys_set_mc2_task_param | 375 | 365 i386 set_mc2_task_param sys_set_mc2_task_param |
376 | 366 i386 set_page_color sys_set_page_color | 376 | 366 i386 set_page_color sys_set_page_color |
377 | 367 i386 run_test sys_run_test | 377 | 367 i386 run_test sys_run_test |
378 | 368 i386 lock_buffer sys_lock_buffer | ||
diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl index 93895e3e4593..0cc2f5eb33ec 100644 --- a/arch/x86/syscalls/syscall_64.tbl +++ b/arch/x86/syscalls/syscall_64.tbl | |||
@@ -338,6 +338,7 @@ | |||
338 | 365 common set_mc2_task_param sys_set_mc2_task_param | 338 | 365 common set_mc2_task_param sys_set_mc2_task_param |
339 | 366 common set_page_color sys_set_page_color | 339 | 366 common set_page_color sys_set_page_color |
340 | 367 common run_test sys_run_test | 340 | 367 common run_test sys_run_test |
341 | 368 common lock_buffer sys_lock_buffer | ||
341 | 342 | ||
342 | # | 343 | # |
343 | # x32-specific system call numbers start at 512 to avoid cache impact | 344 | # x32-specific system call numbers start at 512 to avoid cache impact |
diff --git a/include/litmus/unistd_32.h b/include/litmus/unistd_32.h index ac8995fe508d..8585d51a12a7 100644 --- a/include/litmus/unistd_32.h +++ b/include/litmus/unistd_32.h | |||
@@ -22,5 +22,6 @@ | |||
22 | #define __NR_set_mc2_task_param __LSC(14) | 22 | #define __NR_set_mc2_task_param __LSC(14) |
23 | #define __NR_set_page_color __LSC(15) | 23 | #define __NR_set_page_color __LSC(15) |
24 | #define __NR_run_test __LSC(16) | 24 | #define __NR_run_test __LSC(16) |
25 | #define __NR_lock_buffer __LSC(17) | ||
25 | 26 | ||
26 | #define NR_litmus_syscalls 17 | 27 | #define NR_litmus_syscalls 18 |
diff --git a/include/litmus/unistd_64.h b/include/litmus/unistd_64.h index 69d97c8d49e0..49541f0f4174 100644 --- a/include/litmus/unistd_64.h +++ b/include/litmus/unistd_64.h | |||
@@ -39,5 +39,7 @@ __SYSCALL(__NR_set_mc2_task_param, sys_set_mc2_task_param) | |||
39 | __SYSCALL(__NR_set_page_color, sys_set_page_color) | 39 | __SYSCALL(__NR_set_page_color, sys_set_page_color) |
40 | #define __NR_run_test __LSC(16) | 40 | #define __NR_run_test __LSC(16) |
41 | __SYSCALL(__NR_run_test, sys_run_test) | 41 | __SYSCALL(__NR_run_test, sys_run_test) |
42 | #define __NR_lock_buffer __LSC(17) | ||
43 | __SYSCALL(__NR_lock_buffer, sys_lock_buffer) | ||
42 | 44 | ||
43 | #define NR_litmus_syscalls 17 | 45 | #define NR_litmus_syscalls 18 |
diff --git a/litmus/cache_proc.c b/litmus/cache_proc.c index 2e9327c9b469..3e47a35e2507 100644 --- a/litmus/cache_proc.c +++ b/litmus/cache_proc.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/io.h> | 9 | #include <linux/io.h> |
10 | #include <linux/mutex.h> | 10 | #include <linux/mutex.h> |
11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
12 | #include <linux/random.h> | ||
12 | 13 | ||
13 | #include <litmus/litmus_proc.h> | 14 | #include <litmus/litmus_proc.h> |
14 | #include <litmus/sched_trace.h> | 15 | #include <litmus/sched_trace.h> |
@@ -23,6 +24,14 @@ | |||
23 | #define LOCK_ALL (~UNLOCK_ALL) | 24 | #define LOCK_ALL (~UNLOCK_ALL) |
24 | #define MAX_NR_WAYS 16 | 25 | #define MAX_NR_WAYS 16 |
25 | #define MAX_NR_COLORS 16 | 26 | #define MAX_NR_COLORS 16 |
27 | #define CACHELINE_SIZE 32 | ||
28 | #define INTS_IN_CACHELINE (CACHELINE_SIZE/sizeof(int)) | ||
29 | #define CACHELINES_IN_1KB (1024 / sizeof(cacheline_t)) | ||
30 | |||
31 | typedef struct cacheline | ||
32 | { | ||
33 | int line[INTS_IN_CACHELINE]; | ||
34 | } __attribute__((aligned(CACHELINE_SIZE))) cacheline_t; | ||
26 | 35 | ||
27 | void mem_lock(u32 lock_val, int cpu); | 36 | void mem_lock(u32 lock_val, int cpu); |
28 | 37 | ||
@@ -161,6 +170,7 @@ int lock_all; | |||
161 | int nr_lockregs; | 170 | int nr_lockregs; |
162 | static raw_spinlock_t cache_lock; | 171 | static raw_spinlock_t cache_lock; |
163 | static raw_spinlock_t prefetch_lock; | 172 | static raw_spinlock_t prefetch_lock; |
173 | static raw_spinlock_t bench_lock; | ||
164 | static void ***flusher_pages = NULL; | 174 | static void ***flusher_pages = NULL; |
165 | 175 | ||
166 | extern void l2x0_flush_all(void); | 176 | extern void l2x0_flush_all(void); |
@@ -261,6 +271,7 @@ void litmus_setup_lockdown(void __iomem *base, u32 id) | |||
261 | mutex_init(&lockdown_proc); | 271 | mutex_init(&lockdown_proc); |
262 | raw_spin_lock_init(&cache_lock); | 272 | raw_spin_lock_init(&cache_lock); |
263 | raw_spin_lock_init(&prefetch_lock); | 273 | raw_spin_lock_init(&prefetch_lock); |
274 | raw_spin_lock_init(&bench_lock); | ||
264 | 275 | ||
265 | test_lockdown(NULL); | 276 | test_lockdown(NULL); |
266 | } | 277 | } |
@@ -972,30 +983,120 @@ void flush_cache(int all) | |||
972 | raw_spin_unlock_irqrestore(&cache_lock, flags); | 983 | raw_spin_unlock_irqrestore(&cache_lock, flags); |
973 | } | 984 | } |
974 | 985 | ||
975 | asmlinkage long sys_run_test(int type, size_t size, unsigned long vaddr, lt_t __user *ts) | 986 | /* src = shared, dst = local */ |
987 | #if 0 // random | ||
988 | asmlinkage long sys_run_test(int type, int size, cacheline_t *src, cacheline_t *dst, lt_t __user *ts) | ||
976 | { | 989 | { |
990 | /* size is in KB */ | ||
977 | long ret = 0; | 991 | long ret = 0; |
978 | lt_t t1, t2; | 992 | lt_t t1, t2; |
993 | int numlines = size * CACHELINES_IN_1KB; | ||
994 | int next, sum = 0, ran; | ||
995 | unsigned long flags; | ||
996 | |||
997 | get_random_bytes(&ran, sizeof(int)); | ||
998 | next = ran % ((size*1024)/sizeof(cacheline_t)); | ||
999 | |||
1000 | //preempt_disable(); | ||
1001 | if (type == 1) { | ||
1002 | int i, j; | ||
1003 | color_read_in_mem_lock(0x0000FFF0, 0x0000000f, (void*)src, (void*)src + size*1024); | ||
1004 | color_read_in_mem_lock(0x0000FF0F, 0x0000000f, (void*)dst, (void*)dst + size*1024); | ||
1005 | |||
1006 | local_irq_save(flags); | ||
1007 | t1 = litmus_clock(); | ||
1008 | for (i = 0; i < numlines; i++) { | ||
1009 | next = src[next].line[0]; | ||
1010 | for (j = 0; j < INTS_IN_CACHELINE; j++) { | ||
1011 | dst[next].line[j] = src[next].line[j]; // read | ||
1012 | //src[next].line[j] = dst[next].line[j]; // write | ||
1013 | } | ||
1014 | } | ||
1015 | t2 = litmus_clock(); | ||
1016 | local_irq_restore(flags); | ||
1017 | sum = next + (int)t2; | ||
1018 | t2 -= t1; | ||
1019 | ret = put_user(t2, ts); | ||
1020 | } | ||
1021 | else { | ||
1022 | int i, j; | ||
1023 | color_read_in_mem_lock(0x0000FF0F, 0x0000000f, (void*)dst, (void*)dst + size*1024); | ||
1024 | local_irq_save(flags); | ||
1025 | t1 = litmus_clock(); | ||
1026 | for (i = 0; i < numlines; i++) { | ||
1027 | next = src[next].line[0]; | ||
1028 | for (j = 0; j < INTS_IN_CACHELINE; j++) { | ||
1029 | dst[next].line[j] = src[next].line[j]; //read | ||
1030 | //src[next].line[j] = dst[next].line[j]; //write | ||
1031 | } | ||
1032 | } | ||
1033 | t2 = litmus_clock(); | ||
1034 | local_irq_restore(flags); | ||
1035 | sum = next + (int)t2; | ||
1036 | t2 -= t1; | ||
1037 | ret = put_user(t2, ts); | ||
1038 | v7_flush_kern_dcache_area(src, size*1024); | ||
1039 | } | ||
1040 | //preempt_enable(); | ||
1041 | flush_cache(1); | ||
979 | 1042 | ||
1043 | return ret; | ||
1044 | } | ||
1045 | #else | ||
1046 | // sequential | ||
1047 | asmlinkage long sys_run_test(int type, int size, cacheline_t *src, cacheline_t *dst, lt_t __user *ts) | ||
1048 | { | ||
1049 | /* size is in KB */ | ||
1050 | long ret = 0; | ||
1051 | lt_t t1, t2; | ||
1052 | int numlines = size * CACHELINES_IN_1KB; | ||
1053 | int sum = 0; | ||
1054 | unsigned long flags; | ||
1055 | |||
1056 | //preempt_disable(); | ||
980 | if (type == 1) { | 1057 | if (type == 1) { |
981 | color_read_in_mem_lock(nr_unlocked_way[4], LOCK_ALL, vaddr, vaddr + size); | 1058 | int i, j; |
1059 | color_read_in_mem_lock(0x0000FFF0, 0x0000000f, (void*)src, (void*)src + size*1024); | ||
1060 | color_read_in_mem_lock(0x0000FF0F, 0x0000000f, (void*)dst, (void*)dst + size*1024); | ||
1061 | |||
1062 | local_irq_save(flags); | ||
982 | t1 = litmus_clock(); | 1063 | t1 = litmus_clock(); |
983 | color_read_in_mem(LOCK_ALL, LOCK_ALL, vaddr, vaddr + size); | 1064 | for (i = 0; i < numlines; i++) { |
1065 | for (j = 0; j < INTS_IN_CACHELINE; j++) { | ||
1066 | //dst[i].line[j] = src[i].line[j]; // read | ||
1067 | src[i].line[j] = dst[i].line[j]; // write | ||
1068 | } | ||
1069 | } | ||
984 | t2 = litmus_clock(); | 1070 | t2 = litmus_clock(); |
1071 | local_irq_restore(flags); | ||
1072 | sum = (int)(t1 + t2); | ||
985 | t2 -= t1; | 1073 | t2 -= t1; |
986 | ret = put_user(t2, ts); | 1074 | ret = put_user(t2, ts); |
987 | } | 1075 | } |
988 | else { | 1076 | else { |
1077 | int i, j; | ||
1078 | color_read_in_mem_lock(0x0000FF0F, 0x0000000f, (void*)dst, (void*)dst + size*1024); | ||
1079 | local_irq_save(flags); | ||
989 | t1 = litmus_clock(); | 1080 | t1 = litmus_clock(); |
990 | color_read_in_mem(LOCK_ALL, LOCK_ALL, vaddr, vaddr + size); | 1081 | for (i = 0; i < numlines; i++) { |
1082 | for (j = 0; j < INTS_IN_CACHELINE; j++) { | ||
1083 | //dst[i].line[j] = src[i].line[j]; //read | ||
1084 | src[i].line[j] = dst[i].line[j]; //write | ||
1085 | } | ||
1086 | } | ||
991 | t2 = litmus_clock(); | 1087 | t2 = litmus_clock(); |
1088 | local_irq_restore(flags); | ||
1089 | sum = (int)(t1 + t2); | ||
992 | t2 -= t1; | 1090 | t2 -= t1; |
993 | ret = put_user(t2, ts); | 1091 | ret = put_user(t2, ts); |
994 | v7_flush_kern_dcache_area(vaddr, size); | 1092 | v7_flush_kern_dcache_area(src, size*1024); |
995 | } | 1093 | } |
1094 | //preempt_enable(); | ||
1095 | flush_cache(1); | ||
996 | 1096 | ||
997 | return ret; | 1097 | return ret; |
998 | } | 1098 | } |
1099 | #endif | ||
999 | 1100 | ||
1000 | #define TRIALS 1000 | 1101 | #define TRIALS 1000 |
1001 | 1102 | ||