mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: pavel@ucw.cz, len.brown@intel.com, ebiederm@xmission.com,
	tj@kernel.org, rdunlap@xenotime.net, linux-doc@vger.kernel.org,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, oleg@redhat.com
Subject: Re: [PATCH v2 1/3] PM / Sleep: Make [un]lock_system_sleep() generic
Date: Tue, 6 Dec 2011 23:35:53 +0100	[thread overview]
Message-ID: <201112062335.53670.rjw@sisk.pl> (raw)
In-Reply-To: <20111206192000.25854.53769.stgit@srivatsabhat.in.ibm.com>

On Tuesday, December 06, 2011, Srivatsa S. Bhat wrote:
> The [un]lock_system_sleep() APIs were originally introduced to mutually
> exclude memory hotplug and hibernation.
> 
> Directly using mutex_lock(&pm_mutex) to achieve mutual exclusion with
> suspend or hibernation code can lead to freezing failures. However, the
> APIs [un]lock_system_sleep() can be safely used to achieve the same,
> without causing freezing failures.
> 
> So, since it would be beneficial to modify all the existing users of
> mutex_lock(&pm_mutex) (in all parts of the kernel), so that they use these
> safe APIs intead, make these APIs generic by removing the restriction that
> they work only when CONFIG_HIBERNATE_CALLBACKS is set. Moreover, that
> restriction didn't buy us anything anyway.
> 
> v2: Rebased on top of the patchset posted at:
>     https://lkml.org/lkml/2011/12/6/334
> 
> Suggested-by: Tejun Heo <tj@kernel.org>
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

All patches in this series applied to linux-pm/linux-next.

Thanks,
Rafael


> ---
> 
>  include/linux/suspend.h |   36 ++++++++++++++++--------------------
>  1 files changed, 16 insertions(+), 20 deletions(-)
> 
> diff --git a/include/linux/suspend.h b/include/linux/suspend.h
> index 906d62c..95040cc 100644
> --- a/include/linux/suspend.h
> +++ b/include/linux/suspend.h
> @@ -332,6 +332,8 @@ static inline bool system_entering_hibernation(void) { return false; }
>  #define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
>  #define PM_POST_RESTORE		0x0006 /* Restore failed */
>  
> +extern struct mutex pm_mutex;
> +
>  #ifdef CONFIG_PM_SLEEP
>  void save_processor_state(void);
>  void restore_processor_state(void);
> @@ -352,6 +354,19 @@ extern bool events_check_enabled;
>  extern bool pm_wakeup_pending(void);
>  extern bool pm_get_wakeup_count(unsigned int *count);
>  extern bool pm_save_wakeup_count(unsigned int count);
> +
> +static inline void lock_system_sleep(void)
> +{
> +	freezer_do_not_count();
> +	mutex_lock(&pm_mutex);
> +}
> +
> +static inline void unlock_system_sleep(void)
> +{
> +	mutex_unlock(&pm_mutex);
> +	freezer_count();
> +}
> +
>  #else /* !CONFIG_PM_SLEEP */
>  
>  static inline int register_pm_notifier(struct notifier_block *nb)
> @@ -367,30 +382,11 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
>  #define pm_notifier(fn, pri)	do { (void)(fn); } while (0)
>  
>  static inline bool pm_wakeup_pending(void) { return false; }
> -#endif /* !CONFIG_PM_SLEEP */
> -
> -extern struct mutex pm_mutex;
>  
> -#ifndef CONFIG_HIBERNATE_CALLBACKS
>  static inline void lock_system_sleep(void) {}
>  static inline void unlock_system_sleep(void) {}
>  
> -#else
> -
> -/* Let some subsystems like memory hotadd exclude hibernation */
> -
> -static inline void lock_system_sleep(void)
> -{
> -	freezer_do_not_count();
> -	mutex_lock(&pm_mutex);
> -}
> -
> -static inline void unlock_system_sleep(void)
> -{
> -	mutex_unlock(&pm_mutex);
> -	freezer_count();
> -}
> -#endif
> +#endif /* !CONFIG_PM_SLEEP */
>  
>  #ifdef CONFIG_ARCH_SAVE_PAGE_KEYS
>  /*
> 
> --
> 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
> 
> 


      parent reply	other threads:[~2011-12-06 22:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06 19:23 Srivatsa S. Bhat
2011-12-06 19:24 ` [PATCH v2 2/3] PM / Sleep: Replace mutex_[un]lock(&pm_mutex) with [un]lock_system_sleep() Srivatsa S. Bhat
2011-12-07  0:36   ` Simon Horman
2011-12-06 19:24 ` [PATCH v2 3/3] PM / Docs: Recommend the use of [un]lock_system_sleep() over mutex_[un]lock(&pm_mutex) Srivatsa S. Bhat
2011-12-06 22:35 ` Rafael J. Wysocki [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=201112062335.53670.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=len.brown@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=rdunlap@xenotime.net \
    --cc=srivatsa.bhat@linux.vnet.ibm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®