public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Jiaxin via groups.io" <jiaxin.wu=intel.com@groups.io>
To: "Liu, Zhiguang" <zhiguang.liu@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Ni, Ray" <ray.ni@intel.com>, "Tan, Dun" <dun.tan@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>
Cc: "Kumar, Chandana C" <chandana.c.kumar@intel.com>,
	"Zhao, Jason" <jason.zhao@intel.com>,
	"Kuo, Donald" <donald.kuo@intel.com>
Subject: Re: [edk2-devel] UefiCpuPkg: Proposal to enable/disable AP parallel
Date: Thu, 21 Nov 2024 09:54:00 +0000	[thread overview]
Message-ID: <MN0PR11MB6158A9E4738F6A6F1A6F562AFE222@MN0PR11MB6158.namprd11.prod.outlook.com> (raw)
In-Reply-To: <PH0PR11MB50489D9D4A9D056BFF8F584B90212@PH0PR11MB5048.namprd11.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 4495 bytes --]

Solution 1, it's not kind of spec violating. Instead, it's to add a new capability to the existing interface, and it's a compatible change, no impact to existing interface usage. I recall we have a guideline that prioritizes code-first approaches if there are no compatibility issues. Mike and Ray can comment on this. If no objection, I also prefer this way.
Solution 2 cannot handle the PPI case, leading to inconsistent behavior between the protocol and PPI for the mpservice2.

Solutions 3 and 4 are more like workarounds to address the specific issue.

Thanks,
Jiaxin

From: Liu, Zhiguang <zhiguang.liu@intel.com>
Sent: Wednesday, November 20, 2024 3:13 PM
To: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>; Tan, Dun <dun.tan@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann <kraxel@redhat.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Cc: Kumar, Chandana C <chandana.c.kumar@intel.com>; Zhao, Jason <jason.zhao@intel.com>; Kuo, Donald <donald.kuo@intel.com>
Subject: UefiCpuPkg: Proposal to enable/disable AP parallel

Hi MdePkg and UefiCpuPkg maintainers and reviewers

Recently, we met a performance issue when waking up disabled APs.
There is usage where BIOS needs to disable all APs, do something and then enable all APs.
Now, we are using the MpService PPI/Protocol EnableDisableAP(). This function can only enable/disable one AP each time.
To enable one AP, MP service needs to send INIT-SIPI-SIPI, which takes around 10ms.
And now, we will have more than 10 APs in a client platform, and it will take more than 100ms.
The function definition of EnableDisableAP is:
typedef
EFI_STATUS
(EFIAPI *EFI_MP_SERVICES_ENABLEDISABLEAP)(
  IN  EFI_MP_SERVICES_PROTOCOL  *This,
  IN  UINTN                     ProcessorNumber,
  IN  BOOLEAN                   EnableAP,
  IN  UINT32                    *HealthFlag OPTIONAL
  );
The input parameter ProcessorNumber accepts a range from 0 to the total number of logical processors minus 1.

To support enable/disable AP parallel, I have below solutions:

Solution1:
Let input parameter ProcessorNumber accept a MAX_UINTN also. MAX_UINTN means to enable/disable all APs.
The draft PR is at https://github.com/tianocore/edk2/pull/6453 When the parameter is MAX_UINTN, EnableDisableAP() will enable/disable APs in a parallel way.
                However, we need to change below header files
                                MdePkg\Include\Protocol\MpService.h
                                MdePkg\Include\Ppi\MpServices.h
                                UefiCpuPkg\Include\Ppi\MpServices2.h
                The above two follow PI spec. We need to modify the PI spec first.

Solution2:
                Similar with solution1, but to avoid violating spec, add a new Protocol named MpServices2. Only change below header files.
                                UefiCpuPkg\Include\Ppi\MpServices2.h
UefiCpuPkg\Include\Protocol\MpServices2.h (new)
                The MdePkg part remains no change.

Solution3:
                MpService create new PPI/Protocol to only contain one function EnableDisableAllAps(), which will enable/disable all APs in a parallel way.

Solution4:
                Add PPI/Protocol notify in MpLib. The notify call back function will set WakeUpByInitSipiSipi to True. Similar code is removed in https://github.com/tianocore/edk2/pull/6303/commits/f1f8374381019169d421a65a896ab42ed5338c1e
                When users need to disable and then enable cores, the flow will be:

  1.  Send Init to all APs. (to disable all APs)
  2.  Do things that user need to do when all APs are disabled
  3.  Notify callback function
  4.  Use StartupAllAPs() from existing PPI/Protocol to wake up all APs.
The flow is similar with how S3 SMM code take control APs and then give the control back in old days.

Personally, I prefer solution1. It is simpler, but it does violate spec.
Please let me know your comments or any new idea, please share.

Thanks
Zhiguang



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120808): https://edk2.groups.io/g/devel/message/120808
Mute This Topic: https://groups.io/mt/109680758/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 13992 bytes --]

  reply	other threads:[~2024-11-21  9:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20  7:12 [edk2-devel] UefiCpuPkg: Proposal to enable/disable AP parallel Zhiguang Liu via groups.io
2024-11-21  9:54 ` Wu, Jiaxin via groups.io [this message]
2024-11-21 12:03   ` Zhao, Jason via groups.io
2024-11-21 18:43     ` Michael D Kinney via groups.io
2024-11-26  7:47       ` Zhiguang Liu via groups.io

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-list 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=MN0PR11MB6158A9E4738F6A6F1A6F562AFE222@MN0PR11MB6158.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /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