]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PM: EM: Slightly reduce em_check_capacity_update() overhead
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 21 Oct 2025 19:22:23 +0000 (15:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2025 13:08:53 +0000 (14:08 +0100)
[ Upstream commit a8e62726ac0dd7b610c87ba1a938a5a9091c34df ]

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 <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/1925950.tdWV9SEqCh@rjwysocki.net
Stable-dep-of: 1ebe8f7e7825 ("PM: EM: Fix late boot with holes in CPU topology")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/power/energy_model.c

index 8ee72c6c1daf34cb81b2cf0871cac89930d468d4..a035b030ff7345c952dcd6d3bdd1c00831b1af51 100644 (file)
@@ -769,7 +769,8 @@ static void em_check_capacity_update(void)
                }
                cpufreq_cpu_put(policy);
 
-               pd = em_cpu_get(cpu);
+               dev = get_cpu_device(cpu);
+               pd = em_pd_get(dev);
                if (!pd || em_is_artificial(pd))
                        continue;
 
@@ -793,7 +794,6 @@ static void em_check_capacity_update(void)
                pr_debug("updating cpu%d cpu_cap=%lu old capacity=%lu\n",
                         cpu, cpu_capacity, em_max_perf);
 
-               dev = get_cpu_device(cpu);
                em_adjust_new_capacity(dev, pd);
        }