[patch 04/10] PI-futex: scheduler support for PI

[patch 04/10] PI-futex: scheduler support for PI

Post by Ingo Molna » Mon, 27 Mar 2006 03:50:08


rom: Ingo Molnar < XXXX@XXXXX.COM >

add framework to boost/unboost the priority of RT tasks.

This consists of:

- caching the 'normal' priority in ->normal_prio
- providing a functions to set/get the priority of the task
- make sched_setscheduler() aware of boosting

Signed-off-by: Ingo Molnar < XXXX@XXXXX.COM >
Signed-off-by: Thomas Gleixner < XXXX@XXXXX.COM >
Signed-off-by: Arjan van de Ven < XXXX@XXXXX.COM >

----

include/linux/init_task.h | 1
include/linux/sched.h | 19 +++++-
kernel/sched.c | 136 ++++++++++++++++++++++++++++++++++++++++------
3 files changed, 138 insertions(+), 18 deletions(-)

Index: linux-pi-futex.mm.q/include/linux/init_task.h
===================================================================
--- linux-pi-futex.mm.q.orig/include/linux/init_task.h
+++ linux-pi-futex.mm.q/include/linux/init_task.h
@@ -87,6 +87,7 @@ extern struct group_info init_groups;
.lock_depth = -1, \
.prio = MAX_PRIO-20, \
.static_prio = MAX_PRIO-20, \
+ .normal_prio = MAX_PRIO-20, \
.policy = SCHED_NORMAL, \
.cpus_allowed = CPU_MASK_ALL, \
.mm = NULL, \
Index: linux-pi-futex.mm.q/include/linux/sched.h
===================================================================
--- linux-pi-futex.mm.q.orig/include/linux/sched.h
+++ linux-pi-futex.mm.q/include/linux/sched.h
@@ -486,7 +486,8 @@ struct signal_struct {

#define MAX_PRIO (MAX_RT_PRIO + 40)

-#define rt_task(p) (unlikely((p)->prio < MAX_RT_PRIO))
+#define rt_prio(prio) unlikely((prio) < MAX_RT_PRIO)
+#define rt_task(p) rt_prio((p)->prio)
#define batch_task(p) (unlikely((p)->policy == SCHED_BATCH))

/*
@@ -726,7 +727,7 @@ struct task_struct {
#endif
#endif
int load_weight; /* for niceness load balancing purposes */
- int prio, static_prio;
+ int prio, static_prio, normal_prio;
struct list_head run_list;
prio_array_t *array;

@@ -854,6 +855,9 @@ struct task_struct {
/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
spinlock_t alloc_lock;

+ /* Protection of the PI data structures: */
+ spinlock_t pi_lock;
+
#ifdef CONFIG_DEBUG_MUTEXES
/* mutex deadlock detection */
struct mutex_waiter *blocked_on;
@@ -1020,6 +1024,17 @@ static inline void idle_task_exit(void)
#endif

extern void sched_idle_next(void);
+
+#ifdef CONFIG_RT_MUTEXES
+extern int rt_mutex_getprio(task_t *p);
+extern void rt_mutex_setprio(task_t *p, int prio);
+#else
+static inline int rt_mutex_getprio(task_t *p)
+{
+ return p->normal_prio;
+}
+#endif
+
extern void set_user_nice(task_t *p, long nice);
extern int task_prio(const task_t *p);
extern int task_nice(const task_t *p);
Index: linux-pi-futex.mm.q/kernel/sched.c
===================================================================
--- linux-pi-futex.mm.q.orig/kernel/sched.c
+++ linux-pi-futex.mm.q/kernel/sched.c
@@ -643,7 +643,7 @@ static inline void enqueue_task_head(str
}

/*
- * effective_prio - return the priority that is based on the static
+ * __normal_prio - return the priority that is based on the static
* priority but is modified by bonuses/penalties.
*
* We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
@@ -656,13 +656,11 @@ static inline void enqueue_task_head(str
*
* Both properties are important to certain workloads.
*/
-static int effective_prio(task_t *p)
+
+static inli
 
 
 

[patch 04/10] PI-futex: scheduler support for PI

Post by Andrew Mor » Mon, 27 Mar 2006 12:10:11


This function is not really rt-mutex-related at all, is it? It's just a
piece of new scheduler functionality which various things might use.

If so, it should be named something non-mutexy and should be under a
different CONFIG_option which CONFIG_RT_MUTEXES selects.

Of course, we can do all that later on, if/when something else needs this
facility.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/

 
 
 

[patch 04/10] PI-futex: scheduler support for PI

Post by Ingo Molna » Tue, 28 Mar 2006 01:30:12


well, this particular function should only be used by the rt-mutex
subsystem, because it sets the priority of a task unconditionally.
Priority will vary depending on how other tasks block on a lock held by
this task. So if some other subsystem changes the priority via this
interface, it will both interfere with PI, and PI will interfere with
this.

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/