Pārlūkot izejas kodu

sched: Add struct rq::cpu_capacity_orig

This new field 'cpu_capacity_orig' reflects the original capacity of a CPU
before being altered by rt tasks and/or IRQ

The cpu_capacity_orig will be used:

  - to detect when the capacity of a CPU has been noticeably reduced so we can
    trig load balance to look for a CPU with better capacity. As an example, we
    can detect when a CPU handles a significant amount of irq
    (with CONFIG_IRQ_TIME_ACCOUNTING) but this CPU is seen as an idle CPU by
    scheduler whereas CPUs, which are really idle, are available.

  - evaluate the available capacity for CFS tasks

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Acked-by: Morten Rasmussen <morten.rasmussen@arm.com>
Cc: Morten.Rasmussen@arm.com
Cc: dietmar.eggemann@arm.com
Cc: efault@gmx.de
Cc: linaro-kernel@lists.linaro.org
Cc: nicolas.pitre@linaro.org
Cc: preeti@linux.vnet.ibm.com
Cc: riel@redhat.com
Link: http://lkml.kernel.org/r/1425052454-25797-7-git-send-email-vincent.guittot@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Vincent Guittot 10 gadi atpakaļ
vecāks
revīzija
ca6d75e690
3 mainītis faili ar 9 papildinājumiem un 2 dzēšanām
  1. 1 1
      kernel/sched/core.c
  2. 7 1
      kernel/sched/fair.c
  3. 1 0
      kernel/sched/sched.h

+ 1 - 1
kernel/sched/core.c

@@ -7216,7 +7216,7 @@ void __init sched_init(void)
 #ifdef CONFIG_SMP
 #ifdef CONFIG_SMP
 		rq->sd = NULL;
 		rq->sd = NULL;
 		rq->rd = NULL;
 		rq->rd = NULL;
-		rq->cpu_capacity = SCHED_CAPACITY_SCALE;
+		rq->cpu_capacity = rq->cpu_capacity_orig = SCHED_CAPACITY_SCALE;
 		rq->post_schedule = 0;
 		rq->post_schedule = 0;
 		rq->active_balance = 0;
 		rq->active_balance = 0;
 		rq->next_balance = jiffies;
 		rq->next_balance = jiffies;

+ 7 - 1
kernel/sched/fair.c

@@ -4363,6 +4363,11 @@ static unsigned long capacity_of(int cpu)
 	return cpu_rq(cpu)->cpu_capacity;
 	return cpu_rq(cpu)->cpu_capacity;
 }
 }
 
 
+static unsigned long capacity_orig_of(int cpu)
+{
+	return cpu_rq(cpu)->cpu_capacity_orig;
+}
+
 static unsigned long cpu_avg_load_per_task(int cpu)
 static unsigned long cpu_avg_load_per_task(int cpu)
 {
 {
 	struct rq *rq = cpu_rq(cpu);
 	struct rq *rq = cpu_rq(cpu);
@@ -6040,6 +6045,7 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu)
 
 
 	capacity >>= SCHED_CAPACITY_SHIFT;
 	capacity >>= SCHED_CAPACITY_SHIFT;
 
 
+	cpu_rq(cpu)->cpu_capacity_orig = capacity;
 	sdg->sgc->capacity_orig = capacity;
 	sdg->sgc->capacity_orig = capacity;
 
 
 	capacity *= scale_rt_capacity(cpu);
 	capacity *= scale_rt_capacity(cpu);
@@ -6094,7 +6100,7 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
 			 * Runtime updates will correct capacity_orig.
 			 * Runtime updates will correct capacity_orig.
 			 */
 			 */
 			if (unlikely(!rq->sd)) {
 			if (unlikely(!rq->sd)) {
-				capacity_orig += capacity_of(cpu);
+				capacity_orig += capacity_orig_of(cpu);
 				capacity += capacity_of(cpu);
 				capacity += capacity_of(cpu);
 				continue;
 				continue;
 			}
 			}

+ 1 - 0
kernel/sched/sched.h

@@ -615,6 +615,7 @@ struct rq {
 	struct sched_domain *sd;
 	struct sched_domain *sd;
 
 
 	unsigned long cpu_capacity;
 	unsigned long cpu_capacity;
+	unsigned long cpu_capacity_orig;
 
 
 	unsigned char idle_balance;
 	unsigned char idle_balance;
 	/* For active balancing */
 	/* For active balancing */