aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMing Yang <yang@cs.unc.edu>2016-02-11 20:31:16 -0500
committerMing Yang <yang@cs.unc.edu>2016-02-11 20:31:16 -0500
commit28cef80c0b9da0184ef736ae131b6146c5976422 (patch)
treeddaa898f1786850dbd3d759a032903f5a7a35ae0
parent696546dd52d9baf73920a61e6525a41f3460ba4d (diff)
Manually patched mc^2 related codewip-mc2-cache-slack
-rw-r--r--include/litmus/mc2_common.h31
-rw-r--r--include/litmus/rt_param.h4
-rw-r--r--include/litmus/unistd_32.h3
-rw-r--r--include/litmus/unistd_64.h5
-rw-r--r--litmus/Makefile3
-rw-r--r--litmus/mc2_common.c78
-rw-r--r--litmus/reservation.c6
-rw-r--r--litmus/sched_mc2.c1634
8 files changed, 1757 insertions, 7 deletions
</
diff --git a/include/litmus/mc2_common.h b/include/litmus/mc2_common.h
new file mode 100644
index 000000000000..e3c0af28f1b9
--- /dev/null
+++ b/include/litmus/mc2_common.h
@@ -0,0 +1,31 @@
1/*
2 * MC^2 common data structures
3 */
4
5#ifndef __UNC_MC2_COMMON_H__
6#define __UNC_MC2_COMMON_H__
7
8enum crit_level {
9 CRIT_LEVEL_A = 0,
10 CRIT_LEVEL_B = 1,
11 CRIT_LEVEL_C = 2,
12 NUM_CRIT_LEVELS = 3,
13};
14
15struct mc2_task {
16 enum crit_level crit;
17 unsigned int res_id;
18};
19
20#ifdef __KERNEL__
21
22#include <litmus/reservation.h>
23
24#define tsk_mc2_data(t) (tsk_rt(t)->mc2_data)
25
26long mc2_task_client_init(struct task_client *tc, struct mc2_task *mc2_param, struct task_struct *tsk,
27 struct reservation *res);
28
29#endif /* __KERNEL__ */
30
31#endif \ No newline at end of file
diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h
index e626bbbe60d5..26dfa33c1e5e 100644
--- a/include/litmus/rt_param.h
+++ b/include/litmus/rt_param.h
@@ -206,6 +206,7 @@ struct rt_job {
206}; 206};
207 207
208struct pfair_param; 208struct pfair_param;
209struct mc2_task;
209 210
210/* RT task parameters for scheduling extensions 211/* RT task parameters for scheduling extensions
211 * These parameters are inherited during clone and therefore must 212 * These parameters are inherited during clone and therefore must
@@ -322,6 +323,9 @@ struct rt_param {
322 323
323 /* Pointer to the page shared between userspace and kernel. */ 324 /* Pointer to the page shared between userspace and kernel. */
324 struct control_page * ctrl_page; 325 struct control_page * ctrl_page;
326
327 /* Mixed-criticality specific data */
328 struct mc2_task* mc2_data;
325}; 329};
326 330
327#endif 331#endif
diff --git a/include/litmus/unistd_32.h b/include/litmus/unistd_32.h
index 5f6a2749c6a7..202f439a62ae 100644
--- a/include/litmus/unistd_32.h
+++ b/include/litmus/unistd_32.h
@@ -19,5 +19,6 @@
19#define __NR_null_call __LSC(11) 19#define __NR_null_call __LSC(11)
20#define __NR_reservation_create __LSC(12) 20#define __NR_reservation_create __LSC(12)
21#define __NR_reservation_destroy __LSC(13) 21#define __NR_reservation_destroy __LSC(13)
22#define __NR_set_mc2_task_param __LSC(14)
22 23
23#define NR_litmus_syscalls 14 24#define NR_litmus_syscalls 15
diff --git a/include/litmus/unistd_64.h b/include/litmus/unistd_64.h
index 3e6b1d330336..ba2c91c5bf8c 100644
--- a/include/litmus/unistd_64.h
+++ b/include/litmus/unistd_64.h
@@ -33,6 +33,7 @@ __SYSCALL(__NR_null_call, sys_null_call)
33__SYSCALL(__NR_reservation_create, sys_reservation_create) 33__SYSCALL(__NR_reservation_create, sys_reservation_create)
34#define __NR_reservation_destroy __LSC(13) 34#define __NR_reservation_destroy __LSC(13)
35__SYSCALL(__NR_reservation_destroy, sys_reservation_destroy) 35__SYSCALL(__NR_reservation_destroy, sys_reservation_destroy)
36#define __NR_set_mc2_task_param __LSC(14)
37__SYSCALL(__NR_set_mc2_task_param, sys_set_mc2_task_param)
36 38
37 39#define NR_litmus_syscalls 15
38#define NR_litmus_syscalls 14
diff --git a/litmus/Makefile b/litmus/Makefile
index 05021f553eda..70c77b3e9b53 100644
--- a/litmus/Makefile
+++ b/litmus/Makefile
@@ -35,4 +35,5 @@ obj-$(CONFIG_SCHED_OVERHEAD_TRACE) += trace.o
35 35
36obj-y += reservation.o polling_reservations.o 36obj-y += reservation.o polling_reservations.o
37 37
38obj-y += sched_pres.o \ No newline at end of file 38obj-y += sched_pres.o
39obj-y += mc2_common.o sched_mc2.o
diff --git a/litmus/mc2_common.c b/litmus/mc2_common.c
new file mode 100644
index 000000000000..a8ea5d9889f3
--- /dev/null
+++ b/litmus/mc2_common.c
@@ -0,0 +1,78 @@
1/*
2 * litmus/mc2_common.c
3 *
4 * Common functions for MC2 plugin.
5 */
6
7#include <linux/percpu.h>
8#include <linux/sched.h>
9#include <linux/list.h>
10#include <linux/slab.h>
11#include <asm/uaccess.h>
12
13#include <litmus/litmus.h>
14#include <litmus/sched_plugin.h>
15#include <litmus/sched_trace.h>
16
17#include <litmus/mc2_common.h>
18
19long mc2_task_client_init(struct task_client *tc, struct mc2_task *mc2_param, struct task_struct *tsk, struct reservation *res)
20{
21 task_client_init(tc, tsk, res);
22 if ((mc2_param->crit < CRIT_LEVEL_A) ||
23 (mc2_param->crit > CRIT_LEVEL_C))
24 return -EINVAL;
25
26 TRACE_TASK(tsk, "mc2_task_client_init: crit_level = %d\n", mc2_param->crit);
27
28 return 0;
29}
30
31asmlinkage long sys_set_mc2_task_param(pid_t pid, struct mc2_task __user * param)
32{
33 struct task_struct *target;
34 int retval = -EINVAL;
35 struct mc2_task *mp = kzalloc(sizeof(*mp), GFP_KERNEL);
36
37 if (!mp)
38 return -ENOMEM;
39
40 printk("Setting up mc^2 task parameters for process %d.\n", pid);
41
42 if (pid < 0 || param == 0) {
43 goto out;
44 }
45 if (copy_from_user(mp, param, sizeof(*mp))) {
46 retval = -EFAULT;
47 goto out;
48 }
49
50 /* Task search and manipulation must be protected */
51 read_lock_irq(&tasklist_lock);
52 if (!(target = find_task_by_vpid(pid))) {
53 retval = -ESRCH;
54 goto out_unlock;
55 }
56
57 if (is_realtime(target)) {
58 /* The task is already a real-time task.
59 * We cannot not allow parameter changes at this point.
60 */
61 retval = -EBUSY;
62 goto out_unlock;
63 }
64 if (mp->crit < CRIT_LEVEL_A || mp->crit >= NUM_CRIT_LEVELS) {
65 printk(KERN_INFO "litmus: real-time task %d rejected "
66 "because of invalid criticality level\n", pid);
67 goto out_unlock;
68 }
69
70 //target->rt_param.plugin_state = mp;
71 target->rt_param.mc2_data = mp;
72
73 retval = 0;
74out_unlock:
75 read_unlock_irq(&tasklist_lock);
76out:
77 return retval;
78} \ No newline at end of file
diff --git a/litmus/reservation.c b/litmus/reservation.c
index 08c74f9005b3..d11003af279a 100644
--- a/litmus/reservation.c
+++ b/litmus/reservation.c
@@ -217,7 +217,7 @@ static void sup_charge_budget(
217 /* stop at the first ACTIVE reservation */ 217 /* stop at the first ACTIVE reservation */
218 //break; 218 //break;
219 } 219 }
220 TRACE("finished charging budgets\n"); 220 //TRACE("finished charging budgets\n");
221} 221}
222 222
223static void sup_replenish_budgets(struct sup_reservation_environment* sup_env) 223static void sup_replenish_budgets(struct sup_reservation_environment* sup_env)
@@ -234,7 +234,7 @@ static void sup_replenish_budgets(struct sup_reservation_environment* sup_env)
234 break; 234 break;
235 } 235 }
236 } 236 }
237 TRACE("finished replenishing budgets\n"); 237 //TRACE("finished replenishing budgets\n");
238 238
239 /* request a scheduler update at the next replenishment instant */ 239 /* request a scheduler update at the next replenishment instant */