[RFC v4 4/8] sched/fair: Define core capacity to limit task packing

From: Parth Shah
Date: Thu Jul 25 2019 - 14:03:49 EST

Define a method name arch_scale_core_capacity which should
return the capacity of the core. This method will be used in the future
patches to determine if the spare capacity is left in the core to pack
jitter tasks.

For some architectures, core capacity does not increase much with the
number of threads (or CPUs) in the core. For such cases, architecture
specific calculations needs to be done to find core capacity.

In addition to this, provide a default implementation for the scaling core

ToDo: As per Peter's comments, if we are getting rid of SMT capacity then
we need to find a workaround for limiting task packing. I'm working around
that trying to find a solution for the same but would like to get community
response first to have better view.

Signed-off-by: Parth Shah <parth@xxxxxxxxxxxxx>
kernel/sched/fair.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b798fe7ff7cd..793e1172afc7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5964,6 +5964,25 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
return cpu;

+#ifndef arch_scale_core_capacity
+static inline unsigned long arch_scale_core_capacity(int first_thread,
+ unsigned long smt_cap)
+ /* Default capacity of core is sum of cap of all the threads */
+ unsigned long ret = 0;
+ int sibling;
+ for_each_cpu(sibling, cpu_smt_mask(first_thread))
+ ret += cpu_rq(sibling)->cpu_capacity;
+ return ret;
* Try and locate an idle core/thread in the LLC cache domain.