From: Prarit Bhargava <prarit@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@redhat.com, hpa@zytor.com, bp@suse.de,
paul.gortmaker@windriver.com, JBeulich@suse.com,
drjones@redhat.com, toshi.kani@hp.com, x86@kernel.org,
riel@redhat.com, gong.chen@linux.intel.com
Subject: Re: [PATCH 0/3] x86: fix hang when AP bringup is too slow
Date: Tue, 25 Mar 2014 07:36:07 -0400 [thread overview]
Message-ID: <53316A27.9030609@redhat.com> (raw)
In-Reply-To: <20140319135456.4a74a2ea@nial.usersys.redhat.com>
On 03/19/2014 08:54 AM, Igor Mammedov wrote:
> On Wed, 19 Mar 2014 07:51:05 -0400
> Prarit Bhargava <prarit@redhat.com> wrote:
>
>>
>>
>> On 03/18/2014 02:49 PM, Igor Mammedov wrote:
>>> On Tue, 18 Mar 2014 08:21:19 -0400
>>> Prarit Bhargava <prarit@redhat.com> wrote:
>>>
>>>>
>>>>
>>>> On 03/13/2014 10:25 AM, Igor Mammedov wrote:
>>>>> Hang is observed on virtual machines during CPU hotplug,
>>>>> especially in big guests with many CPUs. (It happens more
>>>>> often if host is over-committed).
>>>>>
>>>>
>>>> Hey Igor, I like this better than the previous version. Thanks for taking into
>>>> account the possible races in this code.
>>>>
>>>> A quick question on system behaviour. As you know I've been more concerned
>>>> lately with error handling, etc., through the cpu hotplug code as we've seen
>>>> several customer reports of silent failures or cascading failures in the cpu
>>>> hotplug code when users have been attempting to perform physical hotplug.
>>>>
>>>> After your patches have been applied, in theory the following can happen:
>>>>
>>>> The master CPU is completing the AP cpu's bring up. The AP cpu is doing (sorry
>>>> for the cut-and-paste),
>>>>
>>>> void cpu_init(void)
>>>> {
>>>> int cpu = smp_processor_id();
>>>> struct task_struct *curr = current;
>>>> struct tss_struct *t = &per_cpu(init_tss, cpu);
>>>> struct thread_struct *thread = &curr->thread;
>>>>
>>>> /*
>>>> * wait till the master CPU completes it's STARTUP sequence,
>>>> * and decides to wait till this AP boots
>>>> */
>>>> while (!cpumask_test_cpu(cpu, cpu_callout_mask)) {
>>>> cpu_relax();
>>>> if (per_cpu(x86_cpu_to_apicid, cpu) == BAD_APICID)
>>>> halt();
>>>> }
>>>>
>>>> and is spinning on cpu_relax(). Suppose something goes wrong and the softlockup
>>>> watchdog fires on the AP cpu:
>>>>
>>>> 1. Can it? :) ie) will the softlockup fire at this point of the AP init? Okay,
>>>> I'm being really lazy and not looking at the code ;)
>>> It shouldn't, CPU is in pristine state and just came from boot trampoline at
>>> this point without interrupts configured yet.
>>
>> Okay, not a big problem.
>>
>>>
>>>>
>>>> 2. Is there anything we can do in this code to notify the user of a problem?
>>>> Even a pr_crit() here I think would help to indicate what went wrong; it might
>>>> be useful for future debugging in this area to have some sort of output. I
>>>> think a WARN() or BUG() is necessary here as there are several calls to cpu_init().
>>> Do you mean something like this:
>>>
>>> + if (per_cpu(x86_cpu_to_apicid, cpu) == BAD_APICID) {
>>> + WARN(1);
>>> + halt();
>>> + }
>>
>> Yeah, maybe WARN_ON(1, "some comment") though.
> printk at so early stage might be cause issues, since it is quite complex.
> Its' disabling/enabling irqs, calls *_delay_*() functions and takes locks.
> The last is especially dangerous because if AP is shot down by another
> INIT/SIPI, system will hang on next printk if locks were acquired by AP
> at that time.
early_printk()?
> That case is possible if master CPU has got errors during wakeup_ap() and
> failed cpu_up() then it was unplugged + plugged via ACPI and attempted
> to be onlined again.
>
> It's much safer not to do anything complex at AP start-up so early.
>
> BTW:
> when AP reaches halt() line, failure is not silent. the master CPU might
> print error message if debug level logging is active:
> see arch/x86/kernel/smpboot.c:native_cpu_up()
> ...
> if (err) {
> pr_debug("do_boot_cpu failed %d\n", err);
> return -EIO;
> }
> ...
>
> perhaps we should change pr_debug to pr_crit here to make it more visible.
> something like:
>
> @@ -858,7 +858,7 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
>
> err = do_boot_cpu(apicid, cpu, tidle);
> if (err) {
> - pr_debug("do_boot_cpu failed %d\n", err);
> + pr_crit("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu);
> return -EIO;
> }
>
Yes, this is a good idea.
>
>>
>>>
>>>>
>>>> 3. Change this comment:
>>>>
>>>> * wait till the master CPU completes it's STARTUP sequence,
>>>> * and decides to wait till this AP boots
>>>>
>>>> to
>>>>
>>>> /* wait for the master CPU to complete this cpu's STARTUP. */ ?
>>> well, that is not quite the same as above, comment should underline that
>>> AP waits for ACK from master CPU before continuing with this AP initialization.
>>>
>>> How about:
>>> /* wait for ACK from master CPU before continuing with AP initialization */
>>
>> Awesome :)
>>
>> P.
>>
>>>
>>>>
>>>> Apologies for the late review,
>>>>
>>>> P.
>>>
>>>
>
next prev parent reply other threads:[~2014-03-25 11:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-13 14:25 Igor Mammedov
2014-03-13 14:25 ` [PATCH 1/3] x86: replace timeouts when booting secondary CPU with infinite wait loop Igor Mammedov
2014-03-13 14:25 ` [PATCH 2/3] x86: halt secondary CPU if master doesn't wait on it Igor Mammedov
2014-03-13 14:25 ` [PATCH 3/3] x86: cleanup not needed cpu_initialized_mask Igor Mammedov
2014-03-18 12:21 ` [PATCH 0/3] x86: fix hang when AP bringup is too slow Prarit Bhargava
2014-03-18 18:49 ` Igor Mammedov
2014-03-19 11:51 ` Prarit Bhargava
2014-03-19 12:54 ` Igor Mammedov
2014-03-25 11:36 ` Prarit Bhargava [this message]
2014-03-25 12:44 ` Igor Mammedov
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=53316A27.9030609@redhat.com \
--to=prarit@redhat.com \
--cc=JBeulich@suse.com \
--cc=bp@suse.de \
--cc=drjones@redhat.com \
--cc=gong.chen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=imammedo@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paul.gortmaker@windriver.com \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=toshi.kani@hp.com \
--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
Powered by JetHome