BACKPORT: sched: Add a new function to compare if two cpus have the same capacity

The new helper function is needed to help blk-mq check if it needs to
dispatch the softirq on another CPU to match the performance level the
IO requester is running at. This is important on HMP systems where not
all CPUs have the same compute capacity.

Bug: 341551538
Signed-off-by: Qais Yousef <qyousef@layalina.io>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240223155749.2958009-2-qyousef@layalina.io
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit b361c9027b4e4159e7bcca4eb64fd26507c19994)
[Trivial clash due to some code shuffling between versions]
Signed-off-by: Qais Yousef <qyousef@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:ee8168e00c6e4fb04bea953bacb61ff017a39f63)
Merged-In: I58f3f3e3560f4800b5c73b3c85bbfdf628e9764e
Change-Id: I58f3f3e3560f4800b5c73b3c85bbfdf628e9764e
This commit is contained in:
Qais Yousef 2024-02-23 15:57:48 +00:00 committed by Treehugger Robot
parent e4622d460e
commit cf4893eb95
2 changed files with 17 additions and 0 deletions

View file

@ -186,6 +186,7 @@ extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
cpumask_var_t *alloc_sched_domains(unsigned int ndoms);
void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms);
bool cpus_equal_capacity(int this_cpu, int that_cpu);
bool cpus_share_cache(int this_cpu, int that_cpu);
typedef const struct cpumask *(*sched_domain_mask_f)(int cpu);
@ -235,6 +236,11 @@ partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
{
}
static inline bool cpus_equal_capacity(int this_cpu, int that_cpu)
{
return true;
}
static inline bool cpus_share_cache(int this_cpu, int that_cpu)
{
return true;

View file

@ -3959,6 +3959,17 @@ out:
}
EXPORT_SYMBOL_GPL(wake_up_if_idle);
bool cpus_equal_capacity(int this_cpu, int that_cpu)
{
if (!sched_asym_cpucap_active())
return true;
if (this_cpu == that_cpu)
return true;
return arch_scale_cpu_capacity(this_cpu) == arch_scale_cpu_capacity(that_cpu);
}
bool cpus_share_cache(int this_cpu, int that_cpu)
{
if (this_cpu == that_cpu)