diff mbox

S3, SMP non boot cpus and /sys/devices/system/cpu[1-9]/cpufreq/scaling_max_freq

Message ID 51924221.2080707@linux.vnet.ibm.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Srivatsa S. Bhat May 14, 2013, 1:54 p.m. UTC
On 05/14/2013 06:30 PM, Rafael J. Wysocki wrote:
> On Tuesday, May 14, 2013 06:04:48 PM Srivatsa S. Bhat wrote:
>> On 05/14/2013 05:24 PM, Jarzmik, Robert wrote:
>>>> Okay, agreed after looking at this discussion ;) I am fine with the approach of kernel preserving permissions too.
>>>
>>> Ok, that's great, yet I don't see a clean solution here.  This is
>>> the path I see and that bothers me in the S3 suspend path:
>>> cpufreq_sysfs_release
>>>   kobject_cleanup
>>>     kobject_release
>>>       kobject_put
>>>         __cpufreq_remove_dev
>>>           cpufreq_cpu_callback
>>>             notifier_call_chain
>>>               __raw_notifier_call_chain
>>>                 __cpu_notify
>>>                   _cpu_down
>>>
>>> Here the sysfs attributes are destroyed. Cpu onlining will
>>> recreate them with root permissions. I don't see a good clean way
>>> to preserve permissions in sysfs across suspend/resume for
>>> deleted nodes. Do you ?
>>>
>>> And here we come to my actual worry : what is the technical clean
>>> way to solve this problem ?
>>>
>>> So far I have no idea (the cpufreq example is only a subset of
>>> the cases where it could happen). So if someone comes up with a
>>> good idea I'll volunteer to implement it :)
>>>
>>
>> Does the below (untested) patch help? I haven't spent time investigating
>> whether not doing the add_dev/remove_dev stuff during CPU hotplug in S3 path
>> will break something else. But it would be great if this works, since
>> its the simplest solution that I can think of.
> 
> Well, what if the CPU doesn't come up during resume?
> 

Hmm, that's a good point. We will need to remove the sysfs files in that
case. The updated patch below uses CPU_UP_CANCELED_FROZEN notification
to do that.

Regards,
Srivatsa S. Bhat

----------------------------------------------------------------------->

From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Subject: [PATCH v2] cpufreq: Preserve sysfs file permissions across suspend/resume

The file permissions of cpufreq per-cpu sysfs files are not preserved across
suspend/resume because we internally go through the CPU Hotplug path which
reinitializes the file permissions on CPU online.

But the user is not supposed to know that we are using CPU hotplug
internally within suspend/resume (IOW, the kernel should not silently wreck
the user-set file permissions across a suspend cycle). Therefore, we need to
preserve the file permissions as it is, across suspend/resume.

The simplest way to achieve that is to just not touch the sysfs files at
all - ie., just ignore the CPU hotplug events in the suspend/resume path
(_FROZEN) in the cpufreq hotplug callback.

Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
Reported-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---
v2: Use UP_CANCELED_FROZEN notification to delete the sysfs files if the
CPUs don't come up during resume.

 drivers/cpufreq/cpufreq.c       |    4 +---
 drivers/cpufreq/cpufreq_stats.c |    7 ++++---
 2 files changed, 5 insertions(+), 6 deletions(-)




