Re: [PATCH v2 6/7] cpufreq: Preserve policy structure across suspend/resume

From: Viresh Kumar
Date: Tue Jul 30 2013 - 05:09:44 EST

On 30 July 2013 04:25, Srivatsa S. Bhat
<srivatsa.bhat@xxxxxxxxxxxxxxxxxx> wrote:
> To perform light-weight cpu-init and teardown in the cpufreq subsystem
> during suspend/resume, we need to separate out the 2 main functionalities
> of the cpufreq CPU hotplug callbacks, as outlined below:
> 1. Init/tear-down of core cpufreq and CPU-specific components, which are
> critical to the correct functioning of the cpufreq subsystem.
> 2. Init/tear-down of cpufreq sysfs files during suspend/resume.
> The first part requires accurate updates to the policy structure such as
> its ->cpus and ->related_cpus masks, whereas the second part requires that
> the policy->kobj structure is not released or re-initialized during
> suspend/resume.
> To handle both these requirements, we need to allow updates to the policy
> structure throughout suspend/resume, but prevent the structure from getting
> freed up. Also, we must have a mechanism by which the cpu-up callbacks can
> restore the policy structure, without allocating things afresh. (That also
> helps avoid memory leaks).
> To achieve this, we use 2 schemes:
> a. Use a fallback per-cpu storage area for preserving the policy structures
> during suspend, so that they can be restored during resume appropriately.
> b. Use the 'frozen' flag to determine when to free or allocate the policy
> structure vs when to restore the policy from the saved fallback storage.
> Thus we can successfully preserve the structure across suspend/resume.
> Effectively, this helps us complete the separation of the 'light-weight'
> and the 'full' init/tear-down sequences in the cpufreq subsystem, so that
> this can be made use of in the suspend/resume scenario.
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@xxxxxxxxxxxxxxxxxx>
> ---
> drivers/cpufreq/cpufreq.c | 69 +++++++++++++++++++++++++++++++++++----------
> 1 file changed, 53 insertions(+), 16 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at