From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.674.1686331672055011188 for ; Fri, 09 Jun 2023 10:27:52 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Bv1tnOtU; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: nolan.hergert@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686331672; x=1717867672; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=r3+TUpZlYiLW3hCjBh7tGkid17iiCBoAfk0VL8ObyM8=; b=Bv1tnOtUZb9MzP6gonsatGqD4jVG27z+tpJGugcpBk6QcK9JiZOcRRg3 O+i7MFOMgM942Obujf0Ez1CGPhMZgq/ihxJ4wrPM5lfWS5EosdXTfoiBr gy/V8RYMz0GNX6wkav+YC39occKax8B2qENVt7hnWQVHPyH3FlgrTfmTa xNdOCvlEh+MRG9UDe745yrSV9NA/nGfk3fhwpqMDZEJMQQYu51x3ZheUr NrFZw6QMMwFk8rUP5ps56K8igUt+nzwOdEWLEnhFNwUg+eEentJixLYB/ puQPZvrXcS7+x7aeYQilEhbDuNztBjyVlmqb6aMszw+EYXYyuo1+2UeWK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="360133343" X-IronPort-AV: E=Sophos;i="6.00,230,1681196400"; d="scan'208";a="360133343" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 10:27:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10736"; a="1040549012" X-IronPort-AV: E=Sophos;i="6.00,230,1681196400"; d="scan'208";a="1040549012" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga005.fm.intel.com with ESMTP; 09 Jun 2023 10:27:50 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.23; Fri, 9 Jun 2023 10:27:50 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Fri, 9 Jun 2023 10:27:50 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.43) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Fri, 9 Jun 2023 10:27:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X8rIcrZc09kdnJLgTk42ORWX7MxF0ooAJEK2hj1Rt0/uh8Z5G8iyHb8z/PLs+zxctTn1Rcv4JxppfemrgBOZ/54hpC1SJymXrmeh3A+5r5A3lG6CHw1Ts/35YEPmsUJzIK43PZUyxWPcPWNWfHWWssCSkq1nh+QGP8ZZSNAXB7Fv1W0elT5LjsZgDcaj9iuhIVJD0bIb3F4TSz6LLLKggga4SDBN2UnIVjImUzCeSSIjZgkQ6K0TwAKJZS28ybvHLPOvT6uZlxQDtqhlkIK/b2vZAk3dRV/6eRE+Ar4Mcfd4vMCSvbIi2qTxs1WFPVEPh9Jr2rZCUnYBut7cpjxWWw== 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=r3+TUpZlYiLW3hCjBh7tGkid17iiCBoAfk0VL8ObyM8=; b=NVjzdNGNtMdO/XrrcT3UJ3BWpfg8rInvHthHk8srFRUmJYsCyhvsu0JHwYtKoZnRQOlTPK1uzaS2oxLmYKO+Nf1c1RIsH+u01ZsQ78Gt5TWCXSdcHoeXxhviRxqpKqhlw5LuIz1NWtUzK3ewnSjUEWDZUZiv4c/MoIXMvaMcj5N5PixyXMeiYF2yxPDoguoUA7cme07rESBaemdd2pQugjihnXBgwLHS1fDKlvVEbkXH8buBWF+ScItS98vIzh5Go2m4WP7Ozw8fagfXpoyotg48vChuuIFrQij7ies6RdBSzXR31b50+3TT5yiydlYpO/+WFAiw80cE9vJ3/OVrPg== 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 SN7PR11MB6728.namprd11.prod.outlook.com (2603:10b6:806:264::9) by BN9PR11MB5372.namprd11.prod.outlook.com (2603:10b6:408:105::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 17:27:49 +0000 Received: from SN7PR11MB6728.namprd11.prod.outlook.com ([fe80::7520:7fe6:19d0:9279]) by SN7PR11MB6728.namprd11.prod.outlook.com ([fe80::7520:7fe6:19d0:9279%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:27:49 +0000 From: "Nolan Hergert" To: "devel@edk2.groups.io" , "Hergert, Nolan" CC: "Bi, Dandan" , "Gao, Liming" Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Cache device path during LoadImage calls Thread-Topic: [edk2-devel] [PATCH 1/1] MdeModulePkg: Cache device path during LoadImage calls Thread-Index: AQHZjnVdRre+UUf/Tk2oF6PzqfbFz6+C0bOD Date: Fri, 9 Jun 2023 17:27:48 +0000 Message-ID: References: <17622AC93CEFC20B.29947@groups.io> In-Reply-To: <17622AC93CEFC20B.29947@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: 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: SN7PR11MB6728:EE_|BN9PR11MB5372:EE_ x-ms-office365-filtering-correlation-id: 9d93c375-a9ad-4546-77db-08db690ed8be x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: z0OCbIqd1/NAu5z6w7J1zAAFO5G+KIA7irqdgIEXhEW960RfHIbbjfNW8lK1pvCq9yUBp7nhGPItpssirwyvW2t4iBtGNvuid/Arp3i+OUUaa6hZLqTjxGgyf2QVZu29c+xnuzubMtLtFYyTc8JdDvjMBTCqG2yDQ1lblNwH7LJ4lY7jjTtPNj2UTNpWGvIFSXgh7g1kfu76shXsCDd/gYdTdrHsl9wL0ds2FLsdEAs5mqgIjpPbzgjuV9CsWm3pvnag1KSsoFZs0SAwvfidPz7KQ94Li/+CPc61OdLvcOPlYjbn6LwKRVaSXUeJqpl22zFII35O2KQjYsfqgJQAJJ2AQjpwCKtOipw42CFtKf3CluyHWct0C7MYSf/MssQ1RTSxBcGR0HgJrmhWBaKnLKDpdFCKzvSpmANBq7xbbfs2JNc4y1PpwOeXZ3Uz0qv4BBt9YhRinA67yrkL1zeC1QSfVpmgrCKCq5R35PnM2QtGUI64aaLV+qUe4Ba7784106jpvx5tDRDKhjnvjMnuV9AEXbjT+McDTeMC5QWpAYHl2q/eHbZEo0Q1CUImXHbk+CCeZ2cuGMmdx7wkYr45dxjRoQzDl2Bi5/r/FExNNxsn+Dk9vrFojhkr7ED4aFu6vYUZixqUm6Wc1ojLiQjIgw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN7PR11MB6728.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(376002)(366004)(136003)(346002)(396003)(451199021)(76116006)(53546011)(26005)(66446008)(9686003)(6506007)(64756008)(83380400001)(66946007)(122000001)(66476007)(4326008)(66556008)(966005)(7696005)(186003)(316002)(478600001)(33656002)(71200400001)(66899021)(110136005)(54906003)(38070700005)(2906002)(5660300002)(8676002)(8936002)(82960400001)(55016003)(52536014)(86362001)(41300700001)(38100700002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?jdI+eRzfA9WELWFaEI6BfxEr9DSr2u0Tt0sSmFNXVeh3OslzalqvUtNp+8?= =?iso-8859-1?Q?ekgA9gIVrStva4nml8/JHyJMFu4a+6wHauw4PlCodqi0yW37WNcr3Tugy2?= =?iso-8859-1?Q?jgk5vKXVyJbcwl+PSGxpdVsq5PfdC7jABjP0+Ioavd2n2lvBW4S0OBsr3n?= =?iso-8859-1?Q?0O4Dcrtpfdo7mT8vBhc7HqZ8V7PLYEwnFRnsEbcanbP8yrSiryGISndIuu?= =?iso-8859-1?Q?yrgrPdIhCYPoFrxuWnHSzbA1cr4B8FZTf9Jpz5x5wdszDgUqhlxcVoETz+?= =?iso-8859-1?Q?m+xhY/h7yo2JkC6JfnxS7Q6QzLyoXLP406Y4wCBuNOWFNseRaGDSZKfsHF?= =?iso-8859-1?Q?WpW0j+mJjDHTrxxhFi6O8u0NetLzWcu6Fo0zsWheJMrLtSxo6WOx/Nxb4l?= =?iso-8859-1?Q?m/NznnqzglOdFV3GiLS5ZgBeQ411G8sO/qy2bIsQ+5j1l/A9M352OKsQ35?= =?iso-8859-1?Q?WH5xszSxU3ay+JWoE+tBg1YFXJiybMCYTErt2+cbNDzj4rBQAhIZQjL//Z?= =?iso-8859-1?Q?MB7XjTFm4gQK62DHjYWaTtw3GNj6w5FvWk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gV/CdfNxB9hiUsMOrj7I1hIrKlarivZa7x4q30Ozv2fhllF?= =?iso-8859-1?Q?oJ2R1nGbZjNBcAqqfFdvjfVHZCv3UDLoNQm4rLhk7N12GGIZHth435f3yf?= =?iso-8859-1?Q?gKscYOS2CQqtoju62nBQhbl3+3KV5s0W3cdaBITeLE6hxSI0WKUNkEFlAE?= =?iso-8859-1?Q?xmuTaDw8Fspb5zlVyOtAIxAVD49jQ0Ke21?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN7PR11MB6728.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d93c375-a9ad-4546-77db-08db690ed8be X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jun 2023 17:27:48.9607 (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: hCoAcx2rFURVvjtdw5Orc0If1/hWOn+wPMY98/CVL0xle9EFqEq3eha/DpIrFiGol/O4953SCwlhBEEVFP+TwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5372 Return-Path: nolan.hergert@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Any feedback? ________________________________________ From: devel@edk2.groups.io on behalf of Nolan Herger= t Sent: Wednesday, May 24, 2023 12:07 PM To: devel@edk2.groups.io Cc: Bi, Dandan ; Gao, Liming Subject: [edk2-devel] [PATCH 1/1] MdeModulePkg: Cache device path during Lo= adImage calls=20 =A0 During LoadImage, there 6-7 of the same call to CoreLocateDevicePath and can be cached during a particular call to LoadImage. For implementations with significant numbers of calls to LoadImage (>250), this change will improve the boot time by >10ms. Cc: Dandan Bi Cc: Liming Gao Signed-off-by: Nolan Hergert --- =A0MdeModulePkg/Core/Dxe/Hand/Locate.c | 21 ++++++++++++++++----- =A0MdeModulePkg/Core/Dxe/Image/Image.c | 15 +++++++++++++-- =A02 files changed, 29 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Hand/Locate.c b/MdeModulePkg/Core/Dxe/Ha= nd/Locate.c index a29010a54565..52b7b7a7cd8c 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Locate.c +++ b/MdeModulePkg/Core/Dxe/Hand/Locate.c @@ -14,6 +14,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =A0// =A0UINTN=A0 mEfiLocateHandleRequest =3D 0; =A0 +extern EFI_DEVICE_PATH_PROTOCOL=A0 *gFilePathCache; +extern EFI_HANDLE=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 gDeviceHand= leCache; +extern EFI_DEVICE_PATH_PROTOCOL=A0 *gOutgoingDevicePathCache; + =A0// =A0// Internal prototypes =A0// @@ -467,10 +471,21 @@ CoreLocateDevicePath ( =A0=A0=A0=A0 return EFI_INVALID_PARAMETER; =A0=A0 } =A0 -=A0 if ((DevicePath =3D=3D NULL) || (*DevicePath =3D=3D NULL)) { +=A0 if ((DevicePath =3D=3D NULL) || (*DevicePath =3D=3D NULL) || (Device = =3D=3D NULL)) { =A0=A0=A0=A0 return EFI_INVALID_PARAMETER; =A0=A0 } =A0 +=A0 if (gFilePathCache !=3D NULL) { +=A0=A0=A0 Size=A0=A0=A0=A0=A0=A0 =3D GetDevicePathSize (gFilePathCache) - = sizeof (EFI_DEVICE_PATH_PROTOCOL); +=A0=A0=A0 SourceSize =3D GetDevicePathSize (*DevicePath) - sizeof (EFI_DEV= ICE_PATH_PROTOCOL); + +=A0=A0=A0 if ((Size =3D=3D SourceSize) && (CompareMem (gFilePathCache, *De= vicePath, (UINTN)Size) =3D=3D 0)) { +=A0=A0=A0=A0=A0 *Device=A0=A0=A0=A0 =3D gDeviceHandleCache; +=A0=A0=A0=A0=A0 *DevicePath =3D gOutgoingDevicePathCache; +=A0=A0=A0=A0=A0 return EFI_SUCCESS; +=A0=A0=A0 } +=A0 } + =A0=A0 Handles=A0=A0=A0=A0=A0=A0 =3D NULL; =A0=A0 BestDevice=A0=A0=A0 =3D NULL; =A0=A0 SourcePath=A0=A0=A0 =3D *DevicePath; @@ -541,10 +556,6 @@ CoreLocateDevicePath ( =A0=A0=A0=A0 return EFI_NOT_FOUND; =A0=A0 } =A0 -=A0 if (Device =3D=3D NULL) { -=A0=A0=A0 return EFI_INVALID_PARAMETER; -=A0 } - =A0=A0 *Device =3D BestDevice; =A0 =A0=A0 // diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index 9dbfb2a1fad2..e76f788a4d89 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -12,7 +12,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =A0// =A0// Module Globals =A0// -LOADED_IMAGE_PRIVATE_DATA=A0 *mCurrentImage =3D NULL; +LOADED_IMAGE_PRIVATE_DATA=A0 *mCurrentImage=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 =3D NULL; +EFI_DEVICE_PATH_PROTOCOL=A0=A0 *gFilePathCache=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 =3D NULL; +EFI_DEVICE_PATH_PROTOCOL=A0=A0 *gOutgoingDevicePathCache =3D NULL; +EFI_HANDLE=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 gDeviceHandleCa= che=A0=A0=A0=A0=A0=A0=A0 =3D NULL; =A0 =A0typedef struct { =A0=A0 LIST_ENTRY=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Link; @@ -1219,7 +1222,10 @@ CoreLoadImageCommon ( =A0=A0=A0=A0 Node=A0=A0 =3D NULL; =A0=A0=A0=A0 Status =3D CoreLocateDevicePath (&gEfiFirmwareVolume2ProtocolG= uid, &HandleFilePath, &DeviceHandle); =A0=A0=A0=A0 if (!EFI_ERROR (Status)) { -=A0=A0=A0=A0=A0 ImageIsFromFv =3D TRUE; +=A0=A0=A0=A0=A0 ImageIsFromFv=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D TRUE; +=A0=A0=A0=A0=A0 gFilePathCache=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D FilePath; +=A0=A0=A0=A0=A0 gOutgoingDevicePathCache =3D HandleFilePath; +=A0=A0=A0=A0=A0 gDeviceHandleCache=A0=A0=A0=A0=A0=A0 =3D DeviceHandle; =A0=A0=A0=A0 } else { =A0=A0=A0=A0=A0=A0 HandleFilePath =3D FilePath; =A0=A0=A0=A0=A0=A0 Status=A0=A0=A0=A0=A0=A0=A0=A0 =3D CoreLocateDevicePath = (&gEfiSimpleFileSystemProtocolGuid, &HandleFilePath, &DeviceHandle); @@ -1497,6 +1503,11 @@ Done: =A0=A0=A0=A0 Image->LoadImageStatus =3D Status; =A0=A0 } =A0 +=A0 // Clear cache +=A0 gFilePathCache=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D NULL; +=A0 gOutgoingDevicePathCache =3D NULL; +=A0 gDeviceHandleCache=A0=A0=A0=A0=A0=A0 =3D NULL; + =A0=A0 return Status; =A0} =A0 --=20 2.38.1.windows.1