On 22-07-15, 18:42, Rafael J. Wysocki wrote:
- what happens when 'policy' is NULL at the point when the first (few) CPUs are added - how do the symlinks get created later if/when policy becomes non-NULL (can it?)
Yes, it can, and we have a design issue here that bothers me a bit.
I replied to Russell with a NO here as the first CPU should have created the policy. BUT...
Namley, we need a driver's ->init callback to populate policy->cpus for us, but this is not the only thing it is doing, so the concern is that it may not be able to deal with CPUs that aren't online.
... the first few CPUs could have been offline and so we might not have tried to add the policy at all.. Need to fix that for sure.
I was thinking about an additional driver callback that would *only* populate a mask of CPUs that should use the same policy as the given one.
Why so ? Drivers today are required to set policy->cpus with all CPUs that should be managed by that policy. i.e. all online+offline. So, actually ->init() fills policy->cpus with the value of policy->related_cpus.
Yes, I thought earlier to change that by setting policy->related_cpus from drivers, instead of policy->cpus and wasn't sure if I should do that :)
We'd be able to call that from cpufreq_add_dev() for offline CPUs too and this way the policy object could be created for the first CPU using the policy that is registered instead of being added for the first CPU using that policy that becomes online (which happens today).
Creating policy for offline CPUs doesn't look that great to me.
What we can do to fix the problem in hand, is to update a global mask of CPUs (with policy == NULL) which were offline when cpufreq_add_dev() was called for them. And when we create the policy, we can add links for all such CPUs.