core_ctl: Isolate not_preferred CPUs first during max_cpus limiting
When CPUs are limited via max_cpus tunable, core_ctl first try
to isolate the non busy CPUs. During this, not_preferred CPUs are
skipped. If more CPUs have to be isolated, CPUs are isolated
in the sequential order without checking not_preferred hint.
So we may end up keeping not_preferred CPUs active after this
step. Add another step to isolate the not_preferred CPUs first
during max_cpus limiting.
Change-Id: If2c5c9d9c69718c1e586cd81c1af0ed0b5d13075
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
diff --git a/kernel/sched/core_ctl.c b/kernel/sched/core_ctl.c
index 26c9cf4..bd64b1a 100644
--- a/kernel/sched/core_ctl.c
+++ b/kernel/sched/core_ctl.c
@@ -789,6 +789,7 @@
unsigned long flags;
unsigned int num_cpus = cluster->num_cpus;
unsigned int nr_isolated = 0;
+ bool first_pass = cluster->nr_not_preferred_cpus;
/*
* Protect against entry being removed (and added at tail) by other
@@ -834,6 +835,7 @@
cluster->nr_isolated_cpus += nr_isolated;
spin_unlock_irqrestore(&state_lock, flags);
+again:
/*
* If the number of active CPUs is within the limits, then
* don't force isolation of any busy CPUs.
@@ -853,6 +855,9 @@
if (cluster->active_cpus <= cluster->max_cpus)
break;
+ if (first_pass && !c->not_preferred)
+ continue;
+
spin_unlock_irqrestore(&state_lock, flags);
pr_debug("Trying to isolate CPU%u\n", c->cpu);
@@ -869,6 +874,10 @@
cluster->nr_isolated_cpus += nr_isolated;
spin_unlock_irqrestore(&state_lock, flags);
+ if (first_pass && cluster->active_cpus > cluster->max_cpus) {
+ first_pass = false;
+ goto again;
+ }
}
static void __try_to_unisolate(struct cluster_data *cluster,