aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/litmus/locking.h76
-rw-r--r--include/litmus/sched_plugin.h5
-rw-r--r--include/litmus/trace.h14
-rw-r--r--include/litmus/unistd_32.h4
-rw-r--r--include/litmus/unistd_64.h6
5 files changed, 101 insertions, 4 deletions
diff --git a/include/litmus/locking.h b/include/litmus/locking.h
index e0c13f4c31e5..972cbdb7fdd5 100644
--- a/include/litmus/locking.h
+++ b/include/litmus/locking.h
@@ -36,6 +36,29 @@ struct litmus_lock {
36#endif 36#endif
37}; 37};
38 38
39#ifdef CONFIG_LITMUS_DGL_SUPPORT
40
41#define MAX_DGL_SIZE CONFIG_LITMUS_MAX_DGL_SIZE
42
43typedef struct dgl_wait_state {
44 struct task_struct *task;
45 struct litmus_lock *locks[MAX_DGL_SIZE];
46 int size;
47 int nr_remaining;
48
49 int last_primary;
50
51 wait_queue_t wq_nodes[MAX_DGL_SIZE];
52} dgl_wait_state_t;
53
54void wake_or_wait_on_next_lock(dgl_wait_state_t *dgl_wait);
55void select_next_lock(dgl_wait_state_t* dgl_wait, struct litmus_lock* prev_lock);
56
57void init_dgl_waitqueue_entry(wait_queue_t *wq_node, dgl_wait_state_t* dgl_wait);
58int dgl_wake_up(wait_queue_t *wq_node, unsigned mode, int sync, void *key);
59void __waitqueue_dgl_remove_first(wait_queue_head_t *wq, dgl_wait_state_t** dgl_wait, struct task_struct **task);
60#endif
61
39struct litmus_lock_ops { 62struct litmus_lock_ops {
40 /* Current task tries to obtain / drop a reference to a lock. 63 /* Current task tries to obtain / drop a reference to a lock.
41 * Optional methods, allowed by default. */ 64 * Optional methods, allowed by default. */
@@ -45,7 +68,7 @@ struct litmus_lock_ops {
45 /* Current tries to lock/unlock this lock (mandatory methods). */ 68 /* Current tries to lock/unlock this lock (mandatory methods). */
46 int (*lock)(struct litmus_lock*); 69 int (*lock)(struct litmus_lock*);
47 int (*unlock)(struct litmus_lock*); 70 int (*unlock)(struct litmus_lock*);
48 71
49 /* The lock is no longer being referenced (mandatory method). */ 72 /* The lock is no longer being referenced (mandatory method). */
50 void (*deallocate)(struct litmus_lock*); 73 void (*deallocate)(struct litmus_lock*);
51 74
@@ -53,6 +76,57 @@ struct litmus_lock_ops {
53 void (*propagate_increase_inheritance)(struct litmus_lock* l, struct task_struct* t, raw_spinlock_t* to_unlock, unsigned long irqflags); 76 void (*propagate_increase_inheritance)(struct litmus_lock* l, struct task_struct* t, raw_spinlock_t* to_unlock, unsigned long irqflags);
54 void (*propagate_decrease_inheritance)(struct litmus_lock* l, struct task_struct* t, raw_spinlock_t* to_unlock, unsigned long irqflags); 77 void (*propagate_decrease_inheritance)(struct litmus_lock* l, struct task_struct* t, raw_spinlock_t* to_unlock, unsigned long irqflags);
55#endif 78#endif
79
80#ifdef CONFIG_LITMUS_DGL_SUPPORT
81 raw_spinlock_t* (*get_dgl_spin_lock)(struct litmus_lock *l);
82 int (*dgl_lock)(struct litmus_lock *l, dgl_wait_state_t* dgl_wait, wait_queue_t* wq_node);
83 int (*is_owner)(struct litmus_lock *l, struct task_struct *t);
84 void (*enable_priority)(struct litmus_lock *l, dgl_wait_state_t* dgl_wait);
85#endif
56}; 86};
57 87
88
89#ifdef CONFIG_LITMUS_DGL_SUPPORT
90#define lock_global_irqsave(lock, flags) raw_spin_lock_irqsave((lock), (flags))
91#define lock_global(lock) raw_spin_lock((lock))
92#define unlock_global_irqrestore(lock, flags) raw_spin_unlock_irqrestore((lock), (flags))
93#define unlock_global(lock) raw_spin_unlock((lock))
94
95/* fine-grain locking are no-ops with DGL support */
96#define lock_fine_irqsave(lock, flags)
97#define lock_fine(lock)
98#define unlock_fine_irqrestore(lock, flags)
99#define unlock_fine(lock)
100
101#elif CONFIG_LITMUS_NESTED_LOCKING
102
103/* global locking are no-ops without DGL support */
104#define lock_global_irqsave(lock, flags)
105#define lock_global(lock)
106#define unlock_global_irqrestore(lock, flags)
107#define unlock_global(lock)
108
109#define lock_fine_irqsave(lock, flags) raw_spin_lock_irqsave((lock), (flags))
110#define lock_fine(lock) raw_spin_lock((lock))
111#define unlock_fine_irqrestore(lock, flags) raw_spin_unlock_irqrestore((lock), (flags))
112#define unlock_fine(lock) raw_spin_unlock((lock))
113
58#endif 114#endif
115
116
117#endif
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h
index 6e7cabdddae8..ae11e3ac9266 100644
--- a/include/litmus/sched_plugin.h
+++ b/include/litmus/sched_plugin.h
@@ -58,6 +58,7 @@ typedef void (*task_exit_t) (struct task_struct *);
58typedef long (*allocate_lock_t) (struct litmus_lock **lock, int type, 58typedef long (*allocate_lock_t) (struct litmus_lock **lock, int type,
59 void* __user config); 59 void* __user config);
60 60
61typedef raw_spinlock_t* (*get_dgl_spinlock_t) (struct task_struct *t);
61 62
62/********************* sys call backends ********************/ 63/********************* sys call backends ********************/
63/* This function causes the caller to sleep until the next release */ 64/* This function causes the caller to sleep until the next release */
@@ -97,6 +98,10 @@ struct sched_plugin {
97 /* locking protocols */ 98 /* locking protocols */
98 allocate_lock_t allocate_lock; 99 allocate_lock_t allocate_lock;
99#endif 100#endif
101
102#ifdef CONFIG_LITMUS_DGL_SUPPORT
103 get_dgl_spinlock_t get_dgl_spinlock;
104#endif
100} __attribute__ ((__aligned__(SMP_CACHE_BYTES))); 105} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
101 106
102 107
diff --git a/include/litmus/trace.h b/include/litmus/trace.h
index e809376d6487..1a1b0d479f61 100644
--- a/include/litmus/trace.h
+++ b/include/litmus/trace.h
@@ -103,11 +103,23 @@ feather_callback void save_task_latency(unsigned long event, unsigned long when_
103#define TS_LOCK_START TIMESTAMP(170) 103#define TS_LOCK_START TIMESTAMP(170)
104#define TS_LOCK_SUSPEND TIMESTAMP(171) 104#define TS_LOCK_SUSPEND TIMESTAMP(171)
105#define TS_LOCK_RESUME TIMESTAMP(172) 105#define TS_LOCK_RESUME TIMESTAMP(172)
106#define TS_LOCK_END TIMESTAMP(173) 106#define TS_LOCK_END TIMESTAMP(173)
107
108#ifdef CONFIG_LITMUS_DGL_SUPPORT
109#define TS_DGL_LOCK_START TIMESTAMP(175)
110#define TS_DGL_LOCK_SUSPEND TIMESTAMP(176)
111#define TS_DGL_LOCK_RESUME TIMESTAMP(177)
112#define TS_DGL_LOCK_END TIMESTAMP(178)
113#endif
107 114
108#define TS_UNLOCK_START TIMESTAMP(180) 115#define TS_UNLOCK_START TIMESTAMP(180)
109#define TS_UNLOCK_END TIMESTAMP(181) 116#define TS_UNLOCK_END TIMESTAMP(181)
110 117
118#ifdef CONFIG_LITMUS_DGL_SUPPORT
119#define TS_DGL_UNLOCK_START TIMESTAMP(185)
120#define TS_DGL_UNLOCK_END TIMESTAMP(186)
121#endif
122
111#define TS_SEND_RESCHED_START(c) CTIMESTAMP(190, c) 123#define TS_SEND_RESCHED_START(c) CTIMESTAMP(190, c)
112#define TS_SEND_RESCHED_END DTIMESTAMP(191, TSK_UNKNOWN) 124#define TS_SEND_RESCHED_END DTIMESTAMP(191, TSK_UNKNOWN)
113 125
diff --git a/include/litmus/unistd_32.h b/include/litmus/unistd_32.h
index 94264c27d9ac..941231c8184b 100644
--- a/include/litmus/unistd_32.h
+++ b/include/litmus/unistd_32.h
@@ -17,5 +17,7 @@
17#define __NR_wait_for_ts_release __LSC(9) 17#define __NR_wait_for_ts_release __LSC(9)
18#define __NR_release_ts __LSC(10) 18#define __NR_release_ts __LSC(10)
19#define __NR_null_call __LSC(11) 19#define __NR_null_call __LSC(11)
20#define __NR_litmus_dgl_lock __LSC(12)
21#define __NR_litmus_dgl_unlock __LSC(13)
20 22
21#define NR_litmus_syscalls 12 23#define NR_litmus_syscalls 14
diff --git a/include/litmus/unistd_64.h b/include/litmus/unistd_64.h
index d5ced0d2642c..bf2ffeac2dbb 100644
--- a/include/litmus/unistd_64.h
+++ b/include/litmus/unistd_64.h
@@ -29,5 +29,9 @@ __SYSCALL(__NR_wait_for_ts_release, sys_wait_for_ts_release)
29__SYSCALL(__NR_release_ts, sys_release_ts) 29__SYSCALL(__NR_release_ts, sys_release_ts)
30#define __NR_null_call __LSC(11) 30#define __NR_null_call __LSC(11)
31__SYSCALL(__NR_null_call, sys_null_call) 31__SYSCALL(__NR_null_call, sys_null_call)
32#define __NR_litmus_dgl_lock __LSC(12)
33__SYSCALL(__NR_litmus_dgl_lock, sys_litmus_dgl_lock)
34#define __NR_litmus_dgl_unlock __LSC(13)
35__SYSCALL(__NR_litmus_dgl_unlock, sys_litmus_dgl_unlock)
32 36
33#define NR_litmus_syscalls 12 37#define NR_litmus_syscalls 14