qos: Speed up plist traversal in pm_qos_set_value_for_cpus()

The plist is already sorted and traversed in ascending order of PM QoS
value, so we can simply look at the lowest PM QoS values which affect
the given request's CPUs until we've looked at all of them, at which
point the traversal can be stopped early. This also lets us get rid of
the pesky qos_val array.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
This commit is contained in:
Sultan Alsawaf 2021-10-17 23:50:33 -07:00 committed by Forenche
parent 5427f42c31
commit 5e4191177a
No known key found for this signature in database
GPG Key ID: 1337D655BAFE85E2

View File

@ -274,9 +274,6 @@ static inline int pm_qos_set_value_for_cpus(struct pm_qos_request *new_req,
unsigned long new_cpus,
enum pm_qos_req_action new_action)
{
s32 qos_val[NR_CPUS] = {
[0 ... (NR_CPUS - 1)] = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE
};
struct pm_qos_request *req;
unsigned long new_req_cpus;
int cpu;
@ -319,14 +316,19 @@ static inline int pm_qos_set_value_for_cpus(struct pm_qos_request *new_req,
continue;
for_each_cpu(cpu, to_cpumask(&affected_cpus)) {
if (qos_val[cpu] > req->node.prio)
qos_val[cpu] = req->node.prio;
if (c->target_per_cpu[cpu] != req->node.prio) {
c->target_per_cpu[cpu] = req->node.prio;
*cpus |= BIT(cpu);
}
}
if (!(new_req_cpus &= ~affected_cpus))
return 0;
}
for_each_cpu(cpu, to_cpumask(&new_req_cpus)) {
if (c->target_per_cpu[cpu] != qos_val[cpu]) {
c->target_per_cpu[cpu] = qos_val[cpu];
if (c->target_per_cpu[cpu] != PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE) {
c->target_per_cpu[cpu] = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
*cpus |= BIT(cpu);
}
}