From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
bp@amd64.org, pavel@ucw.cz, len.brown@intel.com, tj@kernel.org,
mingo@elte.hu, akpm@linux-foundation.org,
suresh.b.siddha@intel.com, lucas.demarchi@profusion.mobi,
rusty@rustcorp.com.au, rdunlap@xenotime.net,
vatsa@linux.vnet.ibm.com, ashok.raj@intel.com,
tigran@aivazian.fsnet.co.uk, tglx@linutronix.de, hpa@zytor.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v2 2/3] Mutually exclude cpu online and suspend/hibernate
Date: Wed, 12 Oct 2011 09:27:30 +0530 [thread overview]
Message-ID: <4E95102A.3050503@linux.vnet.ibm.com> (raw)
In-Reply-To: <201110112356.31502.rjw@sisk.pl>
On 10/12/2011 03:26 AM, Rafael J. Wysocki wrote:
> On Tuesday, October 11, 2011, Srivatsa S. Bhat wrote:
>> On 10/10/2011 08:46 PM, Srivatsa S. Bhat wrote:
>>> On 10/10/2011 07:56 PM, Peter Zijlstra wrote:
>>>> On Mon, 2011-10-10 at 18:15 +0530, Srivatsa S. Bhat wrote:
>>>>>> + /*
>>>>>> + * Prevent cpu online and suspend/hibernate (including freezer)
>>>>>> + * operations from running in parallel. Fail cpu online if suspend or
>>>>>> + * hibernate has already started.
>>>>>> + */
>>>>>> + if (!trylock_pm_sleep())
>>>>>
>>>>> Would it be better to hook into the suspend/hibernate notifiers and
>>>>> use them to exclude cpu hotplug from suspend/hibernate, instead of
>>>>> trying to take pm_mutex lock like this?
>>>>> Peter, I remember you pointing out in another patch's review
>>>>> (http://thread.gmane.org/gmane.linux.kernel/1198312/focus=1199087)
>>>>> that introducing more locks in cpu hotplug would be a bad idea. Does that
>>>>> comment hold here as well, or is this fine?
>>>>
>>>> Arguably pm_mutex is already involved in the whole hotplug dance due to
>>>> suspend using it, that said, I'm not at all familiar with the whole
>>>> suspend/hibernate side of things.
>>>>
>>>> I tried having a quick look this morning but failed to find the actual
>>>> code.
>>>>
>>>> I think it would be good to have an overview of the various locks and a
>>>> small description of how they interact/nest.
>>>>
>>>
>>> Sure. I'll put together whatever I have understood, in the form of a patch
>>> to Documentation/power directory and post it tomorrow, for the benefit of
>>> all.
>>>
>>
>> Here it is, just as promised :-)
>> http://lkml.org/lkml/2011/10/11/393
>
> Well, I have an idea.
>
> Why don't we make drivers/base/cpu.c:store_online() take pm_mutex
> in addition to calling cpu_hotplug_driver_lock()? This at least
> will make the interface mutually exclusive with suspend/hibernation.
>
Oh, no no.. We shouldn't be doing that even though it seems very
innocuous, because of a subtle reason: the memory hotplug code called
in cpu_up() tries to acquire pm_mutex! So we will end up deadlocking
ourselves, due to recursive locking!
See kernel/cpu.c: cpu_up() calls mem_online_node() [defined in
mm/memory_hotplug.c/mem_online_node() which calls lock_memory_hotplug()
which internally calls lock_system_sleep(), which is where it tries
to get pm_mutex].
So this patchset implements the mutual exclusion in the cpu_up() function
(i.e., a little bit deeper down the road than store_online() ) and solves
the problem.
I thought I had put a comment there in my code warning about this locking
order thing, but I must have removed it in the last minute, just before
posting it....
--
Regards,
Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Linux Technology Center,
IBM India Systems and Technology Lab
next prev parent reply other threads:[~2011-10-12 3:57 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-10 12:31 [PATCH v2 0/3] Freezer, CPU hotplug, x86 Microcode: Fix task freezing failures Srivatsa S. Bhat
2011-10-10 12:32 ` [PATCH v2 1/3] Introduce helper functions Srivatsa S. Bhat
2011-10-10 12:33 ` [PATCH v2 2/3] Mutually exclude cpu online and suspend/hibernate Srivatsa S. Bhat
2011-10-10 12:45 ` Srivatsa S. Bhat
2011-10-10 14:26 ` Peter Zijlstra
2011-10-10 15:16 ` Srivatsa S. Bhat
2011-10-11 20:32 ` Srivatsa S. Bhat
2011-10-11 21:56 ` Rafael J. Wysocki
2011-10-12 3:57 ` Srivatsa S. Bhat [this message]
2011-10-12 19:31 ` Rafael J. Wysocki
2011-10-12 21:25 ` Srivatsa S. Bhat
2011-10-12 22:09 ` Rafael J. Wysocki
2011-10-13 15:42 ` Srivatsa S. Bhat
2011-10-13 16:06 ` Tejun Heo
2011-10-13 17:01 ` Borislav Petkov
2011-10-13 17:29 ` Srivatsa S. Bhat
2011-10-19 17:29 ` Srivatsa S. Bhat
2011-10-13 18:03 ` Alan Stern
2011-10-13 19:07 ` Rafael J. Wysocki
2011-10-13 19:08 ` Rafael J. Wysocki
2011-10-10 15:25 ` Alan Stern
2011-10-10 17:00 ` Tejun Heo
2011-10-11 9:18 ` Peter Zijlstra
2011-10-11 9:37 ` Srivatsa S. Bhat
2011-10-10 12:33 ` [PATCH v2 3/3] Update documentation Srivatsa S. Bhat
2011-10-10 15:23 ` [PATCH v2 0/3] Freezer, CPU hotplug, x86 Microcode: Fix task freezing failures Alan Stern
2011-10-10 15:32 ` Srivatsa S. Bhat
2011-10-10 16:53 ` Borislav Petkov
2011-10-10 17:14 ` Pavel Machek
2011-10-10 17:30 ` Srivatsa S. Bhat
2011-10-10 17:53 ` Borislav Petkov
2011-10-10 18:08 ` tj
2011-10-10 18:34 ` Borislav Petkov
2011-10-10 18:45 ` Srivatsa S. Bhat
2011-10-10 18:53 ` tj
2011-10-10 19:00 ` Srivatsa S. Bhat
2011-10-10 20:35 ` Borislav Petkov
[not found] ` <20111010202913.GA30798@aftab>
2011-10-10 21:13 ` tj
2011-10-11 9:17 ` Peter Zijlstra
2011-10-10 16:57 ` Tejun Heo
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=4E95102A.3050503@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=ashok.raj@intel.com \
--cc=bp@amd64.org \
--cc=hpa@zytor.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=lucas.demarchi@profusion.mobi \
--cc=mingo@elte.hu \
--cc=pavel@ucw.cz \
--cc=rdunlap@xenotime.net \
--cc=rjw@sisk.pl \
--cc=rusty@rustcorp.com.au \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=tigran@aivazian.fsnet.co.uk \
--cc=tj@kernel.org \
--cc=vatsa@linux.vnet.ibm.com \
/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
Powered by JetHome