aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZelin Tong <ztong@ludwig.cs.unc.edu>2020-09-16 15:08:10 -0400
committerZelin Tong <ztong@ludwig.cs.unc.edu>2020-09-16 15:08:10 -0400
commitb665fac6de1744ce6aeb4cfdd81a2cff528484dc (patch)
tree65cc441d5620d3872864410b1fc827779af72354
parente21750e5fcfcd24ae828eab337acc04284aff887 (diff)
WIP commit backup
-rw-r--r--include/litmus/reservations/ext_reservation.h135
-rw-r--r--include/litmus/reservations/gedf_reservation.h58
-rw-r--r--include/litmus/reservations/task_reservation.h16
-rw-r--r--litmus/ext_reservation.c19
-rw-r--r--litmus/litmus.c2
-rw-r--r--litmus/reservations/ext_reservation.c406
-rw-r--r--litmus/reservations/gedf_reservation.c459
-rw-r--r--litmus/reservations/task_reservation.c73
-rw-r--r--litmus/rt_domain.c7
9 files changed, 1171 insertions, 4 deletions
diff --git a/include/litmus/reservations/ext_reservation.h b/include/litmus/reservations/ext_reservation.h
new file mode 100644
index 000000000000..b5fedf46a2cc
--- /dev/null
+++ b/include/litmus/reservations/ext_reservation.h
@@ -0,0 +1,135 @@
1#ifndef LITMUS_EXT_RESERVATION_H
2#define LITMUS_EXT_RESERVATION_H
3
4#include <linux/list.h>
5#include <linux/hrtimer.h>
6
7#include <litmus/debug_trace.h>
8#include <litmus/bheap.h>
9#include <litmus/rt_domain.h>
10#include <litmus/reservations/budget-notifier.h>
11
12struct reservation_environment;
13struct reservation;
14
15/* ************************************************************************** */
16/* Reservation replenishes its budget. */
17typedef void (*replenish_budget_t) (
18 struct reservation *reservation,
19 int cpu
20);
21
22/* Update the reservation's budget to reflect execution or idling. */
23typedef void (*drain_budget_t) (
24 struct reservation *reservation,
25 lt_t how_much,
26 int cpu
27);
28
29/* When reservation is scheduled. */
30typedef void (*on_schedule_t) (
31 struct reservation *reservation,
32 lt_t now,
33 int cpu
34);
35
36/* When reservation is preempted. */
37typedef void (*on_preempt_t) (
38 struct reservation *reservation,
39 int cpu
40);
41
42/* Destructor: called before scheduler is deactivated. */
43typedef void (*shutdown_t)(struct reservation *reservation);
44
45struct reservation_ops {
46 drain_budget_t drain_budget;
47 replenish_budget_t replenish_budget;
48 on_schedule_t on_schedule;
49 on_preempt_t on_preempt;
50 shutdown_t shutdown;
51};
52
53struct reservation {
54 unsigned int id;
55 unsigned int kind;
56
57 /* exact meaning defined by impl. */
58 lt_t priority;
59 lt_t cur_budget;
60 lt_t next_replenishment;
61
62 /* budget stats */
63 lt_t budget_consumed; /* how much budget consumed in this allocation cycle? */
64 lt_t budget_consumed_total;
65
66 /* list of registered budget callbacks */
67 struct budget_notifier_list budget_notifiers;
68
69 /* for memory reclamation purposes */
70 struct list_head all_list;
71
72 /* interaction with framework */
73 struct reservation_ops *ops;
74 struct reservation_environment* par_env;
75
76 struct reservation_environment* env;
77
78 /* used to enqueue int rt_domain framework */
79 struct bheap_node* heap_node;
80 struct release_heap* rel_heap;
81 struct list_head ln;
82};
83
84void init_ext_reservation(struct reservation* res);
85
86void clean_up_ext_reservation(struct reservation* res);
87
88/* ************************************************************************** */
89typedef void (*env_advance_time_t) (
90 struct reservation_environment* env,
91 lt_t how_much,
92 int cpu);
93
94typedef struct task_struct* (*env_dispatch_t) (
95 struct reservation_environment* env,
96 lt_t now,
97 int cpu);
98
99typedef void (*env_resume_t) (
100 struct reservation_environment* env,
101 lt_t now,
102 int cpu);
103
104typedef void (*env_suspend_t) (
105 struct reservation_environment* env,
106 int cpu);
107
108typedef void (*env_add_res_t) (struct reservation_environment* env,
109 struct reservation* res,
110 int cpu);
111
112typedef void (*env_remove_res_t) (struct reservation_environment* env,
113 struct reservation* res,
114 int complete,
115 int cpu);
116
117typedef void (*env_shutdown_t) (
118 struct reservation_environment* env,
119 int cpu);
120
121struct reservation_environment_ops {
122 env_update_time_t update_time;
123 env_dispatch_t dispatch;
124 env_resume_t resume;
125 env_suspend_t suspend;
126 env_add_res_t add_res;
127 env_remove_res_t remove_res;
128 env_shutdown_t shutdown;
129};
130
131struct reservation_environment {
132 struct reservation_environment_ops* ops;
133};
134
135#endif
diff --git a/include/litmus/reservations/gedf_reservation.h b/include/litmus/reservations/gedf_reservation.h
new file mode 100644
index 000000000000..f00c21e37fac
--- /dev/null
+++ b/include/litmus/reservations/gedf_reservation.h
@@ -0,0 +1,58 @@
1#ifndef LITMUS_GEDF_RESERVATION_H
2#define LITMUS_GEDF_RESERVATION_H
3
4#include <litmus/reservations/ext_reservation.h>
5
6/* ************************************************************************** */
7struct cpu_entry {
8 int id;
9 struct hrtimer timer;
10 struct bheap_node* hn;
11 struct reservation* linked;
12 struct reservation* scheduled;
13};
14
15struct gedf_reservation {
16 struct reservation res;
17 struct cpu_entry linked_on;
18 struct cpu_entry scheduled_on;
19 int will_remove;
20 int blocked;
21 lt_t period;
22 lt_t relative_deadline;
23 lt_t exec_cost;
24};
25
26long alloc_gedf_reservation(
27 struct reservation** _res,
28 int id,
29 lt_t exec_cost,
30 lt_t period,
31 lt_t relative_deadline
32);
33
34/* environment for scheduling reservations via gedf */
35struct gedf_reservation_environment {
36 struct reservation_environment env;
37 /* number of active cpus in reservation */
38 int num_cpus;
39 /* array of gedf cpu entries */
40 struct cpu_entry cpu_entries[NR_CPUS];
41 /* smp_processor_id to environment cpu array offset mapping */
42 int cpu_mapping[NR_CPUS];
43
44 /* used to order cpus for gedf purposes */
45 struct bheap cpu_heap;
46 struct bheap_node cpu_node[NR_CPUS];
47
48 /* operations */
49 struct reservation_environment_ops ops;
50
51 rt_domain_t domain;
52};
53
54long alloc_gedf_reservation_environment(