Skip to content

Commit a8e6272

Browse files
committed
PM: EM: Slightly reduce em_check_capacity_update() overhead
Every iteration of the loop over all possible CPUs in em_check_capacity_update() causes get_cpu_device() to be called twice for the same CPU, once indirectly via em_cpu_get() and once directly. Get rid of the indirect get_cpu_device() call by moving the direct invocation of it earlier and using em_pd_get() instead of em_cpu_get() to get a pd pointer for the dev one returned by it. This also exposes the fact that dev is needed to get a pd, so the code becomes somewhat easier to follow after it. No functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Lukasz Luba <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 5fad775 commit a8e6272

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/power/energy_model.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,8 @@ static void em_check_capacity_update(void)
774774
}
775775
cpufreq_cpu_put(policy);
776776

777-
pd = em_cpu_get(cpu);
777+
dev = get_cpu_device(cpu);
778+
pd = em_pd_get(dev);
778779
if (!pd || em_is_artificial(pd))
779780
continue;
780781

@@ -798,7 +799,6 @@ static void em_check_capacity_update(void)
798799
pr_debug("updating cpu%d cpu_cap=%lu old capacity=%lu\n",
799800
cpu, cpu_capacity, em_max_perf);
800801

801-
dev = get_cpu_device(cpu);
802802
em_adjust_new_capacity(dev, pd);
803803
}
804804

0 commit comments

Comments
 (0)