mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
rtmutex: Turn the plist into an rb-tree
Turn the pi-chains from plist to rb-tree, in the rt_mutex code, and provide a proper comparison function for -deadline and -priority tasks. This is done mainly because: - classical prio field of the plist is just an int, which might not be enough for representing a deadline; - manipulating such a list would become O(nr_deadline_tasks), which might be to much, as the number of -deadline task increases. Therefore, an rb-tree is used, and tasks are queued in it according to the following logic: - among two -priority (i.e., SCHED_BATCH/OTHER/RR/FIFO) tasks, the one with the higher (lower, actually!) prio wins; - among a -priority and a -deadline task, the latter always wins; - among two -deadline tasks, the one with the earliest deadline wins. Queueing and dequeueing functions are changed accordingly, for both the list of a task's pi-waiters and the list of tasks blocked on a pi-lock. Signed-off-by: Peter Zijlstra <[email protected]> Signed-off-by: Dario Faggioli <[email protected]> Signed-off-by: Juri Lelli <[email protected]> Signed-off-again-by: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
1 parent
af6ace764d
commit
fb00aca474
9 files changed
+157
-65
No files matched your search
@@ -24,7 +24,7 @@
|
||||
#include <linux/kallsyms.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/plist.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/debug_locks.h>
|
||||
|
||||
@@ -57,7 +57,7 @@ static void printk_lock(struct rt_mutex *lock, int print_owner)
|
||||
|
||||
void rt_mutex_debug_task_free(struct task_struct *task)
|
||||
{
|
||||
DEBUG_LOCKS_WARN_ON(!plist_head_empty(&task->pi_waiters));
|
||||
DEBUG_LOCKS_WARN_ON(!RB_EMPTY_ROOT(&task->pi_waiters));
|
||||
DEBUG_LOCKS_WARN_ON(task->pi_blocked_on);
|
||||
}
|
||||
|
||||
@@ -154,16 +154,12 @@ void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock)
|
||||
void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter)
|
||||
{
|
||||
memset(waiter, 0x11, sizeof(*waiter));
|
||||
plist_node_init(&waiter->list_entry, MAX_PRIO);
|
||||
plist_node_init(&waiter->pi_list_entry, MAX_PRIO);
|
||||
waiter->deadlock_task_pid = NULL;
|
||||
}
|
||||
|
||||
void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter)
|
||||
{
|
||||
put_pid(waiter->deadlock_task_pid);
|
||||
DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->list_entry));
|
||||
DEBUG_LOCKS_WARN_ON(!plist_node_empty(&waiter->pi_list_entry));
|
||||
memset(waiter, 0x22, sizeof(*waiter));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user