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 6048A941372 for ; Thu, 1 Feb 2024 11:20:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=0EYsfW0yMj5uLGJRDScHTRr71GF+9ejTe7AhOeAIJ10=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20140610; t=1706786411; v=1; b=tLb4kFCqdgmQzFVciegLj+JxeyOmTB99nKheEzXnrFEuSgfeiVYipO6zW1YluiW3T9Cz3nlu G3v9Cq4cRAKOZoutMSXL+9pSnSJF3aa4xAcTgDqo1R+sD6hLFMzuabOnEqUi4fjMNRgKaIh/5R8 JHrCGVT8sjnXM356TEEhXYCY= X-Received: by 127.0.0.2 with SMTP id yhF8YY7687511x4hovXyYxPJ; Thu, 01 Feb 2024 03:20:11 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.13072.1706786406013912604 for ; Thu, 01 Feb 2024 03:20:10 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="407589411" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="407589411" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 03:20:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="912097615" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="912097615" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by orsmga004.jf.intel.com with ESMTP; 01 Feb 2024 03:20:08 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Eric Dong , Zeng Star , Gerd Hoffmann , Rahul Kumar Subject: [edk2-devel] [PATCH v1 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg Date: Thu, 1 Feb 2024 19:20:01 +0800 Message-Id: <20240201112001.14416-3-jiaxin.wu@intel.com> In-Reply-To: <20240201112001.14416-1-jiaxin.wu@intel.com> References: <20240201112001.14416-1-jiaxin.wu@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,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: QetNw9b2p8z4p9kk7E4PSOgSx7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=tLb4kFCq; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io This patch is to check BspIndex first before lock cmpxchg operation. It's the optimization to lower the resource contention caused by the atomic compare exchange operation, so as to improve the SMI performance for BSP election. Cc: Ray Ni Cc: Laszlo Ersek Cc: Eric Dong Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c index e988ce0542..479024d294 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -1652,15 +1652,17 @@ SmiRendezvous ( } } else { // // Platform hook fails to determine, use default BSP election method // - InterlockedCompareExchange32 ( - (UINT32 *)&mSmmMpSyncData->BspIndex, - (UINT32)-1, - (UINT32)CpuIndex - ); + if (mSmmMpSyncData->BspIndex == (UINT32)-1) { + InterlockedCompareExchange32 ( + (UINT32 *)&mSmmMpSyncData->BspIndex, + (UINT32)-1, + (UINT32)CpuIndex + ); + } } } } // -- 2.16.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114944): https://edk2.groups.io/g/devel/message/114944 Mute This Topic: https://groups.io/mt/104094808/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-