--- kernel/sched/bfs.c | 49 +++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) Index: linux-4.1-bfs/kernel/sched/bfs.c =================================================================== --- linux-4.1-bfs.orig/kernel/sched/bfs.c 2015-08-02 17:34:13.340388825 +1000 +++ linux-4.1-bfs/kernel/sched/bfs.c 2015-08-02 18:21:33.857686300 +1000 @@ -134,7 +134,7 @@ void print_scheduler_version(void) { - printk(KERN_INFO "BFS CPU scheduler v0.462 by Con Kolivas.\n"); + printk(KERN_INFO "BFS CPU scheduler v0.463 by Con Kolivas.\n"); } /* @@ -3361,18 +3361,16 @@ static void __sched __schedule(void) { struct task_struct *prev, *next, *idle; unsigned long *switch_count; - bool deactivate; + bool deactivate = false; struct rq *rq; int cpu; -need_resched: preempt_disable(); cpu = smp_processor_id(); rq = cpu_rq(cpu); rcu_note_context_switch(); prev = rq->curr; - deactivate = false; schedule_debug(prev); /* @@ -3413,17 +3411,6 @@ need_resched: switch_count = &prev->nvcsw; } - /* - * If we are going to sleep and we have plugged IO queued, make - * sure to submit it to avoid deadlocks. This usually clears before - * grabbing the lock but still may rarely happen here. */ - if (unlikely(deactivate && blk_needs_flush_plug(prev))) { - grq_unlock_irq(); - preempt_enable_no_resched(); - blk_schedule_flush_plug(prev); - goto need_resched; - } - update_clocks(rq); update_cpu_clock_switch(rq, prev); if (rq->clock - rq->last_tick > HALF_JIFFY_NS) @@ -3912,8 +3899,8 @@ static inline struct task_struct *find_p } /* Actually do priority change: must hold grq lock. */ -static void -__setscheduler(struct task_struct *p, struct rq *rq, int policy, int prio) +static void __setscheduler(struct task_struct *p, struct rq *rq, int policy, + int prio, bool keep_boost) { int oldrtprio, oldprio; @@ -3922,8 +3909,14 @@ __setscheduler(struct task_struct *p, st p->rt_priority = prio; p->normal_prio = normal_prio(p); oldprio = p->prio; - /* we are holding p->pi_lock already */ - p->prio = rt_mutex_getprio(p); + /* + * Keep a potential priority boosting if called from + * sched_setscheduler(). + */ + if (keep_boost) + p->prio = rt_mutex_get_effective_prio(p, p->normal_prio); + else + p->prio = p->normal_prio; if (task_running(p)) { reset_rq_task(rq, p); /* Resched only if we might now be preempted */ @@ -4104,7 +4097,7 @@ recheck: queued = task_queued(p); if (queued) dequeue_task(p); - __setscheduler(p, rq, policy, param->sched_priority); + __setscheduler(p, rq, policy, param->sched_priority, true); if (queued) { enqueue_task(p, rq); try_preempt(p, rq); @@ -4825,22 +4818,18 @@ EXPORT_SYMBOL_GPL(yield_to); long __sched io_schedule_timeout(long timeout) { - struct task_struct *curr = current; - int old_iowait = curr->in_iowait; + int old_iowait = current->in_iowait; struct rq *rq; long ret; - curr->in_iowait = 1; - if (old_iowait) - blk_schedule_flush_plug(curr); - else - blk_flush_plug(curr); + current->in_iowait = 1; + blk_schedule_flush_plug(current); delayacct_blkio_start(); rq = raw_rq(); atomic_inc(&rq->nr_iowait); ret = schedule_timeout(timeout); - curr->in_iowait = old_iowait; + current->in_iowait = old_iowait; atomic_dec(&rq->nr_iowait); delayacct_blkio_end(); @@ -6153,6 +6142,7 @@ sd_init(struct sched_domain_topology_lev */ if (sd->flags & SD_SHARE_CPUCAPACITY) { + sd->flags |= SD_PREFER_SIBLING; sd->imbalance_pct = 110; sd->smt_gain = 1178; /* ~15% */ @@ -6809,7 +6799,6 @@ static int cpuset_cpu_active(struct noti */ case CPU_ONLINE: - case CPU_DOWN_FAILED: cpuset_update_active_cpus(true); break; default: @@ -7166,7 +7155,7 @@ void normalize_rt_tasks(void) queued = task_queued(p); if (queued) dequeue_task(p); - __setscheduler(p, rq, SCHED_NORMAL, 0); + __setscheduler(p, rq, SCHED_NORMAL, 0, false); if (queued) { enqueue_task(p, rq); try_preempt(p, rq);