From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: "Yu, Fenghua" <fenghua.yu@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
H Peter Anvin <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Mallick, Asit K" <asit.k.mallick@intel.com>,
"Luck, Tony" <tony.luck@intel.com>,
Arjan Dan De Ven <arjan@linux.intel.com>,
"Siddha, Suresh B" <suresh.b.siddha@intel.com>,
"Brown, Len" <len.brown@intel.com>,
Randy Dunlap <rdunlap@xenotime.net>,
Chen Gong <gong.chen@linux.intel.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-pm <linux-pm@vger.kernel.org>, x86 <x86@kernel.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH v9 12/12] x86, topology: Debug CPU00 hotplug
Date: Thu, 18 Oct 2012 12:12:45 +0530 [thread overview]
Message-ID: <507FA4E5.3090604@linux.vnet.ibm.com> (raw)
In-Reply-To: <3E5A0FA7E9CA944F9D5414FEC6C7122030B196BC@ORSMSX105.amr.corp.intel.com>
On 10/17/2012 05:36 AM, Yu, Fenghua wrote:
>>> +#ifdef CONFIG_DEBUG_HOTPLUG_CPU0
> > + case PM_RESTORE_PREPARE:
>>> + /*
>>> + * When system resumes from hibernation, online CPU0
>> because
>>> + * 1. it's required for resume and
>>> + * 2. the CPU was online before hibernation
>>> + */
>>> + if (!cpu_online(0))
>>> + _debug_hotplug_cpu(0, 1);
>>
>> This won't work. CPU hotplug is disabled by cpu_hotplug_pm_callback()
>> during
>> PM_HIBERNATION_PREPARE and is enabled back only during
>> PM_POST_HIBERNATION.
>>
>> So calls to cpu_up() or cpu_down() will fail in the meantime.
>
> The code works just fine.
>
> You are talking about hibernation/suspend phase. This piece of
> code is all about restore phase. Of course you can call cpu_up()
> and cpu_down() during restore phase.
>
> So there is no problem here.
>
I looked into it again, and actually you are right, it'll work fine;
but the reason *why* it will work fine is quite subtle.
Note that there is a difference between calling cpu_up() or cpu_down()
vs calling _cpu_up() or _cpu_down(). The former set of calls will return
-EBUSY if the 'cpu_hotplug_disabled' flag is set. The latter set of calls
don't care about that flag and hence proceed irrespective of the state of
that flag. The former set of calls are used when you echo 0/1 to the online
file from userspace. Whereas the latter set of calls are used by the
disable/enable_nonboot_cpus() functions. This is how you can disable
cpu hotplug by userspace, but continue to do cpu hotplug yourself from
within the kernel in the suspend/hibernation/restore phases.
Now, coming to the notifications part, earlier, I was referring to the
entire hibernate->restore phase, not just the hibernate phase. The relevant
notifications that are sent out during this entire (successful) sequence are:
-> PM_HIBERNATION_PREPARE
-> PM_RESTORE_PREPARE
-> PM_POST_HIBERNATION
cpu_hotplug_pm_callback() will set the cpu_hotplug_disabled flag during
PM_HIBERNATION_PREPARE and clears it only during PM_POST_HIBERNATION.
So in-between, if you invoke cpu_up() or cpu_down(), it should return -EBUSY.
Then how is it that this patch can work fine? The answer is, during the
restore phase, you are not yet in the kernel-to-be-restored. IOW, that
cpu_hotplug_disabled flag is clear in that kernel. That's why cpu_up() and
cpu_down() will continue to work at that point. But once you resume execution
from the saved hibernation image, you won't be able to do cpu_up() and
cpu_down() until that flag is cleared by cpu_hotplug_pm_callback() during
PM_POST_HIBERNATION.
All in all, its tricky, and luckily this patch uses cpu_up()/cpu_down()
at the right moment...
I don't actually see why cpu_hotplug_pm_callback() should not clear the
cpu_hotplug_disabled flag during PM_RESTORE_PREPARE itself.. if we do that,
we don't have to be *this* careful about -when- we can invoke -which-
function..
Regards,
Srivatsa S. Bhat
next prev parent reply other threads:[~2012-10-18 6:43 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-12 16:09 [PATCH v9 0/12] x86: Arbitrary CPU hot(un)plug support Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 01/12] doc: Add x86 CPU0 online/offline feature Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 02/12] x86, Kconfig: Add config switch for CPU0 hotplug Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 03/12] x86, topology: Don't offline CPU0 if any PIC irq can not be migrated out of it Fenghua Yu
2012-10-16 17:03 ` Borislav Petkov
2012-10-16 18:43 ` Yu, Fenghua
2012-10-16 19:40 ` Borislav Petkov
2012-10-12 16:09 ` [PATCH v9 04/12] x86, hotplug: Support functions for CPU0 online/offline Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 05/12] x86, hotplug, suspend: Online CPU0 for suspend or hibernate Fenghua Yu
2012-10-15 20:50 ` Rafael J. Wysocki
2012-10-16 5:35 ` Srivatsa S. Bhat
2012-10-16 16:17 ` Rafael J. Wysocki
2012-10-16 16:30 ` Srivatsa S. Bhat
2012-10-16 22:12 ` Yu, Fenghua
2012-10-17 5:18 ` Rafael J. Wysocki
2012-10-17 17:39 ` Yu, Fenghua
2012-10-18 6:33 ` Rafael J. Wysocki
2012-10-18 6:51 ` Srivatsa S. Bhat
2012-10-17 18:29 ` Yu, Fenghua
2012-10-12 16:09 ` [PATCH v9 06/12] x86-64, hotplug: Add start_cpu0() entry point to head_64.S Fenghua Yu
2012-10-16 16:50 ` Borislav Petkov
2012-10-12 16:09 ` [PATCH v9 07/12] x86-32, hotplug: Add start_cpu0() entry point to head_32.S Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 08/12] x86, hotplug: Wake up CPU0 via NMI instead of INIT, SIPI, SIPI Fenghua Yu
2012-10-16 4:43 ` HATAYAMA Daisuke
2012-10-16 16:57 ` Borislav Petkov
2012-10-12 16:09 ` [PATCH v9 09/12] x86, hotplug: During CPU0 online, enable x2apic, set_numa_node Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 10/12] x86, hotplug: The first online processor saves the MTRR state Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 11/12] x86/i387.c: Initialize thread xstate only on CPU0 only once Fenghua Yu
2012-10-12 16:09 ` [PATCH v9 12/12] x86, topology: Debug CPU00 hotplug Fenghua Yu
2012-10-16 8:47 ` Srivatsa S. Bhat
2012-10-17 0:06 ` Yu, Fenghua
2012-10-18 6:42 ` Srivatsa S. Bhat [this message]
2012-10-19 1:07 ` Yu, Fenghua
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=507FA4E5.3090604@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=asit.k.mallick@intel.com \
--cc=fenghua.yu@intel.com \
--cc=gong.chen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rdunlap@xenotime.net \
--cc=rjw@sisk.pl \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=x86@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