Bug 2707 - Add MWAIT Cx support for Zhaoxin CPUs
Summary: Add MWAIT Cx support for Zhaoxin CPUs
Status: RESOLVED FIXED
Alias: None
Product: ANCK 5.10 Dev
Classification: ANCK
Component: general/others (show other bugs) general/others
Version: unspecified
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: maqiao
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-02 18:32 UTC by LeoLiu-oc
Modified: 2023-02-28 19:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LeoLiu-oc zhaoxin_group 2022-11-02 18:32:45 UTC
Description of problem:
When the processor is idle,low-power idle states (C-states) can be used
to save power. For Zhaoxin processors,there are two methods to enter idle
states. One is HLT instruction and legacy method of I/O reads from the
ACPI-defined register (known as P_LVLx),the other one is MWAIT
instruction with idle states hints.

Default for legacy operating system,HLT and P_LVLx I/O reads are used for
Zhaoxin Processors to enter idle states, but we have checked on some
Zhaoxin platform that MWAIT instruction is more efficient than P_LVLx I/O
reads and HLT, so we add MWAIT Cx support for Zhaoxin Processors.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
Case1: 在BIOS里设置MWAIT support为Enable;Linux kernel使用MWAIT指令进入到Core Cx;
1)dmesg 查看kernel boot log里,应该能看到“Monitor-Mwait will be used to enter C1/C2/Cx state” 
2)在Linux OS下dump Cstate信息如下
# cat /sys/devices/system/cpu/cpu0/cpuidle/state*/desc
CPUIDLE CORE POLL IDLE
ACPI FFH MWAIT 0x0
ACPI FFH MWAIT 0x10
ACPI FFH MWAIT 0x20
ACPI FFH MWAIT 0x30
	3)确认CPU能够进入到package Cx;package C2/C3/C4 residency(即0x870-0x87B)有变化;
		hexdump -C -s 0x870 -n 16 /dev/port	

Case2:kernel boot时,在grub中设置idle=nomwait,能够切换到Legacy P_LVLx IOR Cx 方式
1)	dmesg 查看kernel boot log里,不会再看到“Monitor-Mwait will be used to enter C1/C2/Cx state” 
2)	在Linux OS下dump Cstate信息如下
# cat /sys/devices/system/cpu/cpu0/cpuidle/state*/desc
CPUIDLE CORE POLL IDLE
ACPI HLT
ACPI IOPORT 0x814
ACPI IOPORT 0x815
ACPI IOPORT 0x816
3)	确认CPU能够进入到package Cx;
package C2/C3/C4 residency(即0x870-0x87B)有变化;
hexdump -C -s 0x870 -n 16 /dev/port	


Actual results:


Expected results:
不管使用P_LVLx I/O reads 还是MWAIT instruction,core都能进入指定的idle states,整个CPU package能够进入相应的package c-states。

Additional info:
Comment 1 maqiao alibaba_cloud_group 2023-02-28 19:34:22 UTC
merged: https://gitee.com/anolis/cloud-kernel/pulls/842