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.73065.1682405122098943570 for ; Mon, 24 Apr 2023 23:45:22 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=JMDZSUHC; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682405122; x=1713941122; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=fKQxhmd3QiWmWAOux8PkpsbD6passquoo+MtfNAKLIE=; b=JMDZSUHCKXI/zgDBvEFUNxqCPSqGoMCFSVpj0fSQH/GSOrHX0DwQ/Zsu KzJvAGl0Ez2yqg3OudxF5uTdwNfFNUzouRtoD4g6P4vepRfmish9UQOBq 6Ob49R923SJ9BPVlNdXteagrCyuv/BAFr2LMXbafUSmX83Ziov9jm8qaa qK9YJ8Vb/6UpAImKJH1aUfIQuJB2qj4qzvh/ni2DAynGPP7CLZEDXjzqN eF3a4r5HjDB5KCBjTwyNSZAIyKKGhbv3KcZuf9AUP1nNWgNktzy0P1E1J vzbq/mR09sKRpS5sG7BPtJDqMpieyF43r6bvS8YPnfPG7ReW8mRzWpIfv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="411962264" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="411962264" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2023 23:45:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="725989963" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="725989963" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2023 23:45:21 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.23; Mon, 24 Apr 2023 23:45:20 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 24 Apr 2023 23:45:20 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Mon, 24 Apr 2023 23:45:20 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.102) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Mon, 24 Apr 2023 23:45:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N/3xCJkhqLwuGQlsHM65YLR3Y9zbAiWYgPlLuraGxKDBJYxxmoOK+RxlIRQsYUOaIGJTWNtgPCLU/2tl09uy+9FIlxGDht5NWki+QaaP0OUHnigUj47BMBEE5Q2t73m5A+Ja0lqKfIa/3C6V7ulUuDMjiP3L4zryOLvfBs6+bwapQ074dyX4Q6Jj0/W0b6L5tYN4SpUwMSY3dZFI8r0DACz6ijZpnvpoyVSnl7aOl/CUaqziPNU0unjtFAcO+HPyqgzRAxZmbKtrrNFrcggsPfDNnoSrmFcTV43l8sqkPheNxcB9YBZvyDnQGIkozSVwVhXlKjnWBv8Ke9edN9I+eg== 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=U5Q4o6iRuuHtsFTifg8YsE0DIcTZU04y9/eZVr1Iebc=; b=AHBkApvxHdGDhx4n5PJocEifvxqraKBtXQDWFNdx5oHxjTi9i+kUb8GTfifweV55O8VdNck9x7gK9usaHjKosxjJEaGidAdzqT35zqs3TrS3qn2T217WHCm0nPriqwfmcpC+2XCN18fWUtO26ca5vq4KBRoYxiycinChIIFPCc+T5TDtCQ0kCka+INgEU55826KnyXS6HMYytul8YyRkMa1bdDbMNNDi90z7PBi7csMBn9EQ3+Deo/m7Q6z8icwhG741+ReTzI9GxuYX2BHS2GThyUHXOmBGOX0MI9Gtgm03N6Po54nPco25l9DG2kfnizrfghf9sPkTHTp+HLS1+A== 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 Received: from BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by MN0PR11MB6160.namprd11.prod.outlook.com (2603:10b6:208:3c8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.34; Tue, 25 Apr 2023 06:45:18 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::1eb1:2222:1823:8e7a]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::1eb1:2222:1823:8e7a%7]) with mapi id 15.20.6319.033; Tue, 25 Apr 2023 06:45:18 +0000 From: "duntan" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann , "Chen, Xiao X" Subject: Re: [edk2-devel] [PATCH 1/3] UefiCpuPkg: Update code to support enable ProcTrace only on BSP Thread-Topic: [edk2-devel] [PATCH 1/3] UefiCpuPkg: Update code to support enable ProcTrace only on BSP Thread-Index: AQHZdzv/KFYTNc/980Ge/l8Bz/+Ebq87j7BQ Date: Tue, 25 Apr 2023 06:45:18 +0000 Message-ID: References: <20230425054738.2937-1-dun.tan@intel.com> <20230425054738.2937-2-dun.tan@intel.com> <1759183F15FD97B2.10313@groups.io> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN9PR11MB5483:EE_|MN0PR11MB6160:EE_ x-ms-office365-filtering-correlation-id: 65a85d40-e075-4eb3-901c-08db4558a202 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jdSGp2a83QHg4pNpm/Lq0P/gf4saTuQEI7XxoovgT8X0pd1lBEguBpZyV3er3cd55M3uK/kHCZHgOOPHrsg4Xl/h+HZ41nR9c89Fm0ysGLx9GCyEHv67vHL8/r29maFByFGHMlMmGvhmyFHFY3RHUmXjLvyGvkAPjClpG/QS3z8PSBAAz+jdnNEn5AuZ4ZStev3auYjmWtJEjHvQpQIdl9141DNBuiV9AgoSuCwJXmdijXGj+tu2yN7g4KaaVtJEM4NMEIPZs4MM3KKsuQIFVHaFj88Ogv0btr5V82JaGTqtUx716LwxlK2ZvO+zyp4fytG3H8NbL0+jRy52qr67QIf5Q92yB1ORpt4pAMIY9r69dZeAXgx7djdjZYPemQUesHkam+vlwhq2L9zBLdzjS+1N5Mwgnx4g5ADvQyN0reKwL+ZptP1EGIHFDgQIkYofFlASOYLNKnAtLu/1gjyAw84rksy+/rjFmRb12PcXrwy6rA2GCLJhdOFtWE1s6U7Gk7nVG1Z7tKNXteHRc/LxDl2aaAnOrP+WOP0yBbZ6Cg5daMBgB94h8Jp9R4fwxTGWB5ebX/l6+zO+y63Cwbz5u9ZdHBHsuqAxiyFtYgLd4H7ERl+bzzrjWAasGZhDmnNqFv7mfD0qrswpouavJarXeQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR11MB5483.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(136003)(366004)(39860400002)(376002)(451199021)(71200400001)(66899021)(83380400001)(2906002)(55016003)(41300700001)(26005)(52536014)(66946007)(76116006)(66446008)(64756008)(38100700002)(15650500001)(66476007)(82960400001)(8676002)(8936002)(53546011)(86362001)(107886003)(6506007)(186003)(478600001)(110136005)(9686003)(38070700005)(33656002)(54906003)(66556008)(7696005)(966005)(122000001)(316002)(4326008)(5660300002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?m2XTcpLriXD96e3TuDGLJKmjAUx1al+PYzA8bi1TXt77RkEhETrPFWa+FZiI?= =?us-ascii?Q?OxArRpTNghm7NPBafrAMWCABAfJgRzQ1YWG4ayMJ6TomDO1xQn0aFrGoIASQ?= =?us-ascii?Q?Y/c2WPXGdD/M1HR+vBZmILRshCx81e77tNw5ap1W5WL5/VQdu0mnbcA2IAJu?= =?us-ascii?Q?DaMqt1/6MaNfVrkT3/HGxhOeNi0dYSe6c90tORQImRdaRe3ffFO6RwJZy3OK?= =?us-ascii?Q?/5qN2Vaeyi8X8V5PsQqVsKsJxHfwMjxApex8A1tmaU4gt1Q3UwMSQf4kLtct?= =?us-ascii?Q?xSktZR1SShao6h1NWpFaNme9QUlOG1Cunv3KxXa8Arg6fsgjLZ5A9LviYOGJ?= =?us-ascii?Q?q7ggcciqikTzY+jUT4dvEsHMUM9CDu5cbJjqYL2MxGs011bXmgv253XMPkwk?= =?us-ascii?Q?IKk8SKr3SiZvSYBOc7+TyUUiHITBZB7sdQ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80BBozLQbTSeCNBH/bLiuAykW7voEPZgz7zZjCxxAdxRz1g?= =?us-ascii?Q?F+E9iXZ1I1HDY5Ol7IYayrpSsyonrhNpie/a6/33oUdvERoYcU0ehvJxOT1/?= =?us-ascii?Q?3HCETZeHyMVSkidkwPGkjsSndl/azgL+sIomYPGB2jgX7woH8TyeelBxCp6Z?= =?us-ascii?Q?RIiE0pfO/Czy+c0uWttFY0D4RhTX6kS8AEQGvFUxOEA536eZe+sbMrKAmb/m?= =?us-ascii?Q?akTX7Kho0AZ4Hd4ppjs=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65a85d40-e075-4eb3-901c-08db4558a202 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Apr 2023 06:45:18.0233 (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: oQaEOYgFPzqFonChaTMO/g00fG9k2ugft2TCylNttnxHl/mm0jQsjyB4AhQo+iXboUwG6LU73Qm/HIExBjq15w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB6160 Return-Path: dun.tan@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 comments. I Will update the code based your comments for this pa= tch. Thanks, Dun -----Original Message----- From: Ni, Ray =20 Sent: Tuesday, April 25, 2023 2:06 PM To: devel@edk2.groups.io; Ni, Ray ; Tan, Dun Cc: Dong, Eric ; Kumar, Rahul R ; Gerd Hoffmann ; Chen, Xiao X Subject: RE: [edk2-devel] [PATCH 1/3] UefiCpuPkg: Update code to support en= able ProcTrace only on BSP By the way, I know that ProcTraceInitialize() runs on BSP so it's safe to a= ccess the PCD database. But to be consistent with the old logic, can you please cache the PCD value= in ProcTraceGetConfigData()? It has slight benefit that the PCD is only accessed once not multiple times= depending on cpu count. > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Ni, Ray > Sent: Tuesday, April 25, 2023 2:03 PM > To: Tan, Dun ; devel@edk2.groups.io > Cc: Dong, Eric ; Kumar, Rahul R=20 > ; Gerd Hoffmann ; Chen,=20 > Xiao X > Subject: Re: [edk2-devel] [PATCH 1/3] UefiCpuPkg: Update code to=20 > support enable ProcTrace only on BSP >=20 > > - gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle ## > > SOMETIMES_CONSUMES > > - gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset ## > > SOMETIMES_CONSUMES > > - gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceOutputScheme ## > > SOMETIMES_CONSUMES > > - gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceMemSize ## > > SOMETIMES_CONSUMES > > + gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle ## > > SOMETIMES_CONSUMES > > + gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset ## > > SOMETIMES_CONSUMES > > + gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceOutputScheme ## > > SOMETIMES_CONSUMES > > + gUefiCpuPkgTokenSpaceGuid.PcdCpuProcTraceMemSize ## > > SOMETIMES_CONSUMES > > + gUefiCpuPkgTokenSpaceGuid.PcdEnableProcessorTraceOnBspOnly ## >=20 > 1. PcdCpuProcTraceBspOnly? This is to use the same prefix as other=20 > ProcTrace PCDs. >=20 >=20 > > > > + IsBsp =3D (CpuInfo->ProcessorInfo.StatusFlag & BIT0) ? TRU= E : FALSE; > 2. Can you use PROCESSOR_AS_BSP_BIT instead of BIT0? >=20 >=20 > > + EnableOnBspOnly =3D (PcdGetBool (PcdEnableProcessorTraceOnBspOnly)) = ? > > TRUE : FALSE; >=20 > 3. why not directly use PcdGetBool (PcdEnableProcessorTraceOnBspOnly)=20 > in below if-check? >=20 > > + > > + if (EnableOnBspOnly && (IsBsp =3D=3D FALSE)) { >=20 > 4. Change "IsBsp =3D=3D FALSE" to "!IsBsp". >=20 >=20 >=20 >=20 > > + if (EnableOnBspOnly) { > > AlignedAddress =3D (UINTN)AllocateAlignedReservedPages (Pages,= =20 > > Alignment); > > if (AlignedAddress =3D=3D 0) { > > - DEBUG ((DEBUG_ERROR, "ProcTrace: Out of mem, allocated only > for %d > > threads\n", ProcTraceData->AllocatedThreads)); > > - if (Index =3D=3D 0) { > > - // > > - // Could not allocate for BSP even > > - // > > - FreePool ((VOID *)ThreadMemRegionTable); > > - ThreadMemRegionTable =3D NULL; > > - return RETURN_OUT_OF_RESOURCES; > > + // > > + // Could not allocate for BSP even > > + // > > + DEBUG ((DEBUG_ERROR, "ProcTrace: Out of mem, failed to=20 > > + allocate > > buffer for BSP\n")); > > + return RETURN_OUT_OF_RESOURCES; > > + } > > + > > + DEBUG ((DEBUG_INFO, "ProcTrace: Allocated PT mem for BSP > only.\n")); >=20 > 5. AlignedAddress is the proc trace buffer for BSP. But it seems the=20 > value is not used in > later MSR_IA32_RTIT_OUTPUT_BASE programming. > Similar comments to the Topa code path. >=20 >=20 >=20 >=20 >=20