sched: consider migration thread with smp nice
PATCH 1/1 sched: consider migration thread with smp nice
This patch improves throughput with the smp nice balancing code. Many thanks to Martin Bligh for the usage of his regression testing bed to confirm the effectiveness of various patches.
Con
---
The intermittent scheduling of the migration thread at ultra high priority makes the smp nice handling see that runqueue as being heavily loaded. The migration thread itself actually handles the balancing so its influence on priority balancing should be ignored.
kernel/sched.c +26 -9
@@ -669,6 +669,31 @@ static inline void dec_prio_bias(runqueu { rq->prio_bias -=MAX_PRIO - prio; } + +static inline void inc_nr_running (task_t *p,runqueue_t *rq) +{ + rq->nr_running++; +if (rt_task (p)) { +if (p != rq->migration_thread) +/* +* The migration thread does the actual balancing. Do +* not bias by its priority as the ultra high priority +* will skew balancing adversely. +*/ +inc_prio_bias (rq, p->prio); + }else +inc_prio_bias (rq, p->static_prio); +} + +static inline void dec_nr_running (task_t *p,runqueue_t *rq) +{ + rq->nr_running--; +if (rt_task (p)) { +if (p != rq->migration_thread) +dec_prio_bias (rq, p->prio); + }else +dec_prio_bias (rq, p->static_prio); +}#else static inline void inc_prio_bias (runqueue_t *rq,int prio) {
@@ -677,25 +702,17 @@ static inline void inc_prio_bias(runqueustatic inline void dec_prio_bias (runqueue_t *rq,int prio) { } -#endif static inline void inc_nr_running (task_t *p,runqueue_t *rq) { rq->nr_running++; -if (rt_task (p)) -inc_prio_bias (rq, p->prio); -else -inc_prio_bias (rq, p->static_prio); }static inline void dec_nr_running (task_t *p,runqueue_t *rq) { rq->nr_running--; -if (rt_task (p)) -dec_prio_bias (rq, p->prio); -else -dec_prio_bias (rq, p->static_prio); } +#endif /* * __activate_task - move a task to the runqueue.
Quoted 1 line · Con Kolivas
This patch improves throughput with the smp nice balancing code. Many thanks to Martin Bligh for the usage of his regression testing bed to confirm the effectiveness of various patches.
Con,
This doesn't build on non SMP systems due to the migration_thread field
only being defined for SMP. Attached is a copy of a slightly modified PlugSched version of the patch which I used to fix the problem in PlugSched. Even though it's for a different file it should be easy to copy over.
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce
include/linux/sched_pvt.h +23 -6
@@ -393,6 +393,11 @@ { rq->prio_bias -=MAX_STATIC_PRIO - prio; } + +static inline int is_migration_thread (const task_t *p,const runqueue_t *rq) +{ +return p == rq->migration_thread; +}#else static inline void inc_prio_bias (runqueue_t *rq,int prio) {
@@ -401,23 +406,35 @@static inline void dec_prio_bias (runqueue_t *rq,int prio) { } + +static inline int is_migration_thread (const task_t *p,const runqueue_t *rq) +{ +return 0 ; +}#endif static inline void inc_nr_running (task_t *p,runqueue_t *rq) { rq->nr_running++; -if (rt_task (p)) -inc_prio_bias (rq, p->prio); -else +if (rt_task (p)) { +if (!is_migration_thread (p, rq)) +/* +* The migration thread does the actual balancing. Do +* not bias by its priority as the ultra high priority +* will skew balancing adversely. +*/ +inc_prio_bias (rq, p->prio); + }else inc_prio_bias (rq, p->static_prio); }static inline void dec_nr_running (task_t *p,runqueue_t *rq) { rq->nr_running--; -if (rt_task (p)) -dec_prio_bias (rq, p->prio); -else +if (rt_task (p)) { +if (!is_migration_thread (p, rq)) +dec_prio_bias (rq, p->prio); + }else dec_prio_bias (rq, p->static_prio); }
Quoted 11 lines · Peter Williams
Quoted 3 lines · Con Kolivas
This patch improves throughput with the smp nice balancing code. Many thanks to Martin Bligh for the usage of his regression testing bed to confirm the effectiveness of various patches.
Con,
This doesn't build on non SMP systems due to themigration_threadfield
only being defined for SMP. Attached is a copy of a slightly modified PlugSched version of the patch which I used to fix the problem in PlugSched. Even though it's for a different file it should be easy to copy over.
Peter
Look at the actual patch I sent out you'll see it moved the ifdefs up to compensate. I believe your port of my patch doesn't build and I suspect it's because you missed these ifdef movements ;)
Cheers,
Con
Quoted 16 lines · Con Kolivas
Quoted 6 lines · Peter Williams
Quoted 3 lines · Con Kolivas
This patch improves throughput with the smp nice balancing code. Many thanks to Martin Bligh for the usage of his regression testing bed to confirm the effectiveness of various patches.
Quoted 6 lines
Con,
This doesn't build on non SMP systems due to themigration_threadfield
only being defined for SMP. Attached is a copy of a slightly modified PlugSched version of the patch which I used to fix the problem in PlugSched. Even though it's for a different file it should be easy to copy over.
Quoted 3 lines
Peter
Look at the actual patch I sent out you'll see it moved the ifdefs up to compensate. I believe your port of my patch doesn't build and I suspect it's because you missed these ifdef movements ;)
Yes, I should have read the patch more carefully.
Sorry about that,
Peter
Signature · 4 lines
Peter Williams [email protected] "Learning, n. The kind of ignorance distinguishing the studious." -- Ambrose Bierce