--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Rafael Wysocki May 14, 2013, 8:22 p.m. UTC | #1
On Tuesday, May 14, 2013 07:24:41 PM Srivatsa S. Bhat wrote:
> On 05/14/2013 06:30 PM, Rafael J. Wysocki wrote:
> > On Tuesday, May 14, 2013 06:04:48 PM Srivatsa S. Bhat wrote:
> >> On 05/14/2013 05:24 PM, Jarzmik, Robert wrote:
> >>>> Okay, agreed after looking at this discussion ;) I am fine with the approach of kernel preserving permissions too.
> >>>
> >>> Ok, that's great, yet I don't see a clean solution here.  This is
> >>> the path I see and that bothers me in the S3 suspend path:
> >>> cpufreq_sysfs_release
> >>>   kobject_cleanup
> >>>     kobject_release
> >>>       kobject_put
> >>>         __cpufreq_remove_dev
> >>>           cpufreq_cpu_callback
> >>>             notifier_call_chain
> >>>               __raw_notifier_call_chain
> >>>                 __cpu_notify
> >>>                   _cpu_down
> >>>
> >>> Here the sysfs attributes are destroyed. Cpu onlining will
> >>> recreate them with root permissions. I don't see a good clean way
> >>> to preserve permissions in sysfs across suspend/resume for
> >>> deleted nodes. Do you ?
> >>>
> >>> And here we come to my actual worry : what is the technical clean
> >>> way to solve this problem ?
> >>>
> >>> So far I have no idea (the cpufreq example is only a subset of
> >>> the cases where it could happen). So if someone comes up with a
> >>> good idea I'll volunteer to implement it :)
> >>>
> >>
> >> Does the below (untested) patch help? I haven't spent time investigating
> >> whether not doing the add_dev/remove_dev stuff during CPU hotplug in S3 path
> >> will break something else. But it would be great if this works, since
> >> its the simplest solution that I can think of.
> > 
> > Well, what if the CPU doesn't come up during resume?
> > 
> 
> Hmm, that's a good point. We will need to remove the sysfs files in that
> case. The updated patch below uses CPU_UP_CANCELED_FROZEN notification
> to do that.
> 
> Regards,
> Srivatsa S. Bhat
> 
> ----------------------------------------------------------------------->
> 
> From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> Subject: [PATCH v2] cpufreq: Preserve sysfs file permissions across suspend/resume
> 
> The file permissions of cpufreq per-cpu sysfs files are not preserved across
> suspend/resume because we internally go through the CPU Hotplug path which
> reinitializes the file permissions on CPU online.
> 
> But the user is not supposed to know that we are using CPU hotplug
> internally within suspend/resume (IOW, the kernel should not silently wreck
> the user-set file permissions across a suspend cycle). Therefore, we need to
> preserve the file permissions as it is, across suspend/resume.
> 
> The simplest way to achieve that is to just not touch the sysfs files at
> all - ie., just ignore the CPU hotplug events in the suspend/resume path
> (_FROZEN) in the cpufreq hotplug callback.
> 
> Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
> Reported-by: Durgadoss R <durgadoss.r@intel.com>
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

It makes sense to me.

Robert, Durga, does this work for you?

Rafael


