diff options
-rw-r--r-- | litmus/aux_tasks.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/litmus/aux_tasks.c b/litmus/aux_tasks.c index ef26bba3be77..aa851ab2655b 100644 --- a/litmus/aux_tasks.c +++ b/litmus/aux_tasks.c | |||
@@ -8,7 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/time.h> | 9 | #include <linux/time.h> |
10 | 10 | ||
11 | #define AUX_SLICE_NR_JIFFIES 1 | 11 | #define AUX_SLICE_NR_JIFFIES 4 |
12 | #define AUX_SLICE_NS ((NSEC_PER_SEC / HZ) * AUX_SLICE_NR_JIFFIES) | 12 | #define AUX_SLICE_NS ((NSEC_PER_SEC / HZ) * AUX_SLICE_NR_JIFFIES) |
13 | 13 | ||
14 | static int admit_aux_task(struct task_struct *t) | 14 | static int admit_aux_task(struct task_struct *t) |
@@ -51,7 +51,9 @@ int exit_aux_task(struct task_struct *t) | |||
51 | 51 | ||
52 | BUG_ON(!tsk_rt(t)->is_aux_task); | 52 | BUG_ON(!tsk_rt(t)->is_aux_task); |
53 | 53 | ||
54 | TRACE_CUR("Aux task %s/%d is exiting from %s/%d.\n", t->comm, t->pid, t->group_leader->comm, t->group_leader->pid); | 54 | TRACE_CUR("Aux task %s/%d is exiting from %s/%d.\n", |
55 | t->comm, t->pid, | ||
56 | t->group_leader->comm, t->group_leader->pid); | ||
55 | 57 | ||
56 | tsk_rt(t)->is_aux_task = 0; | 58 | tsk_rt(t)->is_aux_task = 0; |
57 | 59 | ||
@@ -83,7 +85,8 @@ static int aux_tasks_increase_priority(struct task_struct *leader, struct task_s | |||
83 | TRACE_CUR("skipping non-real-time aux task %s/%d\n", aux->comm, aux->pid); | 85 | TRACE_CUR("skipping non-real-time aux task %s/%d\n", aux->comm, aux->pid); |
84 | } | 86 | } |
85 | else if(tsk_rt(aux)->inh_task == hp) { | 87 | else if(tsk_rt(aux)->inh_task == hp) { |
86 | TRACE_CUR("skipping real-time aux task %s/%d that already inherits from %s/%d\n", aux->comm, aux->pid, hp->comm, hp->pid); | 88 | TRACE_CUR("skipping real-time aux task %s/%d that already inherits from %s/%d\n", |
89 | aux->comm, aux->pid, hp->comm, hp->pid); | ||
87 | } | 90 | } |
88 | else { | 91 | else { |
89 | // aux tasks don't touch rt locks, so no nested call needed. | 92 | // aux tasks don't touch rt locks, so no nested call needed. |
@@ -138,7 +141,7 @@ int aux_task_owner_increase_priority(struct task_struct *t) | |||
138 | leader = t->group_leader; | 141 | leader = t->group_leader; |
139 | 142 | ||
140 | if (!binheap_is_in_heap(&tsk_rt(t)->aux_task_owner_node)) { | 143 | if (!binheap_is_in_heap(&tsk_rt(t)->aux_task_owner_node)) { |
141 | WARN_ON(!is_running(t)); | 144 | //WARN_ON(!is_running(t)); |
142 | TRACE_CUR("aux tasks may not inherit from %s/%d in group %s/%d\n", | 145 | TRACE_CUR("aux tasks may not inherit from %s/%d in group %s/%d\n", |
143 | t->comm, t->pid, leader->comm, leader->pid); | 146 | t->comm, t->pid, leader->comm, leader->pid); |
144 | goto out; | 147 | goto out; |
@@ -146,16 +149,18 @@ int aux_task_owner_increase_priority(struct task_struct *t) | |||
146 | 149 | ||
147 | TRACE_CUR("task %s/%d in group %s/%d increasing priority.\n", t->comm, t->pid, leader->comm, leader->pid); | 150 | TRACE_CUR("task %s/%d in group %s/%d increasing priority.\n", t->comm, t->pid, leader->comm, leader->pid); |
148 | 151 | ||
149 | hp = container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 152 | hp = container_of( |
150 | struct task_struct, rt_param); | 153 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
154 | struct task_struct, rt_param); | ||
151 | hp_eff = effective_priority(hp); | 155 | hp_eff = effective_priority(hp); |
152 | 156 | ||
153 | if (hp != t) { /* our position in the heap may have changed. hp is already at the root. */ | 157 | if (hp != t) { /* our position in the heap may have changed. hp is already at the root. */ |
154 | binheap_decrease(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners); | 158 | binheap_decrease(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners); |
155 | } | 159 | } |
156 | 160 | ||
157 | hp = container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 161 | hp = container_of( |
158 | struct task_struct, rt_param); | 162 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
163 | struct task_struct, rt_param); | ||
159 | 164 | ||
160 | if (effective_priority(hp) != hp_eff) { /* the eff. prio. of hp has changed */ | 165 | if (effective_priority(hp) != hp_eff) { /* the eff. prio. of hp has changed */ |
161 | hp_eff = effective_priority(hp); | 166 | hp_eff = effective_priority(hp); |
@@ -183,7 +188,7 @@ int aux_task_owner_decrease_priority(struct task_struct *t) | |||
183 | leader = t->group_leader; | 188 | leader = t->group_leader; |
184 | 189 | ||
185 | if (!binheap_is_in_heap(&tsk_rt(t)->aux_task_owner_node)) { | 190 | if (!binheap_is_in_heap(&tsk_rt(t)->aux_task_owner_node)) { |
186 | WARN_ON(!is_running(t)); | 191 | //WARN_ON(!is_running(t)); |
187 | TRACE_CUR("aux tasks may not inherit from %s/%d in group %s/%d\n", | 192 | TRACE_CUR("aux tasks may not inherit from %s/%d in group %s/%d\n", |
188 | t->comm, t->pid, leader->comm, leader->pid); | 193 | t->comm, t->pid, leader->comm, leader->pid); |
189 | goto out; | 194 | goto out; |
@@ -191,8 +196,9 @@ int aux_task_owner_decrease_priority(struct task_struct *t) | |||
191 | 196 | ||
192 | TRACE_CUR("task %s/%d in group %s/%d decresing priority.\n", t->comm, t->pid, leader->comm, leader->pid); | 197 | TRACE_CUR("task %s/%d in group %s/%d decresing priority.\n", t->comm, t->pid, leader->comm, leader->pid); |
193 | 198 | ||
194 | hp = container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 199 | hp = container_of( |
195 | struct task_struct, rt_param); | 200 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
201 | struct task_struct, rt_param); | ||
196 | hp_eff = effective_priority(hp); | 202 | hp_eff = effective_priority(hp); |
197 | binheap_delete(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners); | 203 | binheap_delete(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners); |
198 | binheap_add(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners, | 204 | binheap_add(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners, |
@@ -200,8 +206,9 @@ int aux_task_owner_decrease_priority(struct task_struct *t) | |||
200 | 206 | ||
201 | if (hp == t) { /* t was originally the hp */ | 207 | if (hp == t) { /* t was originally the hp */ |
202 | struct task_struct *new_hp = | 208 | struct task_struct *new_hp = |
203 | container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 209 | container_of( |
204 | struct task_struct, rt_param); | 210 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
211 | struct task_struct, rt_param); | ||
205 | if (effective_priority(new_hp) != hp_eff) { /* eff prio. of hp has changed */ | 212 | if (effective_priority(new_hp) != hp_eff) { /* eff prio. of hp has changed */ |
206 | hp_eff = effective_priority(new_hp); | 213 | hp_eff = effective_priority(new_hp); |
207 | TRACE_CUR("%s/%d is no longer hp in group %s/%d.\n", t->comm, t->pid, leader->comm, leader->pid); | 214 | TRACE_CUR("%s/%d is no longer hp in group %s/%d.\n", t->comm, t->pid, leader->comm, leader->pid); |
@@ -241,8 +248,9 @@ int make_aux_task_if_required(struct task_struct *t) | |||
241 | 248 | ||
242 | if (!binheap_empty(&tsk_aux(leader)->aux_task_owners)) { | 249 | if (!binheap_empty(&tsk_aux(leader)->aux_task_owners)) { |
243 | struct task_struct *hp = | 250 | struct task_struct *hp = |
244 | container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 251 | container_of( |
245 | struct task_struct, rt_param); | 252 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
253 | struct task_struct, rt_param); | ||
246 | 254 | ||
247 | TRACE_CUR("hp in group: %s/%d\n", hp->comm, hp->pid); | 255 | TRACE_CUR("hp in group: %s/%d\n", hp->comm, hp->pid); |
248 | 256 | ||
@@ -287,8 +295,9 @@ long enable_aux_task_owner(struct task_struct *t) | |||
287 | binheap_add(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners, | 295 | binheap_add(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners, |
288 | struct rt_param, aux_task_owner_node); | 296 | struct rt_param, aux_task_owner_node); |
289 | 297 | ||
290 | hp = container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 298 | hp = container_of( |
291 | struct task_struct, rt_param); | 299 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
300 | struct task_struct, rt_param); | ||
292 | if (hp == t) { | 301 | if (hp == t) { |
293 | /* we're the new hp */ | 302 | /* we're the new hp */ |
294 | TRACE_CUR("%s/%d is new hp in group %s/%d.\n", t->comm, t->pid, leader->comm, leader->pid); | 303 | TRACE_CUR("%s/%d is new hp in group %s/%d.\n", t->comm, t->pid, leader->comm, leader->pid); |
@@ -325,13 +334,15 @@ long disable_aux_task_owner(struct task_struct *t) | |||
325 | 334 | ||
326 | TRACE_CUR("task %s/%d exiting from group %s/%d.\n", t->comm, t->pid, leader->comm, leader->pid); | 335 | TRACE_CUR("task %s/%d exiting from group %s/%d.\n", t->comm, t->pid, leader->comm, leader->pid); |
327 | 336 | ||
328 | hp = container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 337 | hp = container_of( |
329 | struct task_struct, rt_param); | 338 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
339 | struct task_struct, rt_param); | ||
330 | binheap_delete(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners); | 340 | binheap_delete(&tsk_rt(t)->aux_task_owner_node, &tsk_aux(leader)->aux_task_owners); |
331 | 341 | ||
332 | if (!binheap_empty(&tsk_aux(leader)->aux_task_owners)) { | 342 | if (!binheap_empty(&tsk_aux(leader)->aux_task_owners)) { |
333 | new_hp = container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 343 | new_hp = container_of( |
334 | struct task_struct, rt_param); | 344 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
345 | struct task_struct, rt_param); | ||
335 | } | 346 | } |
336 | 347 | ||
337 | if (hp == t && new_hp != t) { | 348 | if (hp == t && new_hp != t) { |
@@ -443,8 +454,9 @@ static long __do_enable_aux_tasks(int flags) | |||
443 | 454 | ||
444 | #ifdef CONFIG_REALTIME_AUX_TASK_PRIORITY_INHERITANCE | 455 | #ifdef CONFIG_REALTIME_AUX_TASK_PRIORITY_INHERITANCE |
445 | if (aux_tasks_added && !binheap_empty(&tsk_aux(leader)->aux_task_owners)) { | 456 | if (aux_tasks_added && !binheap_empty(&tsk_aux(leader)->aux_task_owners)) { |
446 | struct task_struct *hp = container_of(binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), | 457 | struct task_struct *hp = container_of( |
447 | struct task_struct, rt_param); | 458 | binheap_top_entry(&tsk_aux(leader)->aux_task_owners, struct rt_param, aux_task_owner_node), |
459 | struct task_struct, rt_param); | ||
448 | TRACE_CUR("hp in group: %s/%d\n", hp->comm, hp->pid); | 460 | TRACE_CUR("hp in group: %s/%d\n", hp->comm, hp->pid); |
449 | retval = aux_tasks_increase_priority(leader, (tsk_rt(hp)->inh_task)? tsk_rt(hp)->inh_task : hp); | 461 | retval = aux_tasks_increase_priority(leader, (tsk_rt(hp)->inh_task)? tsk_rt(hp)->inh_task : hp); |
450 | } | 462 | } |