From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id B5B80D8003E for ; Tue, 2 Jan 2024 02:49:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=1fS+I6DnPq2VWedy2/OulyjS0oGg8WCWR8PZ+prFimM=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1704163768; v=1; b=Qe3htDUN9GfATPK3qLtp+fQK0WXMTYfnHKeWyDsGbiVLnDzfwMwj4zSEWl9WPeZrDuE6316B U0eIa9eRwfeTGpVOVISAvWUZkV7k3va2cfRISlabDnclJIz6kKVVZf/cHGbNgO827avY81GKc1l vR4W2+uup/OlPIC6Pd9/higE= X-Received: by 127.0.0.2 with SMTP id 6mg6YY7687511x6txNnvUaZW; Mon, 01 Jan 2024 18:49:28 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.21396.1704163766294432610 for ; Mon, 01 Jan 2024 18:49:27 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10940"; a="381789998" X-IronPort-AV: E=Sophos;i="6.04,324,1695711600"; d="scan'208";a="381789998" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jan 2024 18:49:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10940"; a="783067012" X-IronPort-AV: E=Sophos;i="6.04,324,1695711600"; d="scan'208";a="783067012" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 01 Jan 2024 18:49:22 -0800 X-Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 1 Jan 2024 18:49:21 -0800 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 1 Jan 2024 18:49:21 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 1 Jan 2024 18:49:21 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=biE79TfHHnSn3XsxlXcnfvVAOY/EweRHSNH7Fo0QOPGg8/FENL6Rp3zuH72koCU6wdfjlPMs+htjJE5bV8EDUGZRYyZd5Kw6GfJQvzYzcO2ypiw/KLIQtBl24ncAYCgA5ih1nGlkQayoEkssjLhrjnxFwNrSRfmb+Q2NbuDzaeMDs1mE3eY9V257CP1l5bSy/JOLCy17LeTMUXkyju+3MMTnMWdKAtsJejI4QQHEgAzWGGkMhjT88zme/8fv2URce75wzSCZT7JD3ogpMZRTTxYS3M5OYB4O1H5bMhfE6GTrg5Vr8C8pSXeTAHsaOt5SKwamSK9r5cDohN/8+17Waw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YS+O0+D4MkHDm/HBjv+RgDVaEX/tjLkGVeMa9Tf9a0Y=; b=hhR/w9LGWXDyN2EGM3VvLCXEot0ZnIk+vHcGDUWDACjSM45JsSJMu+xyryXSK5BzBmE2L0DYTWjWOsYPKZ1PZWUVOBq8FY5ShpLYy+FQhOP8KSSkfvfmlm+Hp/rDU0l5vblCFCMr1J0DkIPyqWsYkhGYJGAs5FWoGu/QcQaPcVywtrFFc+sN00VML/UDtHmR/ySIfCvNh3epl9qtGt/gQkGEXUhixc90PTtuh3tWfHJeyG6j2aXQEgqZp9fcKN26AiowPx5+JgaZO6qGBdpf35P8bE1+CGMB6x8u6GcogtcwpNWSS69/DLonrvBuuhT73E2PAl6Xae7WAQmCx498zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by CO6PR11MB5650.namprd11.prod.outlook.com (2603:10b6:5:35a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.21; Tue, 2 Jan 2024 02:49:14 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::3fea:ca2b:2ef7:e3d4]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::3fea:ca2b:2ef7:e3d4%4]) with mapi id 15.20.7135.023; Tue, 2 Jan 2024 02:49:14 +0000 From: "Ni, Ray" To: "Liu, Zhiguang" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul R" , Gerd Hoffmann , "Zeng, Star" , "Li, Daoxiang" Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/CpuMpPei: Parallel get stack base for better performance. Thread-Topic: [PATCH] UefiCpuPkg/CpuMpPei: Parallel get stack base for better performance. Thread-Index: AQHaOgdSq4Iexli0KEep7o00gBowirDF0lxg Date: Tue, 2 Jan 2024 02:49:14 +0000 Message-ID: References: <20231229032938.1129-1-zhiguang.liu@intel.com> In-Reply-To: <20231229032938.1129-1-zhiguang.liu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|CO6PR11MB5650:EE_ x-ms-office365-filtering-correlation-id: e0335bac-fffa-46e4-da9f-08dc0b3d67c5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: CPfzWiTQp4cVmx6jjk3gYg8sm/J3h316UhmxlsHxjsbAy2oAZjPxVOfmAzRdDZMT+X7RpB76FPbb2inNHgS0ajX2S/wPOHzroxVXdhFfVtZb9b5YO4pwc36c0tUS8tJa53uBhvPsf7iNI38Uhh1Or3WPMvaFg6FLwxVdUvH3xGLMs2bPRQbVppw2/imc5MJewNJJpKehMCO6sQV+aQy3waaZAzzNF9MUe2D4Nzyj+gz8DKWZvPiR4qWO86QrLnLwonqM4lop3LSkdNe9cZd3Jb8OrBK3esTvnGCUyaYR4otLK6SKW4N1RtLhKhfpeX7iUndsrV+onk3Li27YXJ1YV/1+yof7uhqwYAoXOqJ6ecNFa4TWwj+NJ+RDc2iNBQlmn3aYyCQjKbRtAswXfEFjXFz5g3tOHQLHGiRY0T39ap+A8CoCOBzr8asw+GN5uO7+/kYqBPTIXZnZD9NZ5FLo+lzans4eL3haOoi6rTveQoK/7RH1lB6VnkL9NK3JbBxXDfWk/xejwS/MWJI0uvBRlZ0gBT3f7Bk3Ps2AezEGxNKULC75JhuzRVGFpzYSktigXa91AKKk4WlaLfjjH2oy+bZxxaWZkp1SFo/mY8XsxsrP35CWxO523VnLo6hX3zIS x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?2/IyOSC89FuOgYK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q?IK6A8tLpMECo8QNzF19IrPxwZ5CA6/IOr+Exgn6Oy3G4c4ifgKfLFY5COOh5?= =?us-ascii?Q?Ja9jUUWW7M1vTfFi3hgNfyROeB8it65Nf9cu0iiRZFXQnBJZ3YmqK+6od2Nr?= =?us-ascii?Q?h9RfKqP+jQ8KNaKQ1xkL1wTu0LQsNZtvLqgsiHHHKIPETuL2S3Z43p1JEIiU?= =?us-ascii?Q?LB7eSNPrYZw5Q2wVXai+UM9rubiUbCz/IzdEoubB0FJJ3Wih6oV3FenKdVVv?= =?us-ascii?Q?NLteEVwALFuCSpr3T9p/hQ+CylBFffprqZLRNryNUCTbvnCv6+tQ8xbKSuqr?= =?us-ascii?Q?Tl5KT4BGNqmCtswQJ584bOnxLDUHhlT3TFnsechvnwvf7WIA7GrgtWH5F3EO?= =?us-ascii?Q?XUx/42l4V927tYqLUMEe/SsBeymuYEqlsdbdgCIzWZetkOPYdnflYyViu+J9?= =?us-ascii?Q?ZIl4AkTt0kjlx3tfX1e7NlQd1pCb/rn7lSyb000vVAYBrTZbOySZh+b8UvPi?= =?us-ascii?Q?bdTXehsbDelKcWvwv4qyy9rWgT10U2hg8qSjxL2/KiAPYkc5y4QdrjfMAjSw?= =?us-ascii?Q?4RX77Xw5f6bg9tKpmEvFvNF5jvGGOPjcL6DhT3AiInH3+KbaIN9QsE+74zOk?= =?us-ascii?Q?H6Zjvnm5sNE/ld7PM5v0uBc3Gu8Ki/RUwSk7eR+AthOnn7IMIhKXhtnFm2IB?= =?us-ascii?Q?5ZsvsypiOEkborR6aAg=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0335bac-fffa-46e4-da9f-08dc0b3d67c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jan 2024 02:49:14.1206 (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: vuX9ujs7J0ZmfVudrCLtecZB1GPYjUtYM35hgu10ebU4sO6vRZOhO+6GTmfvAq7cUx7pA9SoE8DkW+WTe55opA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR11MB5650 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 Reply-To: devel@edk2.groups.io,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 5ZkNEY9w44f8u5zn0Ygc8jngx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Qe3htDUN; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Reviewed-by: Ray Ni Can you please submit another patch to remove AsmWriteCr3() in ConvertMemor= yPageToNotPresent() as CpuFlushTlb() has been called later? Thanks, Ray > -----Original Message----- > From: Liu, Zhiguang > Sent: Friday, December 29, 2023 11:30 AM > To: devel@edk2.groups.io > Cc: Liu, Zhiguang ; Ni, Ray ; > Laszlo Ersek ; Kumar, Rahul R > ; Gerd Hoffmann ; Zeng, Star > ; Li, Daoxiang > Subject: [PATCH] UefiCpuPkg/CpuMpPei: Parallel get stack base for better > performance. >=20 > Parallel run the function GetStackBase for all APs for better > performance. >=20 > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Cc: Gerd Hoffmann > Cc: Star Zeng > Cc: Daoxiang Li > Signed-off-by: Zhiguang Liu > --- > UefiCpuPkg/CpuMpPei/CpuPaging.c | 56 +++++++++++++++++---------------- > 1 file changed, 29 insertions(+), 27 deletions(-) >=20 > diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c > b/UefiCpuPkg/CpuMpPei/CpuPaging.c > index 2dd7237141..15c7015fb8 100644 > --- a/UefiCpuPkg/CpuMpPei/CpuPaging.c > +++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c > @@ -267,13 +267,15 @@ GetStackBase ( > ) > { > EFI_PHYSICAL_ADDRESS StackBase; > + UINTN Index; >=20 > + MpInitLibWhoAmI (&Index); > StackBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)&StackBase; > StackBase +=3D BASE_4KB; > StackBase &=3D ~((EFI_PHYSICAL_ADDRESS)BASE_4KB - 1); > StackBase -=3D PcdGet32 (PcdCpuApStackSize); >=20 > - *(EFI_PHYSICAL_ADDRESS *)Buffer =3D StackBase; > + *((EFI_PHYSICAL_ADDRESS *)Buffer + Index) =3D StackBase; > } >=20 > /** > @@ -287,7 +289,7 @@ SetupStackGuardPage ( > ) > { > EFI_PEI_HOB_POINTERS Hob; > - EFI_PHYSICAL_ADDRESS StackBase; > + EFI_PHYSICAL_ADDRESS *StackBase; > UINTN NumberOfProcessors; > UINTN Bsp; > UINTN Index; > @@ -308,44 +310,44 @@ SetupStackGuardPage ( > NumberOfProcessors =3D 1; > } >=20 > + StackBase =3D (EFI_PHYSICAL_ADDRESS *)AllocatePages > (EFI_SIZE_TO_PAGES (sizeof (EFI_PHYSICAL_ADDRESS) * > NumberOfProcessors)); > + ASSERT (StackBase !=3D NULL); > + if (StackBase =3D=3D NULL) { > + return; > + } > + > + ZeroMem (StackBase, sizeof (EFI_PHYSICAL_ADDRESS) * > NumberOfProcessors); > + MpInitLibStartupAllAPs (GetStackBase, FALSE, NULL, 0, (VOID *)StackBas= e, > NULL); > MpInitLibWhoAmI (&Bsp); > - for (Index =3D 0; Index < NumberOfProcessors; ++Index) { > - StackBase =3D 0; > - > - if (Index =3D=3D Bsp) { > - Hob.Raw =3D GetHobList (); > - while ((Hob.Raw =3D GetNextHob > (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) !=3D NULL) { > - if (CompareGuid ( > - &gEfiHobMemoryAllocStackGuid, > - &(Hob.MemoryAllocationStack->AllocDescriptor.Name) > - )) > - { > - StackBase =3D > Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress; > - break; > - } > - > - Hob.Raw =3D GET_NEXT_HOB (Hob); > - } > - } else { > - // > - // Ask AP to return is stack base address. > - // > - MpInitLibStartupThisAP (GetStackBase, Index, NULL, 0, (VOID > *)&StackBase, NULL); > + Hob.Raw =3D GetHobList (); > + while ((Hob.Raw =3D GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, > Hob.Raw)) !=3D NULL) { > + if (CompareGuid ( > + &gEfiHobMemoryAllocStackGuid, > + &(Hob.MemoryAllocationStack->AllocDescriptor.Name) > + )) > + { > + StackBase[Bsp] =3D > Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress; > + break; > } >=20 > - ASSERT (StackBase !=3D 0); > + Hob.Raw =3D GET_NEXT_HOB (Hob); > + } > + > + for (Index =3D 0; Index < NumberOfProcessors; ++Index) { > + ASSERT (StackBase[Index] !=3D 0); > // > // Set Guard page at stack base address. > // > - ConvertMemoryPageToNotPresent (StackBase, EFI_PAGE_SIZE); > + ConvertMemoryPageToNotPresent (StackBase[Index], EFI_PAGE_SIZE); > DEBUG (( > DEBUG_INFO, > "Stack Guard set at %lx [cpu%lu]!\n", > - (UINT64)StackBase, > + (UINT64)StackBase[Index], > (UINT64)Index > )); > } >=20 > + FreePages (StackBase, EFI_SIZE_TO_PAGES (sizeof > (EFI_PHYSICAL_ADDRESS) * NumberOfProcessors)); > // > // Publish the changes of page table. > // > -- > 2.31.1.windows.1 -=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 (#113020): https://edk2.groups.io/g/devel/message/113020 Mute This Topic: https://groups.io/mt/103412489/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-