aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2016-03-16 07:59:07 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2016-03-20 14:30:35 -0400
commit2a38056cc098c56a04bbe18f4e752f4fa782599f (patch)
treec38619d281c9b7ae23333573b322bab72d8801b3
parent095f515b2fd903a0140afcc42db9a9f76d688b65 (diff)
Add basic generic reservation-based scheduling infrastructure
-rw-r--r--include/litmus/reservations/alloc.h15
-rw-r--r--include/litmus/reservations/budget-notifier.h50
-rw-r--r--include/litmus/reservations/polling.h19
-rw-r--r--include/litmus/reservations/reservation.h223
-rw-r--r--include/litmus/reservations/table-driven.h23
-rw-r--r--litmus/Makefile2
-rw-r--r--litmus/reservations/Makefile3
-rw-r--r--litmus/reservations/alloc.c143
-rw-r--r--litmus/reservations/budget-notifier.c26
-rw-r--r--litmus/reservations/core.c392
-rw-r--r--litmus/reservations/polling.c256
-rw-r--r--litmus/reservations/table-driven.c269
12 files changed, 1421 insertions, 0 deletions
diff --git a/include/litmus/reservations/alloc.h b/include/litmus/reservations/alloc.h
new file mode 100644
index 000000000000..b3471288c9f1
--- /dev/null
+++ b/include/litmus/reservations/alloc.h
@@ -0,0 +1,15 @@
1#ifndef LITMUS_RESERVATIONS_ALLOC_H
2#define LITMUS_RESERVATIONS_ALLOC_H
3
4#include <litmus/reservations/reservation.h>
5
6long alloc_polling_reservation(
7 int res_type,
8 struct reservation_config *config,
9 struct reservation **_res);
10
11long alloc_table_driven_reservation(
12 struct reservation_config *config,
13 struct reservation **_res);
14
15#endif \ No newline at end of file
diff --git a/include/litmus/reservations/budget-notifier.h b/include/litmus/reservations/budget-notifier.h
new file mode 100644
index 000000000000..d831fa9d5153
--- /dev/null
+++ b/include/litmus/reservations/budget-notifier.h
@@ -0,0 +1,50 @@
1#ifndef LITMUS_BUDGET_NOTIFIER_H
2#define LITMUS_BUDGET_NOTIFIER_H
3
4#include <linux/list.h>
5#include <linux/spinlock.h>
6
7struct budget_notifier;
8
9typedef void (*budget_callback_t) (
10 struct budget_notifier *bn
11);
12
13struct budget_notifier {
14 struct list_head list;
15 budget_callback_t budget_exhausted;
16 budget_callback_t budget_replenished;
17};
18
19struct budget_notifier_list {
20 struct list_head list;
21 raw_spinlock_t lock;
22};
23
24void budget_notifier_list_init(struct budget_notifier_list* bnl);
25
26static inline void budget_notifier_add(
27 struct budget_notifier_list *bnl,
28 struct budget_notifier *bn)
29{
30 unsigned long flags;
31
32 raw_spin_lock_irqsave(&bnl->lock, flags);
33 list_add(&bn->list, &bnl->list);
34 raw_spin_unlock_irqrestore(&bnl->lock, flags);
35}
36
37static inline void budget_notifier_remove(
38 struct budget_notifier_list *bnl,
39 struct budget_notifier *bn)
40{
41 unsigned long flags;
42
43 raw_spin_lock_irqsave(&bnl->lock, flags);
44 list_del(&bn->list);
45 raw_spin_unlock_irqrestore(&bnl->lock, flags);
46}
47
48void budget_notifiers_fire(struct budget_notifier_list *bnl, bool replenished);
49
50#endif
diff --git a/include/litmus/reservations/polling.h b/include/litmus/reservations/polling.h
new file mode 100644
index 000000000000..230e12b1088a
--- /dev/null
+++ b/include/litmus/reservations/polling.h
@@ -0,0 +1,19 @@
1#ifndef LITMUS_POLLING_RESERVATIONS_H
2#define LITMUS_POLLING_RESERVATIONS_H
3
4#include <litmus/reservations/reservation.h>
5
6struct polling_reservation {
7 /* extend basic reservation */
8 struct reservation res;
9
10 lt_t max_budget;
11 lt_t period;
12 lt_t deadline;
13 lt_t offset;
14};
15
16void polling_reservation_init(struct polling_reservation *pres, int use_edf_prio,
17 int use_periodic_polling, lt_t budget, lt_t period, lt_t deadline, lt_t offset);
18
19#endif
diff --git a/include/litmus/reservations/reservation.h b/include/litmus/reservations/reservation.h
new file mode 100644
index 000000000000..ef639007969b
--- /dev/null
+++ b/include/litmus/reservations/reservation.h
@@ -0,0 +1,223 @@
1#ifndef LITMUS_RESERVATION_H
2#define LITMUS_RESERVATION_H
3
4#include <linux/list.h>
5#include <linux/hrtimer.h>
6
7#include <litmus/reservations/budget-notifier.h>
8
9struct reservation_client;
10struct reservation_environment;
11struct reservation;
12
13typedef enum {
14 /* reservation has no clients, is not consuming budget */
15 RESERVATION_INACTIVE = 0,
16
17 /* reservation has clients, consumes budget when scheduled */
18 RESERVATION_ACTIVE,
19
20 /* reservation has no clients, but may be consuming budget */
21 RESERVATION_ACTIVE_IDLE,
22
23 /* Reservation has no budget and waits for
24 * replenishment. May or may not have clients. */
25 RESERVATION_DEPLETED,
26} reservation_state_t;
27
28
29/* ************************************************************************** */
30
31/* Select which task to dispatch. If NULL is returned, it means there is nothing
32 * to schedule right now and background work can be scheduled. */
33typedef struct task_struct * (*dispatch_t) (
34 struct reservation_client *client
35);
36
37/* Something that can be managed in a reservation and that can yield
38 * a process for dispatching. Contains a pointer to the reservation
39 * to which it "belongs". */
40struct reservation_client {
41 struct list_head list;
42 struct reservation* reservation;
43 dispatch_t dispatch;
44};
45
46
47/* ************************************************************************** */
48
49/* Called by reservations to request state change. */
50typedef void (*reservation_change_state_t) (
51 struct reservation_environment* env,
52 struct reservation *res,
53 reservation_state_t new_state
54);
55
56/* Called by reservations to request replenishment while not DEPLETED.
57 * Useful for soft reservations that remain ACTIVE with lower priority. */
58typedef void (*request_replenishment_t)(
59 struct reservation_environment* env,
60 struct reservation *res
61);
62
63/* The framework within wich reservations operate. */
64struct reservation_environment {
65 lt_t time_zero;
66 lt_t current_time;
67
68 /* services invoked by reservations */
69 reservation_change_state_t change_state;
70 request_replenishment_t request_replenishment;
71};
72
73/* ************************************************************************** */
74
75/* A new client is added or an existing client resumes. */
76typedef void (*client_arrives_t) (
77 struct reservation *reservation,
78 struct reservation_client *client
79);
80
81/* A client suspends or terminates. */
82typedef void (*client_departs_t) (
83 struct reservation *reservation,
84 struct reservation_client *client,