From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.3122.1616642140954101546 for ; Wed, 24 Mar 2021 20:15:41 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Thu, 25 Mar 2021 11:15:38 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , , "'Ankur Arora'" Cc: "'Michael D Kinney'" , "'Laszlo Ersek'" References: <20210319181421.2791425-1-ankur.a.arora@oracle.com> <166E86818BEFA632.26767@groups.io> In-Reply-To: <166E86818BEFA632.26767@groups.io> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0g5Zue5aSNOiBbUkVTRU5EIHYyXSBNZGVQa2c6IHVzZSBDcHVQYXVzZSgpIGluIENwdURlYWRMb29wKCk=?= Date: Thu, 25 Mar 2021 11:15:39 +0800 Message-ID: <00ce01d72125$21a8dbe0$64fa93a0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQI4dxI3tYlfk8YA2TZzDFRYMeBiUQFgQ5cuqcZZ8AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Create PR https://github.com/tianocore/edk2/pull/1515 Thanks Liming > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io = =E4=BB=A3=E8=A1=A8 gaoliming > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B43=E6=9C=8822=E6=97=A5= 9:40 > =E6=94=B6=E4=BB=B6=E4=BA=BA: 'Ankur Arora' ; d= evel@edk2.groups.io > =E6=8A=84=E9=80=81: 'Michael D Kinney' ; 'La= szlo Ersek' > > =E4=B8=BB=E9=A2=98: [edk2-devel] =E5=9B=9E=E5=A4=8D: [RESEND v2] MdePkg:= use CpuPause() in > CpuDeadLoop() >=20 > Reviewed-by: Liming Gao >=20 > Thanks > Liming > > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > > =E5=8F=91=E4=BB=B6=E4=BA=BA: Ankur Arora > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2021=E5=B9=B43=E6=9C=8820=E6=97= =A5 2:14 > > =E6=94=B6=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io > > =E6=8A=84=E9=80=81: Ankur Arora ; Liming Gao > > ; Michael D Kinney > > ; Laszlo Ersek > > =E4=B8=BB=E9=A2=98: [RESEND v2] MdePkg: use CpuPause() in CpuDeadLoop(= ) > > > > CpuPause() might allow the CPU to go into a lower power state > > state while we spin. > > > > On X86, CpuPause() executes a PAUSE instruction which the Intel > > and AMD specs describe as follows: > > > > Intel: > > "PAUSE: An additional function of the PAUSE instruction is to reduce > > the power consumed by a processor while executing a spin loop. A > > processor can execute a spin-wait loop extremely quickly, causing th= e > > processor to consume a lot of power while it waits for the resource = it > > is spinning on to become available. Inserting a pause instruction in= a > > spin-wait loop greatly reduces the processor=E2=80=99s power consump= tion." > > > > AMD: > > "PAUSE: Improves the performance of spin loops, by providing a hint = to > > the processor that the current code is in a spin loop. The processor > > may use this to optimize power consumption while in the spin loop. > > Architecturally, this instruction behaves like a NOP instruction." > > > > On RISC-V and ARM64, CpuPause() executes a NOP, which is no worse than > > the tight loop we have. > > > > Cc: Liming Gao > > Signed-off-by: Ankur Arora > > Reviewed-by: Michael D Kinney > > Reviewed-by: Laszlo Ersek > > --- > > MdePkg/Library/BaseLib/CpuDeadLoop.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/MdePkg/Library/BaseLib/CpuDeadLoop.c > > b/MdePkg/Library/BaseLib/CpuDeadLoop.c > > index 9e110cacbc96..3cd304351a65 100644 > > --- a/MdePkg/Library/BaseLib/CpuDeadLoop.c > > +++ b/MdePkg/Library/BaseLib/CpuDeadLoop.c > > @@ -28,5 +28,7 @@ CpuDeadLoop ( > > { > > volatile UINTN Index; > > > > - for (Index =3D 0; Index =3D=3D 0;); > > + for (Index =3D 0; Index =3D=3D 0;) { > > + CpuPause(); > > + } > > } > > -- > > 2.9.3 >=20 >=20 >=20 >=20 >=20 >=20 >=20