Skip to content

Commit

Permalink
Add one offline cpu pkg cstate6 case check
Browse files Browse the repository at this point in the history
Signed-off-by: qwang59 <[email protected]>
  • Loading branch information
qwang59 committed Jun 21, 2024
1 parent ddc4901 commit ffd5084
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
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

0 comments on commit ffd5084

Please sign in to comment.