qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ankur Arora <ankur.a.arora@oracle.com>
To: Laszlo Ersek <lersek@redhat.com>, Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [RFC] ich9:cpuhp: add support for cpu hot-unplug with SMI broadcast enabled
Date: Fri, 27 Nov 2020 16:43:23 -0800	[thread overview]
Message-ID: <c197150c-7156-6f19-b36e-5199a5536fcd@oracle.com> (raw)
In-Reply-To: <a92b50df-f693-ebda-e549-7bc9e6d2d7a5@redhat.com>

On 2020-11-27 7:19 a.m., Laszlo Ersek wrote:
> On 11/27/20 05:10, Ankur Arora wrote:
> 
>> Yeah I was wondering what would happen for simultaneous hot add and remove.
>> I guess we would always do remove first and then the add, unless we hit
>> the break due to max_cpus_per_pass and switch to hot-add mode.
> 
> Considering the firmware only, I disagree with remove-then-add.
> 
> EFI_SMM_CPU_SERVICE_PROTOCOL.AddProcessor() and
> EFI_SMM_CPU_SERVICE_PROTOCOL.RemoveProcessor() (implemented in
> SmmAddProcessor() and SmmRemoveProcessor() in
> "UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c", respectively) only mark the
> processors for addition/removal. The actual processing is done only
> later, in BSPHandler() --> SmmCpuUpdate(), when "all SMI handlers are
> finished" (see the comment in SmmRemoveProcessor()).
> 
> Consequently, I would not suggest replacing a valid APIC ID in a
> particular mCpuHotPlugData.ApicId[Index] slot with INVALID_APIC_ID
> (corresponding to the unplug operation), and then possibly replacing
> INVALID_APIC_ID in the *same slot* with the APIC ID of the newly plugged
> CPU, in the exact same SMI invocation (= in the same execution of
> CpuHotplugMmi()). That might cause some component in edk2 to see the
> APIC ID in mCpuHotPlugData.ApicId[Index] to change from one valid ACPI
> ID to another valid APIC ID, and I don't even want to think about what
> kind of mess that could cause.

Shudders.

> 
> So no, please handle plugs first, for which unused slots in
> mCpuHotPlugData.ApicId will be populated, and *then* handle removals (in
> the same invocation of CpuHotplugMmi()).

Yeah, that ordering makes complete sense.

> 
> By the way, for unplug, you will not have to re-set
> mCpuHotPlugData.ApicId[Index] to INVALID_APIC_ID, as
> SmmRemoveProcessor() does that internally. You just have to locate the
> Index for the APIC ID being removed, for calling
> EFI_SMM_CPU_SERVICE_PROTOCOL.RemoveProcessor().

Right. The hotplug is more involved (given the need to pen the new CPU)
but for the unplug, AFAICS all the actual handling for removal is in
.RemoveProcessor() and at SMI exit in SmmCpuUpdate().


Thanks
Ankur

> 
> 
> Thanks
> Laszlo
> 


  reply	other threads:[~2020-11-28  0:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 12:25 [RFC] ich9:cpuhp: add support for cpu hot-unplug with SMI broadcast enabled Igor Mammedov
2020-11-24 22:58 ` Laszlo Ersek
2020-11-26 10:24 ` Ankur Arora
2020-11-26 12:46   ` Laszlo Ersek
2020-11-26 19:50     ` Igor Mammedov
2020-11-27  3:39       ` Ankur Arora
2020-11-27  3:35     ` Ankur Arora
2020-11-27 11:33       ` Igor Mammedov
2020-11-27 15:02         ` Laszlo Ersek
2020-11-27 23:48           ` Ankur Arora
2020-11-30 16:58             ` Laszlo Ersek
2020-11-30 19:45               ` Ankur Arora
2020-11-26 20:45   ` Igor Mammedov
2020-11-26 11:17 ` Laszlo Ersek
2020-11-26 20:38   ` Igor Mammedov
2020-11-27  4:10     ` Ankur Arora
2020-11-27 11:47       ` Igor Mammedov
2020-11-27 23:49         ` Ankur Arora
2020-11-27 15:19       ` Laszlo Ersek
2020-11-28  0:43         ` Ankur Arora [this message]
2020-11-30 17:00           ` Laszlo Ersek
2020-11-27 14:48     ` Laszlo Ersek
2020-11-27 15:07       ` Igor Mammedov
2020-11-27 16:52         ` Laszlo Ersek

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=c197150c-7156-6f19-b36e-5199a5536fcd@oracle.com \
    --to=ankur.a.arora@oracle.com \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).