From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.656.1577087317051888227 for ; Sun, 22 Dec 2019 23:48:37 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: eric.dong@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2019 23:48:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,346,1571727600"; d="scan'208";a="222969857" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 22 Dec 2019 23:48:36 -0800 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 22 Dec 2019 23:48:36 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 22 Dec 2019 23:48:35 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.109]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.222]) with mapi id 14.03.0439.000; Mon, 23 Dec 2019 15:48:34 +0800 From: "Dong, Eric" To: "Ni, Ray" , "devel@edk2.groups.io" CC: Laszlo Ersek Subject: Re: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove dependence between APs Thread-Topic: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove dependence between APs Thread-Index: AQHVuVz0x6Oeds+sqEeTy9UIgdGb66fHUE1ggAAG/9A= Date: Mon, 23 Dec 2019 07:48:33 +0000 Message-ID: References: <20191223064806.682-1-eric.dong@intel.com> <20191223064806.682-2-eric.dong@intel.com> <734D49CCEBEEF84792F5B80ED585239D5C3A8DBD@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C3A8DBD@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: eric.dong@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, > -----Original Message----- > From: Ni, Ray > Sent: Monday, December 23, 2019 3:38 PM > To: devel@edk2.groups.io; Dong, Eric > Cc: Laszlo Ersek > Subject: RE: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: > Remove dependence between APs >=20 > > > > + WaitForSemaphore (&Token->RunningApCount); > > + > > + if (Token->RunningApCount =3D=3D 0) { > > + ReleaseSpinLock (Token->SpinLock); > > } >=20 > 1. if (InterlockedDecrement (&Token->RunningApCount) =3D=3D 0) { > ReleaseSpinLock (Token->SpinLock); > } >=20 > We should avoid checking RunningApCount directly because it's possible > that AP#1 decrease the Count to 1 and before AP#1 checks the value agains= t > 0 > the Count is decreased by AP#2 to 0. So that causes AP#1 and AP#2 call > ReleaseSpinLock() on the same SpinLock. >=20 [[Eric]] good comments, will update it in next version. > > > > + // Decrease the count to mark this AP as finished. >=20 > 2. BSP is also handled here. So this comment is mis-leading. [[Eric]] will enhance the comments in next version. >=20 > > > > + // > > > > + if (Token !=3D NULL) { > > + WaitForSemaphore (&ProcToken->RunningApCount); >=20 > 3. The code is written correctly but improperly IMO. > Token is checked but ProcToken is deferenced. > I suggest you check ProcToken directly. [[Eric]] The other place in this function all check the Token status then u= pdate code.=20 So this code consistent with other place. I will keep this code to keep co= nsistent. Thanks, Eric