All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: len.brown@intel.com, pavel@ucw.cz, rdunlap@xenotime.net,
	tj@kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v2] PM/Hibernation: Fix the early termination of test modes
Date: Sat, 19 Nov 2011 11:07:42 +0530	[thread overview]
Message-ID: <4EC740A6.8010803@linux.vnet.ibm.com> (raw)
In-Reply-To: <201111182300.44173.rjw@sisk.pl>

On 11/19/2011 03:30 AM, Rafael J. Wysocki wrote:
> On Friday, November 18, 2011, Srivatsa S. Bhat wrote:
>> On 11/18/2011 02:57 PM, Srivatsa S. Bhat wrote:
>>> On 11/18/2011 02:50 PM, Rafael J. Wysocki wrote:
>>>>> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
>>>>> index b4511b6..257e8e7 100644
>>>>> --- a/kernel/power/hibernate.c
>>>>> +++ b/kernel/power/hibernate.c
>>>>> @@ -55,6 +55,8 @@ enum {
>>>>>  
>>>>>  static int hibernation_mode = HIBERNATION_SHUTDOWN;
>>>>>  
>>>>> +static bool freezer_test_done;
>>>>> +
>>>>>  static const struct platform_hibernation_ops *hibernation_ops;
>>>>>  
>>>>>  /**
>>>>> @@ -347,6 +349,17 @@ int hibernation_snapshot(int platform_mode)
>>>>>  	if (error)
>>>>>  		goto Close;
>>>>>  
>>>>> +	if (hibernation_test(TEST_FREEZER) ||
>>>>> +		hibernation_testmode(HIBERNATION_TESTPROC)) {
>>>>> +
>>>>> +		/*
>>>>> +		 * Indicate to the caller that we are returning due to a
>>>>> +		 * successful freezer test.
>>>>> +		 */
>>>>> +		freezer_test_done = true;
>>>>> +		goto Close;
>>>>> +	}
>>>>> +
>>>>>  	error = dpm_prepare(PMSG_FREEZE);
>>>>>  	if (error)
>>>>>  		goto Complete_devices;
>>>>> @@ -641,15 +654,13 @@ int hibernate(void)
>>>>>  	if (error)
>>>>>  		goto Finish;
>>>>>  
>>>>> -	if (hibernation_test(TEST_FREEZER))
>>>>> -		goto Thaw;
>>>>> -
>>>>> -	if (hibernation_testmode(HIBERNATION_TESTPROC))
>>>>> -		goto Thaw;
>>>>> -
>>>>>  	error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM);
>>>>>  	if (error)
>>>>>  		goto Thaw;
>>>>> +	if (freezer_test_done) {
>>>>> +		freezer_test_done = false;
>>>>> +		goto Thaw;
>>>>> +	}
>>>>
>>>> What happens if hibernation_snapshot() and freezer_test_done is 'true'?
>>>> Won't that leek freezer_test_done to the next hibernation cycle?
>>>>
>>>
>>> Oh yes, thanks for catching that! I'll fix that and send an updated patch.
>>>
>>
>> Sorry, I think I hit reply too soon.
>> To restate your question, you are asking if freezer_test_done was set in
>> hibernation_snapshot() and then there was a genuine error in
>> hibernation_snapshot() which it returned, then won't freezer_test_done
>> leak to the next cycle.., right?
>>
>> If there is a genuine error before hibernation_test(TEST_FREEZER)... is
>> done, then we will never set freezer_test_done flag to true.
>>
>> And whenever freezer_test_done is set (inside hibernation_snapshot) there
>> is no way it will continue further executing normal code. It will jump to
>> the Close label and come out, so that here in hibernate(), the first
>> check for error will fail (because it returned 0) and the subsequent
>> check for freezer_test_done will succeed. So I don't see how it can leak.
>>
>> Or, am I missing something?
> 
> No, that's fine, I just wasn't sure. :-)
> 
> I'm going to apply your patch without the documentation changes.
> 

Great! Thanks a lot!

Thanks,
Srivatsa S. Bhat


      reply	other threads:[~2011-11-19  5:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18  3:16 [PATCH v2] PM/Hibernation: Fix the early termination of test modes Srivatsa S. Bhat
2011-11-18  9:20 ` Rafael J. Wysocki
2011-11-18  9:27   ` Srivatsa S. Bhat
2011-11-18  9:34     ` Rafael J. Wysocki
2011-11-18  9:45     ` Srivatsa S. Bhat
2011-11-18 22:00       ` Rafael J. Wysocki
2011-11-19  5:37         ` Srivatsa S. Bhat [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EC740A6.8010803@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=len.brown@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rdunlap@xenotime.net \
    --cc=rjw@sisk.pl \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.