From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.81563.1629453718316697246 for ; Fri, 20 Aug 2021 03:01:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=c0/KL+QP; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: jackx.lin@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10081"; a="280479008" X-IronPort-AV: E=Sophos;i="5.84,337,1620716400"; d="scan'208";a="280479008" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 03:01:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,337,1620716400"; d="scan'208";a="523493135" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by FMSMGA003.fm.intel.com with ESMTP; 20 Aug 2021 03:01:33 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10; Fri, 20 Aug 2021 03:01:33 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10 via Frontend Transport; Fri, 20 Aug 2021 03:01:33 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168) 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.2242.10; Fri, 20 Aug 2021 03:01:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T0dx11DYcKPbRoQFM5VaBBsim108JEfmIyjEe1xL+To7ltUJBqHFv6sTvFFDaPfKeomZOr8th5E9pEZLCUNIp1FyQ14Nhi0sT7mVO6eED9PoZ7jyiFsrGxFy12ecGbIc8xIzzzoG4AL3N/DRcHDUtQGil0hu7QP5/CbCQ11OAhTVoVwER0QWplYkgj4oP+m7wkZuhQcxKRjkdNysrLW9qwfRpDYrkKTxnkN05jJbkg4p+/xnifJxTxuAzvzc/2WkUhoa0oVPxwYHOFlqHiI03cpFB3Pr7yIRRm8E/0vCgS8FbIKcBu74e7wsJ8V3xULfKJzlsLrA4xrM/mI+XiODCQ== 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-SenderADCheck; bh=YX3o64/bjhtdS4ShC4OJcOy9bOV3UYL+TDiKuRyDv3o=; b=dctaIdFXylopllXZo4ehKMqJTCWC1jQS7mfFHidMexKq000gx6lKpa3yUiMGIg9wBOGgcOpUMjldduicMHwu5G4u2c/NPZyyO6j0r1KIvT7sn1pJJaA5aTu5m9XWiTG1IBmDZpODzaUmo7r06zfvALd6XOTRUkISA5kScpzPPT9Ni3G9Eald2U1AiTUuGJTIpYwqtaifxK7go5lGArgSfYXWg9EjeBAQj7/NCiRnGLrYJfqE4AT4QvQsc7FMXZZSHu3pypi9RtO68d8J4yH0NbT6RdqNstPiQRlllFxn2YBP8hCiYHHGIPVKZnWlChHNIxOMDAoiYpsdGu9PLp4MgA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YX3o64/bjhtdS4ShC4OJcOy9bOV3UYL+TDiKuRyDv3o=; b=c0/KL+QP0wbeIFHPA37htzrBEiVwiJWGDSz3NgKRlL7zx3ti/ndyceeBmbU5lGWTG7guuD4Xs/w6IljLc3s8z8dN/UNRWkqqZCGFJCDhqXyakoDDlM2VaHxCMvMVm1YHPsXYGO994o+P30d54v9DFNNZ1aHxsJBZB3OluPk7baw= Received: from DM6PR11MB3738.namprd11.prod.outlook.com (2603:10b6:5:139::25) by DM4PR11MB5245.namprd11.prod.outlook.com (2603:10b6:5:388::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 20 Aug 2021 10:01:30 +0000 Received: from DM6PR11MB3738.namprd11.prod.outlook.com ([fe80::d0e8:aa91:7d35:b0e1]) by DM6PR11MB3738.namprd11.prod.outlook.com ([fe80::d0e8:aa91:7d35:b0e1%7]) with mapi id 15.20.4415.025; Fri, 20 Aug 2021 10:01:30 +0000 From: "JackX Lin" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Chiu, Chasel" , "Dong, Eric" , "Yao, Jiewen" , "Chaganty, Rangasai V" , "Kuo, Donald" , "Kumar, Chandana C" Subject: Re: [edk2-platforms: PATCH V8] Platform/Intel: Correct CPU APIC IDs Thread-Topic: [edk2-platforms: PATCH V8] Platform/Intel: Correct CPU APIC IDs Thread-Index: AQHXkpiBi110NAfYJUajtDZ/eCaDWqt60BpwgAFemjA= Date: Fri, 20 Aug 2021 10:01:30 +0000 Message-ID: References: <20210816121547.226-1-JackX.Lin@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 37b11010-fff3-4ed6-288d-08d963c17be7 x-ms-traffictypediagnostic: DM4PR11MB5245: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DDZap5VeF8yUlEiLctQKu9RqdDPB0abuC/c+Y/hOFYUO10/5iVQkEZ1uJBBgP2ANtWuKWtCdeeAHdbmPvKrzwX/GVgrOoZON7Sob2SA8WmwMecmCq6OxwNH6vXccqWbiM8KfF0wjPRVtMWcg8dW9XZeuiTQE3LyLGx6lH4TaCKPCqUhU+SHIManIsFu34LvGNwNmIpWGdwGJGnrPtd/71ELEyNobH04fyBZECvPn1dXWnU2g1NVqEmi3CmgtIJXWL5pW9Yq8US2Ra0EZU1pErR9z6TXwhwpaFHAKKMmO8pXsp0sNSltpuT6K7DDgO9QY3LW0HMei2g4gX2CGOBx5NwesvHQs8iDh+WNoQSJn467Hlm2eU+YaV/sxCd+kqA4LJ3WLPuYihMVnC9ab//qhV+atQ3M/abdeJSU47xKji/R6fpf7K7sSfxKWv3ZQ5QrasARdxYRfq6Fscyicvyk9pdipyKtsLqfdGLx0UIRYtrh1zTRMH5Kv5K4VvqFqpWp7UxynxymS3eLtA1N2E+9G/Y6YiVZKJ0+k0DmYWnCcfr+rjrm5lxP0kGpdFBtiPyulmkEsqZBsK9UvorYHdT1grWEya6VJ0jUFwMNqKqvHaJrJLa7g+qE4L8eDtdGv8G6J/H+gZurzGNDI8UPRTfylunLryblH+MLX1FSAi1rBdl5+SBkRtXDJHDPqdOoTHjR6n90z4APEavibEdrl+4sFFw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3738.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(346002)(39860400002)(376002)(366004)(136003)(33656002)(2906002)(4326008)(38100700002)(5660300002)(8676002)(66556008)(478600001)(66476007)(8936002)(54906003)(86362001)(6506007)(38070700005)(110136005)(186003)(122000001)(26005)(66446008)(71200400001)(316002)(55016002)(66946007)(53546011)(64756008)(83380400001)(107886003)(9686003)(76116006)(7696005)(52536014);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?NiAeZrmaCBJ8SRQTP0HFjewxjn2S/Ee97Cnt6WuzvMumGe7UKQ3hHz1W2mMR?= =?us-ascii?Q?94LHEV4QlLA0JZ1Wo+zUfLS9/XPf5BytfbqzC2Y9SzqtftbgyhCUtEstEX43?= =?us-ascii?Q?4HskRMJeJe8jBige4QoOJtxzCE6U3UFPCMRCvSoQjpHWi9DUKdIss0MesuQK?= =?us-ascii?Q?j9ViDCP3klxDhfa6cgytPK3z3nkgOX3k7Cv8Rke4UBdvub2+tbtYBf9pHQxJ?= =?us-ascii?Q?SKftg1W9XRxJZR+jvCwaYvUqBZmt7AB19m2PrMvsqa2b8Al2ae2XdvfQUdwj?= =?us-ascii?Q?g25XwFiFAKnVrvgAcis4H09iGYH/dPIQ4Qv9bNYhxNCPNZWCS/mxWpk/5Isy?= =?us-ascii?Q?xZQX6KEjYab/dUEgvNthjP6FZukRV8yq4ivHGBYzpyxIIc4+XCmtgNCxSQJd?= =?us-ascii?Q?bsG+zIDTXjPoAiaBRuXnyhaKWsZjneAmG46/SA61+gKi2iB3xTjKCk6Qu5XK?= =?us-ascii?Q?+dFZ/pxsNEQCCouUuTTIWYLJUjsLIa6zZeboWpmmrAs8+k7YVX9NaP3T9uRf?= =?us-ascii?Q?gnYBi1B9mGVUlLVMVE8UCvuLhZu4mfUeKqFPA4HPF0wKye3/LcBWvlI6rNHm?= =?us-ascii?Q?DLhO6t0HGUjb+/sx0FALIo4dkJcxqozhaREFjAG9hMw4OR+ktzATAXRvrUvG?= =?us-ascii?Q?wj1qGkDIbiId5xwghlCmHXb0F1TFwiB+kB/28HEU8mxh/P/HZUpRRAngO6Ta?= =?us-ascii?Q?IFKFsLzdtPuaActSHe/Ltq7W6wVJLXcA6IGHLqR/HZC7UMDVR0UyC8V2jak0?= =?us-ascii?Q?V5Ab4AsM2IH08y5snnaU2XY69VNgwsp5rCO+7Obi1syEYl2Fg7gI1XCToFLc?= =?us-ascii?Q?dF3S75FBoJGMwoo61FwCXcNYMA9anhKVhzQonTOdj0mW5+3eLPqfT0DphSUv?= =?us-ascii?Q?DtalScGF3w/xO9PkCuRcM35jluFwLtLtsA/6am/RZ4UQtWjC9yFwhMesJ9H7?= =?us-ascii?Q?9vx2aWxz9THcjL3ltaZgrZ21SFJZTjDkNj3pi3dmooxSDQcfkP1cDTkenf+p?= =?us-ascii?Q?WQSb2Un7bTsnz5s8fHtWXDYWpGqdyEsiLf8SjM2oHT5JUQqoE7jEpIhAvhvL?= =?us-ascii?Q?faeId75zBhbLY+vRVs/sPiqiHOvjxuLivwF3D2YQe2UPx0L5REaEQHRW/+YJ?= =?us-ascii?Q?9wPoVlkV2D+UWPqJ8g9UE32tjGKbcF49uS+dUeu4kFUtu5fvrdiV0kW3khYB?= =?us-ascii?Q?6YbI9pjZGPWZ2xcnDGMiHy06x2W/BxOOfsMFBj7DBY1fxEaOc4oRVq+sHeOR?= =?us-ascii?Q?rOFLakaxvC39wc8ZdFc2Y7IWivwi5FTup+bNSF+gLI1s2fdXuxFVMzygeAoP?= =?us-ascii?Q?M/gmoivElCuKBmwvbOivP21K?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3738.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37b11010-fff3-4ed6-288d-08d963c17be7 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Aug 2021 10:01:30.6881 (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: UmXscagG79DGZHebpKXcA9Cz9vFMZO2kpRKQNMf6mAH/2qn5UsN+WNU8ti7eVsI9pCh+6IpjsA4zEshwOFlw8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5245 Return-Path: jackx.lin@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, Thanks for recommendations. For item5, after referencing the log from server platform. I think it is fine to keep original coding. For item1 to item4, all of them are optimized. I will re-sent the code patch. Thank you. Jack -----Original Message----- From: Ni, Ray =20 Sent: Thursday, August 19, 2021 9:23 PM To: Lin, JackX ; devel@edk2.groups.io Cc: Chiu, Chasel ; Dong, Eric ;= Yao, Jiewen ; Chaganty, Rangasai V ; Kuo, Donald ; Kumar, Chandana C Subject: RE: [edk2-platforms: PATCH V8] Platform/Intel: Correct CPU APIC ID= s > + CpuIdMapPtr->AcpiProcessorId =3D=20 > + (ProcessorInfoBuffer.Location.Package << mNumOfBitShift) + > (UINT32)ProcessorInfoBuffer.ProcessorId; 1. I don't understand this assignment. Since you will re-assign this later,= why not remove this assignment? > + > + //make sure 1st entry is BSP > + if (mX2ApicEnabled) { > + BspApicId =3D (UINT32)AsmReadMsr64 (0x802); } else { > + BspApicId =3D (*(volatile UINT32 *)(UINTN)0xFEE00020) >> 24; } =20 > + DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", BspApicId)); 2. you can use GetApicId() API from LocalApicLib library in UefiCpuPkg. > - if(mCpuApicIdOrderTable[0].ApicId !=3D BspApicId) { > - //check to see if 1st entry is BSP, if not swap it > - Index =3D ApicId2SwProcApicId(BspApicId); > + CopyMem (&TempVal, &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_= ID_ORDER_MAP)); > + CopyMem (&TempCpuApicIdOrderTable[Index], &TempCpuApicIdOrderTable[0= ], sizeof (EFI_CPU_ID_ORDER_MAP)); > + CopyMem (&TempCpuApicIdOrderTable[0], &TempVal, sizeof (EFI_CPU_ID_O= RDER_MAP)); > + TempCpuApicIdOrderTable[0].Flags =3D 1; 3. Why is " TempCpuApicIdOrderTable[0].Flags =3D 1;" needed?=20 > + for (CurrProcessor =3D 1; CurrProcessor < mNumberOfCpus; CurrProcessor= ++) { > + for (Index =3D CurrProcessor+1; Index < mNumberOfCpus; Index++) { > + if (TempCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId > TempC= puApicIdOrderTable[Index].AcpiProcessorId) { > + CopyMem (&TempVal, &TempCpuApicIdOrderTable[CurrProcessor], size= of (EFI_CPU_ID_ORDER_MAP)); > + CopyMem (&TempCpuApicIdOrderTable[CurrProcessor],=20 > + &TempCpuApicIdOrderTable[Index], sizeof > (EFI_CPU_ID_ORDER_MAP)); > + CopyMem (&TempCpuApicIdOrderTable[Index], &TempVal, sizeof=20 > + (EFI_CPU_ID_ORDER_MAP)); > } > + } > + } 4. Can you use PerformQuickSort() API from SortLib in MdeModulePkg? > + > + // > + // 5. Re-assigen AcpiProcessorId for AcpiProcessorUId uses purpose. > + // > + for (Socket =3D 0; Socket < MAX_SOCKET; Socket++) { > + for (CurrProcessor =3D 0, Index =3D 0; CurrProcessor < mNumberOfCpus= ; CurrProcessor++) { > + if (mCpuApicIdOrderTable[CurrProcessor].Flags && (mCpuApicIdOrderT= able[CurrProcessor].SocketNum =3D=3D Socket)) { > + mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId =3D=20 > + (ProcessorInfoBuffer.Location.Package << mNumOfBitShift) + > Index; > + Index++; 5. I think you need a AcpiProcessorId[MAX_SOCKET] array to remember the "Ac= piProcessorId" for each socket/package. For example: AcpiProcessorId[MAX_SOCKET]; ZeroMem (AcpiProcessorId); for (Socket =3D 0; ...) { for (CurrProcessor =3D 0; ...) { if (...Flags =3D=3D 1 && ...SocketNum =3D=3D Socket) { mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId =3D (ProcessorInf= oBuffer.Location.Package << mNumOfBitShift) + AcpiProcessorId[Socket]; AcpiProcessorId[Socket]++;