[lkml]   [2006]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[RFC PATCH -rt] Priority preemption latency
We have run into a situation where a lower priority RT task will run after a 
higher priority RT task is awoken. We are running the test case available

For all required files, including librt.h, download the tarball here:

The test case returns non zero on failure, so just run it in a loop, exitting
on failure. The following is a patch by Mike Kravetz that seems to resolve
the problem.

Thoughts, comments?


Darren Hart
IBM Linux Technology Center

I've been looking into the priority preemption issues with [the prio-preempt
test case]. My 'theory' is that when RT tasks are awakened they are not always
put on the 'best' runqueue. As a result, the rt_overload functionality
has to be engaged to get the task to a CPU it can run on. This 'delay'
in getting the task on a CPU is the 'bug' exposed by the testcase as
a lower priority task is allowed to run during this delay.

In the testcase, awakened worker tasks should all run on the same CPU
as the others are busy running other higher priority tasks. But, from
the scheduler's point of view these other CPUs might be a better place
for the awakened task because they are 'less loaded'.

My quick and dirty patch (below) is to the try_to_wake_up path. When
awakening an RT task don't send it to a remote CPU (determined to
be less loaded) unless it can prerempt the task running on the remote
CPU. In such cases the task is added to the current CPU's runqueue.

I've been successfully running the C testcase for a while with this patch

I'm not sure of there is a 'complete' solution to this problem without
a redesign of 'global' RT scheduling on SMP. The rt_overload mechanism
does not guarantee strict priority ordering (as evidenced by this bug).
Perhaps the best solution we can hope for with the current mechanism is
to make the scheduler be smarter with RT task placement on SMP. This
would at least minimize the need for rt_overload.


diff -Naupr linux-rayrt12.1-r357/kernel/sched.c
--- linux-rayrt12.1-r357/kernel/sched.c 2006-05-27 00:43:35.000000000 +0000
+++ 2006-06-08 22:41:20.000000000
@@ -1543,6 +1543,17 @@ static int try_to_wake_up(task_t *p, uns

+ /*
+ * XXX Don't send RT task elsewhere unless it can preempt current
+ * XXX on other CPU. Better yet would be for awakened RT tasks to
+ * XXX examine this(and all other) CPU(s) to see what is the best
+ * XXX fit. For example there is no check here to see if the
+ * XXX currently running task can be preempted (which would be the
+ * XXX ideal case).
+ */
+ if (rt_task(p) && !TASK_PREEMPTS_CURR(p, rq))
+ goto out_set_cpu;
new_cpu = cpu; /* Could not wake to this_cpu. Wake to cpu instead */
new_cpu = wake_idle(new_cpu, p);
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-06-10 02:04    [W:0.082 / U:17.736 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site