From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id E583694132C for ; Wed, 20 Nov 2024 07:12:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=WPx+vvzIEAcOm4wgd6CeLMKJQD3cTPymginZaUNFIOk=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20240830; t=1732086771; v=1; x=1732345970; b=IDCUc8NPxzHYL7YojBcrzCpufSTzZnvx4rlMtsH9swHB3cinUgOjRD03fgYSkKKyb6xCianD +hwDOTf+HFKeZGVWPzJov6IB+DQOauGSQE1vSLnQPD6Eoc+Xw95e170TbE4mQHnnBqD7Xq1B0Jz FtCnjN2P6lG2j6sXriXhfNNtIFg7bfpFq6bSFRTtYRe037mYCHJlz69j7Mxw+wwfZGv4chozOnn pixj4oYYHFBc8IieVpjAv8Hez84zvM51EFi/hfM1VrHTDS1PhHI4QKq1ZldQByH7mu65tibdXzX apJ8XN+cmc/kifNJQ3Fp9/yBsrC9FV2KEsr47ZXl4dHuA== X-Received: by 127.0.0.2 with SMTP id 9sp5YY7687511xliVZJ8dcNO; Tue, 19 Nov 2024 23:12:50 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web11.7939.1732086769256222546 for ; Tue, 19 Nov 2024 23:12:49 -0800 X-CSE-ConnectionGUID: 4FMl/O7BQ5Ccbb1R2VFNyw== X-CSE-MsgGUID: FP1NRpb4R3eRMZtOfTLRGQ== X-IronPort-AV: E=McAfee;i="6700,10204,11261"; a="54630015" X-IronPort-AV: E=Sophos;i="6.12,168,1728975600"; d="scan'208,217";a="54630015" X-Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2024 23:12:49 -0800 X-CSE-ConnectionGUID: hMlMiL5ERN2jaIJW2f4iOA== X-CSE-MsgGUID: lqxrwXbKSRqCWUv2LJHwVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,168,1728975600"; d="scan'208,217";a="93884767" X-Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmviesa003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 19 Nov 2024 23:12:48 -0800 X-Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 23:12:48 -0800 X-Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Tue, 19 Nov 2024 23:12:48 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.45) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 19 Nov 2024 23:12:47 -0800 X-Received: from PH0PR11MB5048.namprd11.prod.outlook.com (2603:10b6:510:3d::14) by SA1PR11MB6710.namprd11.prod.outlook.com (2603:10b6:806:25a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Wed, 20 Nov 2024 07:12:40 +0000 X-Received: from PH0PR11MB5048.namprd11.prod.outlook.com ([fe80::67b2:6d4a:c673:54a]) by PH0PR11MB5048.namprd11.prod.outlook.com ([fe80::67b2:6d4a:c673:54a%7]) with mapi id 15.20.8158.023; Wed, 20 Nov 2024 07:12:39 +0000 From: "Zhiguang Liu via groups.io" To: "devel@edk2.groups.io" , "Ni, Ray" , "Wu, Jiaxin" , "Liu, Zhiguang" , "Tan, Dun" , "Kumar, Rahul R" , Gerd Hoffmann , "Kinney, Michael D" , "Gao, Liming" CC: "Kumar, Chandana C" , "Zhao, Jason" , "Kuo, Donald" Subject: [edk2-devel] UefiCpuPkg: Proposal to enable/disable AP parallel Thread-Topic: UefiCpuPkg: Proposal to enable/disable AP parallel Thread-Index: Ads7ENWFYT6OL6QbQl+cr51i2qWfsQ== Date: Wed, 20 Nov 2024 07:12:39 +0000 Message-ID: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR11MB5048:EE_|SA1PR11MB6710:EE_ x-ms-office365-filtering-correlation-id: a4a122a3-684e-44e9-e41c-08dd0932b827 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?QqmAsXRE09ElVrfmoRm+qZ+LhXCB4txanaz4qPFSx/gPa0a61b1IpqvmcRGy?= =?us-ascii?Q?qqWqA9GwHtsg3eDgGpLIyes8whlTqGSuLRUz7UwxH3oUyB+420Pazhlsbxm7?= =?us-ascii?Q?avk+Zg6rD0b0kVw4kZNvdpdDRvuAMn4AOg/AAhy5+23KizCu1J58/kGGGgG5?= =?us-ascii?Q?zCJwl3EzJm+VTT5p+DR647pL2s+zsvu5YTbmEtAry5HvSUdCJhIqcHengD4F?= =?us-ascii?Q?uhqQ2psbWleKY3HeK4JLOY7KLh+HpiX7LpgOd0GNc88BIuYeqdnySkW9KMXp?= =?us-ascii?Q?Q1r4pYBeBDTUMP7vrYkr+Or1gvQD9SGd8us+Qcs2f8uM10DqqFwHZ9Hj9FVa?= =?us-ascii?Q?r+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ezufmktJte4OHxTcGdyREhYrguwRgh/yUztra7Hq1FP?= =?us-ascii?Q?IUKFOj8JzHzOBkIksGCkWn0me0tTzg6z44runXdbunu5xO9IIL/a4sWPw66z?= =?us-ascii?Q?zyIF2dMTtc37SrcTZco7jv6o1VWAUiNn5QcFob6rNKXyDVhlfDFCv0PHXf7Q?= =?us-ascii?Q?wL7ovaor4siPa9sqSzVjmF0STqY2?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?WY9YWLPZP5qdeHTJdY5ngV6hTSLQSo7up929FO2UWz671f3sqdgM3398nmYs?= =?us-ascii?Q?Y6EKMf70YqApLAe5LfpUneypN1ILuHIbqltoy940UZspMhGmyKRQfeGnSMuc?= =?us-ascii?Q?VyJiaCVcNn8J1tdc/9gEVlaNYPjkdjfomWVjEQkumgqhMJfFUePRreaaVTrZ?= =?us-ascii?Q?CDIbUom1Ji2ye4F/1w6Satd/A/S+ASTDGLrwFw8tncgS1o6wnspQ9fTCGNqC?= =?us-ascii?Q?ZYOvtBDEmJQTGI64joM2h46gLK7pITDnFyL3mFPNz1PDf2fkJLoBf2Xwc/ma?= =?us-ascii?Q?iQzq1zjqNc2blfN05x6feu1ptTVezRrRzkyifiDqsZaYimcS3aFtEIfARuDx?= =?us-ascii?Q?VZtmgK3tozvQkiJre1E/2jAC4V+oqjfFCTcId3aGz1jbxKn5AhbdAoLqXYkA?= =?us-ascii?Q?fYfRydRan/as/VwBtketlKBA2Ef/AmNP+MUb7q/aM9NHYtAk2+/NIZIWRj5e?= =?us-ascii?Q?47NKEqD6/k94LUsqzy+v3ngpklueAJA5gubUMMR4JZVkBWCtIqSr17RQ624e?= =?us-ascii?Q?sUTC8Gi7XCbsF9TUuFzzC5Ul5PCfnPp4HlSQ4Uh8gpR2xTChw3iSf8BXTUje?= =?us-ascii?Q?RhuTRyjG0zO5jvNAc5WeHuVHnvUgwY+2K/Z3jILGNwoDmGoCM9m9nm0G/S7Y?= =?us-ascii?Q?534At19VNcXYg0d0I/MwbM3fbUe4WRagi0701mpeNdjhGWO+z36NYW57O9fp?= =?us-ascii?Q?xNsILv+IfAMjAjhBhBLIgNVuy4ZIb4gQeEpiJUffTkio2vF2nhvlwDG4yjMa?= =?us-ascii?Q?SBSxBwCqgenz3EDg22YrRxreUqLrgXI4IeC+jtdAjIloQUmusnlYvhvqdM9z?= =?us-ascii?Q?HnhigbKrmUKrQ7NUJP9B2zEut/hn66BEcKotN2N79VGgGB1i2GSEjypREEYl?= =?us-ascii?Q?eobsbq75rRQlaOqchKOyFlj/qivHm88HOlyordiGPLV+ebHtXSnqFFe2pjXA?= =?us-ascii?Q?cOdVz+4wnSGucQedGBPLYi3lcVB6Dnw4ApAp/m9i8066C3MkYvAc3JMz7X+3?= =?us-ascii?Q?cXoyyc+33Ulnj2/GJM/TBo6IocwW2oodGfhZq+fcXB0q+gRefRR3Qhax3Rwc?= =?us-ascii?Q?dOxilFyo12qzxWvT1AejdHopKb36gt8l6VXCHMR5g8eik6/gHv2u9OWm1jvu?= =?us-ascii?Q?HmVT3sEMDt7wnghJCnXkhYKG1MS2L2GuuX1lK81sg3c0xUZ55KbcHDlQcEHU?= =?us-ascii?Q?rzBzu4iAY1rrrQFaan6N0oxNB1XOjWtyW0QrW93acwMNil4WPMborNnd+TX1?= =?us-ascii?Q?Oq+2rPo29keX/DdDgiPx+NkkZKz2gvfNsjEgumtIjycp5Jpq5Yw1WK1OrTsu?= =?us-ascii?Q?iw6i+yq7txyI0b8Zbp6XktMnh9upFPWjc0z35dbsB4CQe2ME3XonWGClRQ7l?= =?us-ascii?Q?M1sywSqZOCF2vBvzYX9XEomN/dt9pboxm/vq/vYDlVs/yRqkDw/rg9L43bNf?= =?us-ascii?Q?KiU8yyJlG818qY4wNfJaR6nFNHkcpqs78avovWVmY88X4buRMw/379oeArlc?= =?us-ascii?Q?WYZdTgXcmotPGo16XHz3AtDf+E6vhsJnlMPrerr70ePUKAxuG76V21EI6VFJ?= =?us-ascii?Q?xpAvWvdhRlRv8e01JMbnavJZYKAo38PnuoTHOM64?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5048.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4a122a3-684e-44e9-e41c-08dd0932b827 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Nov 2024 07:12:39.9096 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: n24RJjRJ12mKQhISuFZbV9tvsWMbP4lmbNRiZLplZMx431yrhR9ktNd+qDRVMTFxu0F3Pv2DPpOQhZJjlJJS1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB6710 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 19 Nov 2024 23:12:49 -0800 Resent-From: zhiguang.liu@intel.com Reply-To: devel@edk2.groups.io,zhiguang.liu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: buAyhuaBaTrY9fojKJxlvbOGx7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_PH0PR11MB50489D9D4A9D056BFF8F584B90212PH0PR11MB5048namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=IDCUc8NP; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --_000_PH0PR11MB50489D9D4A9D056BFF8F584B90212PH0PR11MB5048namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 e= nable all APs. Now, we are using the MpService PPI/Protocol EnableDisableAP(). This functi= on can only enable/disable one AP each time. To enable one AP, MP service needs to send INIT-SIPI-SIPI, which takes arou= nd 10ms. And now, we will have more than 10 APs in a client platform, and it will ta= ke 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 num= ber 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 mean= s to enable/disable all APs. The draft PR is at https://github.com/tianocore/edk2/pull/6453 When the par= ameter is MAX_UINTN, EnableDisableAP() will enable/disable APs in a paralle= l 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 funct= ion EnableDisableAllAps(), which will enable/disable all APs in a parallel = way. Solution4: Add PPI/Protocol notify in MpLib. The notify call back func= tion will set WakeUpByInitSipiSipi to True. Similar code is removed in http= s://github.com/tianocore/edk2/pull/6303/commits/f1f8374381019169d421a65a896= ab42ed5338c1e 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120802): https://edk2.groups.io/g/devel/message/120802 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_PH0PR11MB50489D9D4A9D056BFF8F584B90212PH0PR11MB5048namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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 EnableD= isableAP(). 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 p= latform, and it will take more than 100ms.

