Re: [PATCH v5 03/23] PM: EM: Find first CPU active while updating OPP efficiency

From: Lukasz Luba
Date: Tue Jan 02 2024 - 04:40:56 EST




On 12/28/23 17:13, Qais Yousef wrote:
On 12/19/23 10:53, Lukasz Luba wrote:


On 12/17/23 17:58, Qais Yousef wrote:
On 11/29/23 11:08, Lukasz Luba wrote:
The Energy Model might be updated at runtime and the energy efficiency
for each OPP may change. Thus, there is a need to update also the
cpufreq framework and make it aligned to the new values. In order to
do that, use a first active CPU from the Performance Domain. This is
needed since the first CPU in the cpumask might be offline when we
run this code path.

I didn't understand the problem here. It seems you're fixing a race, but the
description is not clear to me what the race is.

I have explained that in v1, v4 comments for this patch.
When the EM is registered the fist CPU is always online. No problem
for the old code, but for new code with runtime modification at
later time, potentially from different subsystems - it it (e.g. thermal,
drivers, etc). The fist CPU might be offline, but still such EM
update for this domain shouldn'y fail. Although, when the CPU is offline
we cannot get the valid policy...

We can get it for next cpu in the cpumask, that's what the code is
doing.

Okay, I can see now that cpufreq_cpu_get_raw() ignores offline CPUs
intentionally.

A new variant seems better to me. But the experts know better. So LGTM.

Thanks. Yes, I will gently ask Viresh to have a look at those places
cpufreq related places.