Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add one offline cpu pkg cstate6 case check #283

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion BM/cstate/powermgr_cstate_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ current_cpuidle_driver=$(cat "$CPU_IDLE_SYSFS_PATH"/current_driver)

# Turbostat tool is required to run core cstate cases
if which turbostat 1>/dev/null 2>&1; then
turbostat sleep 1 1>/dev/null || block_test "Failed to run turbostat tool,
turbostat -q sleep 1 1>/dev/null || block_test "Failed to run turbostat tool,
please check turbostat tool error message."
else
block_test "Turbostat tool is required to run CSTATE cases,
Expand All @@ -35,6 +35,13 @@ else
please get it from latest upstream kernel-tools."
fi

# msr-tools is required to run this cstate pc case
if which rdmsr 1>/dev/null 2>&1; then
test_print_trc "rdmsr tool is available."
else
block_test "msr-tools is required to run CSTATE cases."
fi

# Function to verify if Intel_idle driver refer to BIOS _CST table
test_cstate_table_name() {
local cstate_name=""
Expand Down Expand Up @@ -572,6 +579,63 @@ runtime_pc6_residency() {
done
}

# Function to check if the deepest PC6 counter is available after CPU offline and online
offline_cpu_pc() {
local pc=$1
local pc_ori=""
local pc_af=""
local cpus_num=""

cpus_num=$(lscpu | grep "On-line CPU(s) list" | awk -F "-" '{print $NF}' 2>&1)

test_print_trc "Reading the deepest Package cstate counter before CPU offline"
pc_ori=$(rdmsr $pc 2>&1)
dec_pc_ori=$((16#$pc_ori))
if [ -n $dec_pc_ori ]; then
test_print_trc "The deepest Package cstate counter before CPU offline is available: $dec_pc_ori"
else
die "The deepest Package cstate counter before CPU offline is not available: $dec_pc_ori"
fi

# Offline all the CPUs except CPU0
for ((i = 1; i <= cpus_num; i++)); do
do_cmd "echo 0 > /sys/devices/system/cpu/cpu$i/online"
done

# Read the deepest Package cstate counter residency after CPU offline
test_print_trc "Reading the deepest Package cstate counter after CPU offline"
pc_res_bf=$(rdmsr $pc 2>&1)
dec_pc_res_bf=$((16#$pc_res_bf))
test_print_trc "The deepest Package cstate counter after CPU offline: $dec_pc_res_bf"
sleep 20
pc_res_af=$(rdmsr $pc 2>&1)
dec_pc_res_af=$((16#$pc_res_af))
test_print_trc "The deepest Package cstate counter after CPU offline and idle: $dec_pc_res_af"

# Online all the CPUs
for ((i = 1; i <= $cpus_num; i++)); do
do_cmd "echo 1 > /sys/devices/system/cpu/cpu$i/online"
done

# Check if the PC6 counter is updated after CPU offline, if offline CPUs are stucked in C1
# PC6 will not be available
if [ -n $dec_pc_res_bf ] && [ -n $dec_pc_res_af ] && (($dec_pc_res_af > $dec_pc_res_bf)); then
test_print_trc "The deepest Package cstate counter is updated after CPU offline"
else
die "The deepest Package cstate counter after CPU offline is not updated."
fi

# Recheck the PC6 counter after CPUs online
test_print_trc "Reading the deepest Package cstate counter after CPU online"
pc_af=$(rdmsr $pc 2>&1)
dec_pc_af=$((16#$pc_af))
if [ -n $pc_af ] && (($dec_pc_af > $dec_pc_ori)); then
test_print_trc "The deepest Package cstate counter after CPU online is updated: $dec_pc_af"
else
die "The deepest Package cstate counter after CPU online is not updated: $dec_pc_af"
fi
}

# Function to do CPU offline and online short stress
cpu_off_on_stress() {
local cycle=$1
Expand Down Expand Up @@ -677,6 +741,9 @@ core_cstate_test() {
verify_server_pc6_residency)
runtime_pc6_residency
;;
verify_offline_cpu_deepest_pc)
offline_cpu_pc 0x3f9
;;
verify_cpu_offline_online_stress)
cpu_off_on_stress 5
;;
Expand Down
1 change: 1 addition & 0 deletions BM/cstate/tests-server
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ powermgr_cstate_tests.sh -t verify_server_perf_module_cstat_update
powermgr_cstate_tests.sh -t verify_server_pc2_entry
powermgr_cstate_tests.sh -t verify_server_pc6_entry
powermgr_cstate_tests.sh -t verify_server_pc6_residency
powermgr_cstate_tests.sh -t verify_offline_cpu_deepest_pc
powermgr_cstate_tests.sh -t verify_cpu_offline_online_stress
Loading