The function definition of EnableDisableAP is:<= /o:p>

typedef

EFI_STATUS

(EFIAPI *EFI_MP_SERVICES= _ENABLEDISABLEAP)(

  IN  EFI_MP_S= ERVICES_PROTOCOL  *This,

  IN  UINTN &n= bsp;                   Process= orNumber,

  IN  BOOLEAN =                   EnableAP,

  IN  UINT32 &= nbsp;                  *Health= Flag 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 Proce= ssorNumber accept a MAX_UINTN also. MAX_UINTN means to enable/disable all A= Ps.

The draft PR is at https://github.com/tianocore/edk2/pull/6453 When the parameter is MAX_U= INTN, EnableDisableAP() will enable/disable APs in a parallel way.

        &nbs= p;       However, we need to change below hea= der files

        &nbs= p;            &= nbsp;          MdePkg\Include\= Protocol\MpService.h

        &nbs= p;            &= nbsp;          MdePkg\Include\= Ppi\MpServices.h

        &nbs= p;            &= nbsp;          UefiCpuPkg\Incl= ude\Ppi\MpServices2.h

        &nbs= p;       The above two follow PI spec. We nee= d to modify the PI spec first.

 

Solution2:

        &nbs= p;       Similar with solution1, but to avoid= violating spec, add a new Protocol named MpServices2. Only change below he= ader files.

        &nbs= p;            &= nbsp;          UefiCpuPkg\Incl= ude\Ppi\MpServices2.h

UefiCpuP= kg\Include\Protocol\MpServices2.h (new)

        &nbs= p;       The MdePkg part remains no change.

 

Solution3:

        &nbs= p;       MpService create new PPI/Protocol to= only contain one function EnableDisableAllAps(), which will enable/disable= all APs in a parallel way.

 

Solution4:

        &nbs= p;       Add PPI/Protocol notify in MpLib. Th= e notify call back function will set WakeUpByInitSipiSipi to True. Similar = code is removed in https://github.com/tianocore/edk2/pull/6303/commits/f1f8374381019169d421a65= a896ab42ed5338c1e

        &nbs= p;       When users need to disable and then = enable cores, the flow will be:

  1. Send Init to all APs. (to disable all APs)
  2. D= o things that user need to do when all APs are disabled
  3. Notify callback function
  4. Use StartupAllAPs() fro= m 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 i= t does violate spec.

Please let me know your comments or any new idea, pl= ease share.

 

Thanks

Zhiguang       &n= bsp;  

 

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#120802) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_PH0PR11MB50489D9D4A9D056BFF8F584B90212PH0PR11MB5048namp_--