> ---
> v2: Use UP_CANCELED_FROZEN notification to delete the sysfs files if the
> CPUs don't come up during resume.
> 
>  drivers/cpufreq/cpufreq.c       |    4 +---
>  drivers/cpufreq/cpufreq_stats.c |    7 ++++---
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 1b8a48e..284ba63 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1832,15 +1832,13 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
>  	if (dev) {
>  		switch (action) {
>  		case CPU_ONLINE:
> -		case CPU_ONLINE_FROZEN:
>  			cpufreq_add_dev(dev, NULL);
>  			break;
>  		case CPU_DOWN_PREPARE:
> -		case CPU_DOWN_PREPARE_FROZEN:
> +		case CPU_UP_CANCELED_FROZEN:
>  			__cpufreq_remove_dev(dev, NULL);
>  			break;
>  		case CPU_DOWN_FAILED:
> -		case CPU_DOWN_FAILED_FROZEN:
>  			cpufreq_add_dev(dev, NULL);
>  			break;
>  		}
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index bfd6273..fb65dec 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -349,15 +349,16 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
>  
>  	switch (action) {
>  	case CPU_ONLINE:
> -	case CPU_ONLINE_FROZEN:
>  		cpufreq_update_policy(cpu);
>  		break;
>  	case CPU_DOWN_PREPARE:
> -	case CPU_DOWN_PREPARE_FROZEN:
>  		cpufreq_stats_free_sysfs(cpu);
>  		break;
>  	case CPU_DEAD:
> -	case CPU_DEAD_FROZEN:
> +		cpufreq_stats_free_table(cpu);
> +		break;
> +	case CPU_UP_CANCELED_FROZEN:
> +		cpufreq_stats_free_sysfs(cpu);
>  		cpufreq_stats_free_table(cpu);
>  		break;
>  	}
> 
> 
>
Viresh Kumar May 15, 2013, 6:16 a.m. UTC | #2
On 14 May 2013 19:24, Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> wrote:
> From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> Subject: [PATCH v2] cpufreq: Preserve sysfs file permissions across suspend/resume
>
> The file permissions of cpufreq per-cpu sysfs files are not preserved across
> suspend/resume because we internally go through the CPU Hotplug path which
> reinitializes the file permissions on CPU online.
>
> But the user is not supposed to know that we are using CPU hotplug
> internally within suspend/resume (IOW, the kernel should not silently wreck
> the user-set file permissions across a suspend cycle). Therefore, we need to
> preserve the file permissions as it is, across suspend/resume.
>
> The simplest way to achieve that is to just not touch the sysfs files at
> all - ie., just ignore the CPU hotplug events in the suspend/resume path
> (_FROZEN) in the cpufreq hotplug callback.
>
> Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
> Reported-by: Durgadoss R <durgadoss.r@intel.com>
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> ---
> v2: Use UP_CANCELED_FROZEN notification to delete the sysfs files if the
> CPUs don't come up during resume.

Is it also possible that more cpus come up after resume? i.e. we had 2 cpus
at suspend and 3 at resume?

>  drivers/cpufreq/cpufreq.c       |    4 +---
>  drivers/cpufreq/cpufreq_stats.c |    7 ++++---
>  2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 1b8a48e..284ba63 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1832,15 +1832,13 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
>         if (dev) {
>                 switch (action) {
>                 case CPU_ONLINE:
> -               case CPU_ONLINE_FROZEN:
>                         cpufreq_add_dev(dev, NULL);
>                         break;
>                 case CPU_DOWN_PREPARE:
> -               case CPU_DOWN_PREPARE_FROZEN:
> +               case CPU_UP_CANCELED_FROZEN:
>                         __cpufreq_remove_dev(dev, NULL);
>                         break;
>                 case CPU_DOWN_FAILED:
> -               case CPU_DOWN_FAILED_FROZEN:
>                         cpufreq_add_dev(dev, NULL);
>                         break;

I have forgotten meaning of these flags now :(
So, CPU_ONLINE, CPU_DOWN_PREPARE and CPU_DOWN_FAILED
are called when cpus are added/removed (but not for cpu_down in suspend
resume)? and _FROZEN ones are only used for s2r/s2d?
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Srivatsa S. Bhat May 15, 2013, 6:30 a.m. UTC | #3
On 05/15/2013 11:46 AM, Viresh Kumar wrote:
> On 14 May 2013 19:24, Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> wrote:
>> From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
>> Subject: [PATCH v2] cpufreq: Preserve sysfs file permissions across suspend/resume
>>
>> The file permissions of cpufreq per-cpu sysfs files are not preserved across
>> suspend/resume because we internally go through the CPU Hotplug path which
>> reinitializes the file permissions on CPU online.
>>
>> But the user is not supposed to know that we are using CPU hotplug
>> internally within suspend/resume (IOW, the kernel should not silently wreck
>> the user-set file permissions across a suspend cycle). Therefore, we need to
>> preserve the file permissions as it is, across suspend/resume.
>>
>> The simplest way to achieve that is to just not touch the sysfs files at
>> all - ie., just ignore the CPU hotplug events in the suspend/resume path
>> (_FROZEN) in the cpufreq hotplug callback.
>>
>> Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
>> Reported-by: Durgadoss R <durgadoss.r@intel.com>
>> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
>> ---
>> v2: Use UP_CANCELED_FROZEN notification to delete the sysfs files if the
>> CPUs don't come up during resume.
> 
> Is it also possible that more cpus come up after resume? i.e. we had 2 cpus
> at suspend and 3 at resume?

Nope. That's not possible. While suspending we note down the online non-boot
CPUs we have, in a cpumask, and take them offline. On resume, we try to online
the CPUs in that cpumask. So there is no chance for more CPUs to come up during
resume.

> 
>>  drivers/cpufreq/cpufreq.c       |    4 +---
>>  drivers/cpufreq/cpufreq_stats.c |    7 ++++---
>>  2 files changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index 1b8a48e..284ba63 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -1832,15 +1832,13 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
>>         if (dev) {
>>                 switch (action) {
>>                 case CPU_ONLINE: 
>> -               case CPU_ONLINE_FROZEN:
>>                         cpufreq_add_dev(dev, NULL);
>>                         break;
>>                 case CPU_DOWN_PREPARE:
>> -               case CPU_DOWN_PREPARE_FROZEN:
>> +               case CPU_UP_CANCELED_FROZEN:
>>                         __cpufreq_remove_dev(dev, NULL);
>>                         break;
>>                 case CPU_DOWN_FAILED:
>> -               case CPU_DOWN_FAILED_FROZEN:
>>                         cpufreq_add_dev(dev, NULL);
>>                         break;
> 
> I have forgotten meaning of these flags now :(

Take a quick peek at kernel/cpu.c and include/linux/cpu.h and all those
memories will come rushing back ;-)

> So, CPU_ONLINE, CPU_DOWN_PREPARE and CPU_DOWN_FAILED
> are called when cpus are added/removed (but not for cpu_down in suspend
> resume)? and _FROZEN ones are only used for s2r/s2d?
> 

Yes, that's right. For the suspend/resume and hibernate/restore case, all
the notifiers use the _FROZEN flags. The regular hotplug notifications use
the flags without the _FROZEN suffix.

Regards,
Srivatsa S. Bhat

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar May 15, 2013, 6:45 a.m. UTC | #4
On 14 May 2013 19:24, Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> wrote:
> From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> Subject: [PATCH v2] cpufreq: Preserve sysfs file permissions across suspend/resume
>
> The file permissions of cpufreq per-cpu sysfs files are not preserved across
> suspend/resume because we internally go through the CPU Hotplug path which
> reinitializes the file permissions on CPU online.
>
> But the user is not supposed to know that we are using CPU hotplug
> internally within suspend/resume (IOW, the kernel should not silently wreck
> the user-set file permissions across a suspend cycle). Therefore, we need to
> preserve the file permissions as it is, across suspend/resume.
>
> The simplest way to achieve that is to just not touch the sysfs files at
> all - ie., just ignore the CPU hotplug events in the suspend/resume path
> (_FROZEN) in the cpufreq hotplug callback.
>
> Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
> Reported-by: Durgadoss R <durgadoss.r@intel.com>
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> ---
> v2: Use UP_CANCELED_FROZEN notification to delete the sysfs files if the
> CPUs don't come up during resume.
>
>  drivers/cpufreq/cpufreq.c       |    4 +---
>  drivers/cpufreq/cpufreq_stats.c |    7 ++++---
>  2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 1b8a48e..284ba63 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1832,15 +1832,13 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
>         if (dev) {
>                 switch (action) {
>                 case CPU_ONLINE:
> -               case CPU_ONLINE_FROZEN:
>                         cpufreq_add_dev(dev, NULL);
>                         break;
>                 case CPU_DOWN_PREPARE:
> -               case CPU_DOWN_PREPARE_FROZEN:
> +               case CPU_UP_CANCELED_FROZEN:
>                         __cpufreq_remove_dev(dev, NULL);
>                         break;
>                 case CPU_DOWN_FAILED:
> -               case CPU_DOWN_FAILED_FROZEN:
>                         cpufreq_add_dev(dev, NULL);
>                         break;
>                 }
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index bfd6273..fb65dec 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -349,15 +349,16 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
>
>         switch (action) {
>         case CPU_ONLINE:
> -       case CPU_ONLINE_FROZEN:
>                 cpufreq_update_policy(cpu);
>                 break;
>         case CPU_DOWN_PREPARE:
> -       case CPU_DOWN_PREPARE_FROZEN:
>                 cpufreq_stats_free_sysfs(cpu);
>                 break;
>         case CPU_DEAD:
> -       case CPU_DEAD_FROZEN:
> +               cpufreq_stats_free_table(cpu);
> +               break;
> +       case CPU_UP_CANCELED_FROZEN:
> +               cpufreq_stats_free_sysfs(cpu);
>                 cpufreq_stats_free_table(cpu);
>                 break;
>         }

I accept that the patch makes things work but honestly speaking I
didn't like it much :(

As it looks like more of a hack than a proper solution. We are off-lining
cpus but we are still keeping cpufreq directories (cpu/cpu*/cpufreq)...
That goes against the basic rules...

This works because there is no potential user between suspend/resume
who can notice above issue. But that doesn't mean we write such code.

On the other side, it looks difficult to preserve permissions by writing some
complicated code to preserve and restore original settings for
Suspend/resume.

For now I can't imaging this breaking some stuff in cpufreq core.

I don't want to but I have to (As i don't have a better solution):

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Srivatsa S. Bhat May 15, 2013, 7:33 a.m. UTC | #5
On 05/15/2013 12:15 PM, Viresh Kumar wrote:
> On 14 May 2013 19:24, Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> wrote:
>> From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
>> Subject: [PATCH v2] cpufreq: Preserve sysfs file permissions across suspend/resume
>>
>> The file permissions of cpufreq per-cpu sysfs files are not preserved across
>> suspend/resume because we internally go through the CPU Hotplug path which
>> reinitializes the file permissions on CPU online.
>>
>> But the user is not supposed to know that we are using CPU hotplug
>> internally within suspend/resume (IOW, the kernel should not silently wreck
>> the user-set file permissions across a suspend cycle). Therefore, we need to
>> preserve the file permissions as it is, across suspend/resume.
>>
>> The simplest way to achieve that is to just not touch the sysfs files at
>> all - ie., just ignore the CPU hotplug events in the suspend/resume path
>> (_FROZEN) in the cpufreq hotplug callback.
>>
>> Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
>> Reported-by: Durgadoss R <durgadoss.r@intel.com>
>> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
>> ---
>> v2: Use UP_CANCELED_FROZEN notification to delete the sysfs files if the
>> CPUs don't come up during resume.
>>
>>  drivers/cpufreq/cpufreq.c       |    4 +---
>>  drivers/cpufreq/cpufreq_stats.c |    7 ++++---
>>  2 files changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index 1b8a48e..284ba63 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -1832,15 +1832,13 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
>>         if (dev) {
>>                 switch (action) {
>>                 case CPU_ONLINE:
>> -               case CPU_ONLINE_FROZEN:
>>                         cpufreq_add_dev(dev, NULL);
>>                         break;
>>                 case CPU_DOWN_PREPARE:
>> -               case CPU_DOWN_PREPARE_FROZEN:
>> +               case CPU_UP_CANCELED_FROZEN:
>>                         __cpufreq_remove_dev(dev, NULL);
>>                         break;
>>                 case CPU_DOWN_FAILED:
>> -               case CPU_DOWN_FAILED_FROZEN:
>>                         cpufreq_add_dev(dev, NULL);
>>                         break;
>>                 }
>> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
>> index bfd6273..fb65dec 100644
>> --- a/drivers/cpufreq/cpufreq_stats.c
>> +++ b/drivers/cpufreq/cpufreq_stats.c
>> @@ -349,15 +349,16 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
>>
>>         switch (action) {
>>         case CPU_ONLINE:
>> -       case CPU_ONLINE_FROZEN:
>>                 cpufreq_update_policy(cpu);
>>                 break;
>>         case CPU_DOWN_PREPARE:
>> -       case CPU_DOWN_PREPARE_FROZEN:
>>                 cpufreq_stats_free_sysfs(cpu);
>>                 break;
>>         case CPU_DEAD:
>> -       case CPU_DEAD_FROZEN:
>> +               cpufreq_stats_free_table(cpu);
>> +               break;
>> +       case CPU_UP_CANCELED_FROZEN:
>> +               cpufreq_stats_free_sysfs(cpu);
>>                 cpufreq_stats_free_table(cpu);
>>                 break;
>>         }
> 
> I accept that the patch makes things work but honestly speaking I
> didn't like it much :(
> 
> As it looks like more of a hack than a proper solution. We are off-lining
> cpus but we are still keeping cpufreq directories (cpu/cpu*/cpufreq)...
> That goes against the basic rules...
>

Why do you say that? We want to do *suspend/resume*, not *CPU hotplug*.
So we do a "light" form of hotplug where only the most necessary things
are done. Deleting all the sysfs files and recreating them on resume is
a total waste of time anyway (and adds to the suspend/resume latency).
The _FROZEN flags have been introduced and used for a long time now,
for this very purpose : provide a way to make hotplug as light, and as
smart as possible in the suspend/resume path, because our intention is
to do *suspend/resume* and *not* hotplug per-se. It is only coincidental
that we use hotplug internally in the those paths to get the job done easily.

> This works because there is no potential user between suspend/resume
> who can notice above issue. But that doesn't mean we write such code.
> 

I disagree. There is absolutely nothing wrong here - we have *frozen* the
userspace much before we did any of that! Why do you think we do that?
IOW, it is not purely by chance that nobody is observing what we are doing
in the suspend/resume path - we intentionally *froze* everybody! And until
we thaw them in the resume path, nobody can see anything. And that is
by design. Of course, freezing of tasks is important to restore them back
on resume to the same state, but it serves higher-level purposes too, like
this (ie., not surprising the user with unrelated events). That's part of
the reason why its almost the first thing we do in the suspend path.

> On the other side, it looks difficult to preserve permissions by writing some
> complicated code to preserve and restore original settings for
> Suspend/resume.
> 

Think about it - nobody asked us to delete the sysfs files or wreck their
settings and then worry about restoring them back; we were just asked to suspend
and resume the system. Wrecking the settings is a side-effect of doing hotplug
internally in the suspend/resume path. And that's exactly why we have the
_FROZEN flags, to help us avoid shooting ourselves in the foot like that.

We have used this solution of ignoring stuff to give the effect of
preserving and restoring state, for much more serious stuff before.
Take a look at commit 8f2f748b0656 (CPU hotplug, cpusets, suspend: Don't
touch cpusets during suspend/resume). (But that commit had to be reworked later
to handle a different problem, but that is not relevant here). There have been
some clever optimizations too, that used similar methods : commit 3fb82d56ad0
(x86, suspend: Avoid unnecessary smp alternatives switch during suspend/resume).

So IMHO this is a perfectly sane way to deal with suspend/resume with the
infrastructure we have today. There is nothing wrong in doing this.
Using the _FROZEN flags to speed up suspend/resume (and handle problems like
this) is the closest approximation of the "inactive" state that Alan Stern
described, that we have today in the kernel.

> For now I can't imaging this breaking some stuff in cpufreq core.
> 

What I was concerned was if there were any hidden dependencies between these
functions which deal with sysfs and functions that deal with putting back
the CPUs to the previously set frequencies upon resume (in case there are such
things to be done at resume). Good to know that there are no such dependencies.

> I don't want to but I have to (As i don't have a better solution):
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> 

Thank you! I wish you had ACKed it more happily though ;-)

Regards,
Srivatsa S. Bhat

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar May 15, 2013, 7:44 a.m. UTC | #6
On 15 May 2013 13:03, Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> wrote:
> Thank you! I wish you had ACKed it more happily though ;-)

Hmm.. Your reasoning looks valid and mine wasn't right. So, consider it
a very happy Ack :)
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Srivatsa S. Bhat May 15, 2013, 8:18 a.m. UTC | #7
On 05/15/2013 01:14 PM, Viresh Kumar wrote:
> On 15 May 2013 13:03, Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> wrote:
>> Thank you! I wish you had ACKed it more happily though ;-)
> 
> Hmm.. Your reasoning looks valid and mine wasn't right. So, consider it
> a very happy Ack :)
> 

Awesome! Thank you :-) 

