From ad9dd03db1002717f155c859ee613641620d3ba0 Mon Sep 17 00:00:00 2001 From: Alfred Chen Date: Fri, 29 Aug 2014 22:51:51 +0800 Subject: [PATCH] bfs: Refine resched_best_idle() call logic in schedule(). Idle or deactivated tasks don't need to be reschedule to other cpu in schedule(). There is dupicated resched_best_idle() call when prev needs other cpu to run. --- kernel/sched/bfs.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) Index: linux-3.17.2-bfsdev/kernel/sched/bfs.c =================================================================== --- linux-3.17.2-bfsdev.orig/kernel/sched/bfs.c 2014-11-11 11:45:09.458051716 +1100 +++ linux-3.17.2-bfsdev/kernel/sched/bfs.c 2014-11-11 11:45:09.457051716 +1100 @@ -3531,23 +3531,22 @@ need_resched: prev->last_ran = rq->clock_task; /* Task changed affinity off this CPU */ - if (needs_other_cpu(prev, cpu)) { - if (!deactivate) - resched_suitable_idle(prev); - } else if (!deactivate) { - if (!queued_notrunning()) { - /* - * We now know prev is the only thing that is - * awaiting CPU so we can bypass rechecking for - * the earliest deadline task and just run it - * again. - */ - set_rq_task(rq, prev); - check_smt_siblings(cpu); - grq_unlock_irq(); - goto rerun_prev_unlocked; - } else - swap_sticky(rq, cpu, prev); + if (likely(!needs_other_cpu(prev, cpu))) { + if (!deactivate) { + if (!queued_notrunning()) { + /* + * We now know prev is the only thing that is + * awaiting CPU so we can bypass rechecking for + * the earliest deadline task and just run it + * again. + */ + set_rq_task(rq, prev); + check_smt_siblings(cpu); + grq_unlock_irq(); + goto rerun_prev_unlocked; + } else + swap_sticky(rq, cpu, prev); + } } return_task(prev, rq, deactivate); } @@ -3569,7 +3568,11 @@ need_resched: } if (likely(prev != next)) { - resched_suitable_idle(prev); + /* + * Don't reschedule an idle task or deactivated tasks + */ + if ( prev != idle && !deactivate) + resched_suitable_idle(prev); /* * Don't stick tasks when a real time task is going to run as * they may literally get stuck.