aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMing Yang <yang@cs.unc.edu>2016-02-10 10:58:42 -0500
committerMing Yang <yang@cs.unc.edu>2016-02-10 18:05:12 -0500
commit696546dd52d9baf73920a61e6525a41f3460ba4d (patch)
tree7093c4b6ba8af2714101d400fdc3e987098c9d47 /include
parent3dfe2804d7ccc6b7f0e2e44175249b38299c83e7 (diff)
Patched reservation implementation of MC^2 version
Patched using Namhoon's implementation of reservation for MC^2 to support global multiprocessor scheduling. Patched compiler-gcc5 to support gcc v5 compiler. Bug fixed regarding user input big cpu id number causing kernel crash.
Diffstat (limited to 'include')
-rw-r--r--include/linux/compiler-gcc5.h66
-rw-r--r--include/litmus/reservation.h65
2 files changed, 131 insertions, 0 deletions
diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
new file mode 100644
index 000000000000..cec40d7428cf
--- /dev/null
+++ b/include/linux/compiler-gcc5.h
@@ -0,0 +1,66 @@
1#ifndef __LINUX_COMPILER_H
2#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
3#endif
4
5#define __used __attribute__((__used__))
6#define __must_check __attribute__((warn_unused_result))
7#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
8
9/* Mark functions as cold. gcc will assume any path leading to a call
10 to them will be unlikely. This means a lot of manual unlikely()s
11 are unnecessary now for any paths leading to the usual suspects
12 like BUG(), printk(), panic() etc. [but let's keep them for now for
13 older compilers]
14
15 Early snapshots of gcc 4.3 don't support this and we can't detect this
16 in the preprocessor, but we can live with this because they're unreleased.
17 Maketime probing would be overkill here.
18
19 gcc also has a __attribute__((__hot__)) to move hot functions into
20 a special section, but I don't see any sense in this right now in
21 the kernel context */
22#define __cold __attribute__((__cold__))
23
24#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
25
26#ifndef __CHECKER__
27# define __compiletime_warning(message) __attribute__((warning(message)))
28# define __compiletime_error(message) __attribute__((error(message)))
29#endif /* __CHECKER__ */
30
31/*
32 * Mark a position in code as unreachable. This can be used to
33 * suppress control flow warnings after asm blocks that transfer
34 * control elsewhere.
35 *
36 * Early snapshots of gcc 4.5 don't support this and we can't detect
37 * this in the preprocessor, but we can live with this because they're
38 * unreleased. Really, we need to have autoconf for the kernel.
39 */
40#define unreachable() __builtin_unreachable()
41
42/* Mark a function definition as prohibited from being cloned. */
43#define __noclone __attribute__((__noclone__))
44
45/*
46 * Tell the optimizer that something else uses this function or variable.
47 */
48#define __visible __attribute__((externally_visible))
49
50/*
51 * GCC 'asm goto' miscompiles certain code sequences:
52 *
53 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
54 *
55 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
56 * Fixed in GCC 4.8.2 and later versions.
57 *
58 * (asm goto is automatically volatile - the naming reflects this.)
59 */
60#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
61
62#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
63#define __HAVE_BUILTIN_BSWAP32__
64#define __HAVE_BUILTIN_BSWAP64__
65#define __HAVE_BUILTIN_BSWAP16__
66#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
diff --git a/include/litmus/reservation.h b/include/litmus/reservation.h
index 4eecd3f088e8..af1fba297bf5 100644
--- a/include/litmus/reservation.h
+++ b/include/litmus/reservation.h
@@ -126,6 +126,14 @@ struct reservation {
126 struct reservation_ops *ops; 126 struct reservation_ops *ops;
127 127
128 struct list_head clients; 128 struct list_head clients;
129
130 /* for global env. */
131 int scheduled_on;
132 int event_added;
133 /* for blocked by ghost. Do not charge budget when ACTIVE */
134 int blocked_by_ghost;
135 /* ghost_job. If it is clear, do not charge budget when ACTIVE_IDLE */
136 int is_ghost;
129}; 137};
130 138
131void reservation_init(struct reservation *res); 139void reservation_init(struct reservation *res);
@@ -185,10 +193,67 @@ struct sup_reservation_environment {
185void sup_init(struct sup_reservation_environment* sup_env); 193void sup_init(struct sup_reservation_environment* sup_env);
186void sup_add_new_reservation(struct sup_reservation_environment* sup_env, 194void sup_add_new_reservation(struct sup_reservation_environment* sup_env,
187 struct reservation* new_res); 195 struct reservation* new_res);
196/*
197 * TODO this function is added from Namhoon's implementation for MC^2.
198 * The need of this declaration is that it's used explicitly outside.
199 */
200void sup_scheduler_update_after(struct sup_reservation_environment* sup_env,
201 lt_t timeout);
188void sup_update_time(struct sup_reservation_environment* sup_env, lt_t now); 202void sup_update_time(struct sup_reservation_environment* sup_env, lt_t now);
189struct task_struct* sup_dispatch(struct sup_reservation_environment* sup_env); 203struct task_struct* sup_dispatch(struct sup_reservation_environment* sup_env);
190 204
191struct reservation* sup_find_by_id(struct sup_reservation_environment* sup_env, 205struct reservation* sup_find_by_id(struct sup_reservation_environment* sup_env,
192 unsigned int id); 206 unsigned int id);
193 207
208/* A global multiprocessor reservation environment. */
209
210typedef enum {
211 EVENT_REPLENISH = 0,
212 EVENT_DRAIN,
213 EVENT_OTHERS,
214} event_type_t;
215
216
217struct next_timer_event {
218 lt_t next_update;
219 int timer_armed_on;
220 unsigned int id;
221 event_type_t type;
222 struct list_head list;
223};
224
225struct gmp_reservation_environment {
226 raw_spinlock_t lock;
227 struct reservation_environment env;
228
229 /* ordered by priority */
230 struct list_head active_reservations;
231
232 /* ordered by next_replenishment */
233 struct list_head depleted_reservations;
234
235 /* unordered */
236 struct list_head inactive_reservations;
237
238 /* timer event ordered by next_update */
239 struct list_head next_events;
240
241 /* (schedule_now == true) means call gmp_dispatch() now */
242 int schedule_now;
243 /* set to true if a call to gmp_dispatch() is imminent */
244 bool will_schedule;
245};
246
247void gmp_init(struct gmp_reservation_environment* gmp_env);
248void gmp_add_new_reservation(struct gmp_reservation_environment* gmp_env,
249 struct reservation* new_res);
250void gmp_add_event_after(struct gmp_reservation_environment* gmp_env,
251 lt_t timeout, unsigned int id, event_type_t type);
252void gmp_print_events(struct gmp_reservation_environment* gmp_env, lt_t now);
253int gmp_update_time(struct gmp_reservation_environment* gmp_env, lt_t now);
254struct task_struct* gmp_dispatch(struct gmp_reservation_environment* gmp_env);
255struct next_timer_event* gmp_find_event_by_id(struct gmp_reservation_environment* gmp_env, unsigned int id);
256struct next_timer_event* gmp_find_event_by_time(struct gmp_reservation_environment* gmp_env, lt_t when);
257struct reservation* gmp_find_by_id(struct gmp_reservation_environment* gmp_env,
258 unsigned int id);
194#endif 259#endif