Regards,
Srivatsa S. Bhat

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jarzmik, Robert May 15, 2013, 8:24 a.m. UTC | #8
LS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCkZyb206IFJhZmFlbCBKLiBXeXNvY2tpIFttYWls
dG86cmp3QHNpc2sucGxdIA0KU2VudDogVHVlc2RheSwgTWF5IDE0LCAyMDEzIDEwOjIzIFBNDQpU
bzogU3JpdmF0c2EgUy4gQmhhdDsgSmFyem1paywgUm9iZXJ0OyBSLCBEdXJnYWRvc3MNCkNjOiBW
aXJlc2ggS3VtYXI7IGxpbnV4LXBtQHZnZXIua2VybmVsLm9yZw0KU3ViamVjdDogUmU6IFMzLCBT
TVAgbm9uIGJvb3QgY3B1cyBhbmQgL3N5cy9kZXZpY2VzL3N5c3RlbS9jcHVbMS05XS9jcHVmcmVx
L3NjYWxpbmdfbWF4X2ZyZXENCg0KPiBSb2JlcnQsIER1cmdhLCBkb2VzIHRoaXMgd29yayBmb3Ig
eW91Pw0KWWVzIGl0IGRvZXMsIGV4YWN0bHkgdGhlIGZpeCBJIHdhcyBsb29raW5nIGZvci4NCg0K
VGVzdGVkLWJ5OiBSb2JlcnQgSmFyem1payA8cm9iZXJ0LmphcnptaWtAaW50ZWwuY29tPg0KDQot
LQ0KUm9iZXJ0DQoNCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQpJbnRlbCBDb3Jwb3JhdGlvbiBTQVMgKEZyZW5jaCBz
aW1wbGlmaWVkIGpvaW50IHN0b2NrIGNvbXBhbnkpClJlZ2lzdGVyZWQgaGVhZHF1YXJ0ZXJzOiAi
TGVzIE1vbnRhbGV0cyItIDIsIHJ1ZSBkZSBQYXJpcywgCjkyMTk2IE1ldWRvbiBDZWRleCwgRnJh
bmNlClJlZ2lzdHJhdGlvbiBOdW1iZXI6ICAzMDIgNDU2IDE5OSBSLkMuUy4gTkFOVEVSUkUKQ2Fw
aXRhbDogNCw1NzIsMDAwIEV1cm9zCgpUaGlzIGUtbWFpbCBhbmQgYW55IGF0dGFjaG1lbnRzIG1h
eSBjb250YWluIGNvbmZpZGVudGlhbCBtYXRlcmlhbCBmb3IKdGhlIHNvbGUgdXNlIG9mIHRoZSBp
bnRlbmRlZCByZWNpcGllbnQocykuIEFueSByZXZpZXcgb3IgZGlzdHJpYnV0aW9uCmJ5IG90aGVy
cyBpcyBzdHJpY3RseSBwcm9oaWJpdGVkLiBJZiB5b3UgYXJlIG5vdCB0aGUgaW50ZW5kZWQKcmVj
aXBpZW50LCBwbGVhc2UgY29udGFjdCB0aGUgc2VuZGVyIGFuZCBkZWxldGUgYWxsIGNvcGllcy4K

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
durgadoss.r@intel.com May 15, 2013, 8:37 a.m. UTC | #9
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBSYWZhZWwgSi4gV3lzb2NraSBb
bWFpbHRvOnJqd0BzaXNrLnBsXQ0KPiBTZW50OiBXZWRuZXNkYXksIE1heSAxNSwgMjAxMyAxOjUz
IEFNDQo+IFRvOiBTcml2YXRzYSBTLiBCaGF0OyBKYXJ6bWlrLCBSb2JlcnQ7IFIsIER1cmdhZG9z
cw0KPiBDYzogVmlyZXNoIEt1bWFyOyBsaW51eC1wbUB2Z2VyLmtlcm5lbC5vcmcNCj4gU3ViamVj
dDogUmU6IFMzLCBTTVAgbm9uIGJvb3QgY3B1cyBhbmQgL3N5cy9kZXZpY2VzL3N5c3RlbS9jcHVb
MS0NCj4gOV0vY3B1ZnJlcS9zY2FsaW5nX21heF9mcmVxDQo+IA0KPiBPbiBUdWVzZGF5LCBNYXkg
MTQsID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lY2hub2xvZ3kgQ2VudGVyLg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael Wysocki May 15, 2013, 8:50 p.m. UTC | #10
On Tuesday, May 14, 2013 07:24:41 PM Srivatsa S. Bhat wrote:
> On 05/14/2013 06:30 PM, Rafael J. Wysocki wrote:
> > On Tuesday, May 14, 2013 06:04:48 PM Srivatsa S. Bhat wrote:
> >> On 05/14/2013 05:24 PM, Jarzmik, Robert wrote:
> >>>> Okay, agreed after looking at this discussion ;) I am fine with the approach of kernel preserving permissions too.
> >>>
> >>> Ok, that's great, yet I don't see a clean solution here.  This is
> >>> the path I see and that bothers me in the S3 suspend path:
> >>> cpufreq_sysfs_release
> >>>   kobject_cleanup
> >>>     kobject_release
> >>>       kobject_put
> >>>         __cpufreq_remove_dev
> >>>           cpufreq_cpu_callback
> >>>             notifier_call_chain
> >>>               __raw_notifier_call_chain
> >>>                 __cpu_notify
> >>>                   _cpu_down
> >>>
> >>> Here the sysfs attributes are destroyed. Cpu onlining will
> >>> recreate them with root permissions. I don't see a good clean way
> >>> to preserve permissions in sysfs across suspend/resume for
> >>> deleted nodes. Do you ?
> >>>
> >>> And here we come to my actual worry : what is the technical clean
> >>> way to solve this problem ?
> >>>
> >>> So far I have no idea (the cpufreq example is only a subset of
> >>> the cases where it could happen). So if someone comes up with a
> >>> good idea I'll volunteer to implement it :)
> >>>
> >>
> >> Does the below (untested) patch help? I haven't spent time investigating
> >> whether not doing the add_dev/remove_dev stuff during CPU hotplug in S3 path
> >> will break something else. But it would be great if this works, since
> >> its the simplest solution that I can think of.
> > 
> > Well, what if the CPU doesn't come up during resume?
> > 
> 
> Hmm, that's a good point. We will need to remove the sysfs files in that
> case. The updated patch below uses CPU_UP_CANCELED_FROZEN notification
> to do that.
> 
> Regards,
> Srivatsa S. Bhat
> 
> ----------------------------------------------------------------------->
> 
> From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
> Subject: [PATCH v2] cpufreq: Preserve sysfs file permissions across suspend/resume
> 
> The file permissions of cpufreq per-cpu sysfs files are not preserved across
> suspend/resume because we internally go through the CPU Hotplug path which
> reinitializes the file permissions on CPU online.
> 
> But the user is not supposed to know that we are using CPU hotplug
> internally within suspend/resume (IOW, the kernel should not silently wreck
> the user-set file permissions across a suspend cycle). Therefore, we need to
> preserve the file permissions as it is, across suspend/resume.
> 
> The simplest way to achieve that is to just not touch the sysfs files at
> all - ie., just ignore the CPU hotplug events in the suspend/resume path
> (_FROZEN) in the cpufreq hotplug callback.
> 
> Reported-by: Robert Jarzmik <robert.jarzmik@intel.com>
> Reported-by: Durgadoss R <durgadoss.r@intel.com>
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Applied to linux-pm.git/linux-next as v3.10-rc2 material.

