linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gautham R Shenoy <ego@linux.vnet.ibm.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Oleg Nesterov <oleg@redhat.com>,
	"Srivatsa S. Bhat" <srivatsa@mit.edu>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH] ACPI / cpuidle: fix deadlock between cpuidle_lock and cpu_hotplug.lock
Date: Wed, 17 Sep 2014 14:11:12 +0530	[thread overview]
Message-ID: <20140917084112.GC31806@in.ibm.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1409031503140.12309@pobox.suse.cz>

Hi Jiri,

On Wed, Sep 03, 2014 at 03:04:28PM +0200, Jiri Kosina wrote:
> There is a following AB-BA dependency between cpu_hotplug.lock and 
> cpuidle_lock:
> 
> 1) cpu_hotplug.lock -> cpuidle_lock
> enable_nonboot_cpus()
>  _cpu_up()
>   cpu_hotplug_being()
>    LOCK(cpu_hotplug.lock)
>  cpu_notify()
>   ...
>   acpi_processor_hotplug()
>    cpuidle_pause_and_lock()
>     LOCK(cpuidle_lock)
> 
> 2) cpuidle_lock -> cpu_hotplug.lock
> acpi_os_execute_deferred() workqueue
>  ...
>  acpi_processor_cst_has_changed()
>   cpuidle_pause_and_lock()
>    LOCK(cpuidle_lock)
>   get_online_cpus()
>    LOCK(cpu_hotplug.lock)
> 
> Fix this by reversing the order acpi_processor_cst_has_changed() does 
> thigs -- let it first execute the protection against CPU hotplug by 
> calling get_online_cpus() and obtain the cpuidle lock only after that (and 
> perform the symmentric change when allowing CPUs hotplug again and 
> dropping cpuidle lock).
> 
> Spotted by lockdep.
> 
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Looks good to me.
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>

> ---
>  drivers/acpi/processor_idle.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index 3dca36d..17f9ec5 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -1071,9 +1071,9 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
> 
>  	if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) {
> 
> -		cpuidle_pause_and_lock();
>  		/* Protect against cpu-hotplug */
>  		get_online_cpus();
> +		cpuidle_pause_and_lock();
> 
>  		/* Disable all cpuidle devices */
>  		for_each_online_cpu(cpu) {
> @@ -1100,8 +1100,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
>  				cpuidle_enable_device(dev);
>  			}
>  		}
> -		put_online_cpus();
>  		cpuidle_resume_and_unlock();
> +		put_online_cpus();
>  	}
> 
>  	return 0;
> -- 
> Jiri Kosina
> SUSE Labs
> 

      reply	other threads:[~2014-09-17  8:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03 12:08 3.17-rc3+ CPU hotplug lockdep splat during resume from RAM Jiri Kosina
2014-09-03 13:04 ` [PATCH] ACPI / cpuidle: fix deadlock between cpuidle_lock and cpu_hotplug.lock Jiri Kosina
2014-09-17  8:41   ` Gautham R Shenoy [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=20140917084112.GC31806@in.ibm.com \
    --to=ego@linux.vnet.ibm.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srivatsa@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).