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.web09.7085.1616377206206575927 for ; Sun, 21 Mar 2021 18:40:06 -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 ; Mon, 22 Mar 2021 09:40:02 +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> In-Reply-To: <20210319181421.2791425-1-ankur.a.arora@oracle.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUkVTRU5EIHYyXSBNZGVQa2c6IHVzZSBDcHVQYXVzZSgpIGluIENwdURlYWRMb29wKCk=?= Date: Mon, 22 Mar 2021 09:40:02 +0800 Message-ID: <002401d71ebc$4767d130$d6377390$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQI4dxI3tYlfk8YA2TZzDFRYMeBiUanMij5g Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Reviewed-by: Liming Gao 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() >=20 > CpuPause() might allow the CPU to go into a lower power state > state while we spin. >=20 > On X86, CpuPause() executes a PAUSE instruction which the Intel > and AMD specs describe as follows: >=20 > 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 = the > 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 = consumption." >=20 > 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." >=20 > On RISC-V and ARM64, CpuPause() executes a NOP, which is no worse than > the tight loop we have. >=20 > 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(-) >=20 > 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; >=20 > - for (Index =3D 0; Index =3D=3D 0;); > + for (Index =3D 0; Index =3D=3D 0;) { > + CpuPause(); > + } > } > -- > 2.9.3