Thanks,
Rafael


> ---
> v2: Use UP_CANCELED_FROZEN notification to delete the sysfs files if the
> CPUs don't come up during resume.
> 
>  drivers/cpufreq/cpufreq.c       |    4 +---
>  drivers/cpufreq/cpufreq_stats.c |    7 ++++---
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 1b8a48e..284ba63 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1832,15 +1832,13 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
>  	if (dev) {
>  		switch (action) {
>  		case CPU_ONLINE:
> -		case CPU_ONLINE_FROZEN:
>  			cpufreq_add_dev(dev, NULL);
>  			break;
>  		case CPU_DOWN_PREPARE:
> -		case CPU_DOWN_PREPARE_FROZEN:
> +		case CPU_UP_CANCELED_FROZEN:
>  			__cpufreq_remove_dev(dev, NULL);
>  			break;
>  		case CPU_DOWN_FAILED:
> -		case CPU_DOWN_FAILED_FROZEN:
>  			cpufreq_add_dev(dev, NULL);
>  			break;
>  		}
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index bfd6273..fb65dec 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -349,15 +349,16 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
>  
>  	switch (action) {
>  	case CPU_ONLINE:
> -	case CPU_ONLINE_FROZEN:
>  		cpufreq_update_policy(cpu);
>  		break;
>  	case CPU_DOWN_PREPARE:
> -	case CPU_DOWN_PREPARE_FROZEN:
>  		cpufreq_stats_free_sysfs(cpu);
>  		break;
>  	case CPU_DEAD:
> -	case CPU_DEAD_FROZEN:
> +		cpufreq_stats_free_table(cpu);
> +		break;
> +	case CPU_UP_CANCELED_FROZEN:
> +		cpufreq_stats_free_sysfs(cpu);
>  		cpufreq_stats_free_table(cpu);
>  		break;
>  	}
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 1b8a48e..284ba63 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1832,15 +1832,13 @@  static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
 	if (dev) {
 		switch (action) {
 		case CPU_ONLINE:
-		case CPU_ONLINE_FROZEN:
 			cpufreq_add_dev(dev, NULL);
 			break;
 		case CPU_DOWN_PREPARE:
-		case CPU_DOWN_PREPARE_FROZEN:
+		case CPU_UP_CANCELED_FROZEN:
 			__cpufreq_remove_dev(dev, NULL);
 			break;
 		case CPU_DOWN_FAILED:
-		case CPU_DOWN_FAILED_FROZEN:
 			cpufreq_add_dev(dev, NULL);
 			break;
 		}
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index bfd6273..fb65dec 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -349,15 +349,16 @@  static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
 
 	switch (action) {
 	case CPU_ONLINE:
-	case CPU_ONLINE_FROZEN:
 		cpufreq_update_policy(cpu);
 		break;
 	case CPU_DOWN_PREPARE:
-	case CPU_DOWN_PREPARE_FROZEN:
 		cpufreq_stats_free_sysfs(cpu);
 		break;
 	case CPU_DEAD:
-	case CPU_DEAD_FROZEN:
+		cpufreq_stats_free_table(cpu);
+		break;
+	case CPU_UP_CANCELED_FROZEN:
+		cpufreq_stats_free_sysfs(cpu);
 		cpufreq_stats_free_table(cpu);
 		break;
 	}