Skip to content

Conversation

seankingyang
Copy link
Contributor

Description

  • Add the trigger and capture CPU cpuidle state
  • For ARM platform also have the CPU idle feature, and this script is similar fwts cstates with more useful info.
  • This script also can be run on X86 platform.

Resolved issues

Miss coverage of the CPU idle.

Documentation

Tests

ARM w/o CPUidle driver (this is a true issue):

root@ubuntu:/home/ubuntu/CPU# ./cpu_idle_state.py 
[INFO] Starting CPU idle state test
[INFO] This test checks if all processors have the same number of idle states and if idle state transitions happen during alternating load patterns
[INFO] Found 2 CPUs in system
[ERROR] ERROR: No CPUs with cpuidle support found
root@ubuntu:/home/ubuntu/CPU# echo $?
1

ARM w/ CPUidle driver (some state can't entry during the trigger idle state testing but the usage of state w/ existing usage so mark as pass )

root@mtk-genio:/home/ubuntu/CPU# ./cpu_idle_state.py 
[INFO] Starting CPU idle state test
[INFO] This test checks if all processors have the same number of idle states and if idle state transitions happen during alternating load patterns
[INFO] Found 8 CPUs in system
[INFO] CPU 0: Found 3 idle states
[INFO] CPU 1: Found 3 idle states
[INFO] CPU 2: Found 3 idle states
[INFO] CPU 3: Found 3 idle states
[INFO] CPU 4: Found 3 idle states
[INFO] CPU 5: Found 3 idle states
[INFO] CPU 6: Found 3 idle states
[INFO] CPU 7: Found 3 idle states
[INFO] Testing 8 CPUs with cpuidle support
[INFO] Testing CPU 0 (1/8)
[INFO] CPU 0: State 2 (clusteroff_l) was used
[INFO] CPU 0: State 0 (WFI) was used
[INFO] CPU 0: State 1 (cpuoff_l) was used
[INFO] CPU 0: All idle states reached, stopping early
[INFO] CPU 0: SUCCESS - All states reached: cpuoff_l, clusteroff_l, WFI
[INFO] Testing CPU 1 (2/8)
[INFO] CPU 1: State 2 (clusteroff_l) was used
[INFO] CPU 1: State 0 (WFI) was used
[INFO] CPU 1: NOTE - States with existing usage (not tested): cpuoff_l
[INFO] Testing CPU 2 (3/8)
[INFO] CPU 2: State 1 (cpuoff_l) was used
[INFO] CPU 2: State 2 (clusteroff_l) was used
[INFO] CPU 2: State 0 (WFI) was used
[INFO] CPU 2: All idle states reached, stopping early
[INFO] CPU 2: SUCCESS - All states reached: cpuoff_l, clusteroff_l, WFI
[INFO] Testing CPU 3 (4/8)
[INFO] CPU 3: State 2 (clusteroff_l) was used
[INFO] CPU 3: State 0 (WFI) was used
[INFO] CPU 3: NOTE - States with existing usage (not tested): cpuoff_l
[INFO] Testing CPU 4 (5/8)
[INFO] CPU 4: State 2 (clusteroff_b) was used
[INFO] CPU 4: State 1 (cpuoff_b) was used
[INFO] CPU 4: State 0 (WFI) was used
[INFO] CPU 4: All idle states reached, stopping early
[INFO] CPU 4: SUCCESS - All states reached: cpuoff_b, clusteroff_b, WFI
[INFO] Testing CPU 5 (6/8)
[INFO] CPU 5: State 2 (clusteroff_b) was used
[INFO] CPU 5: State 1 (cpuoff_b) was used
[INFO] CPU 5: NOTE - States with existing usage (not tested): WFI
[INFO] Testing CPU 6 (7/8)
[INFO] CPU 6: State 2 (clusteroff_b) was used
[INFO] CPU 6: State 1 (cpuoff_b) was used
[INFO] CPU 6: State 0 (WFI) was used
[INFO] CPU 6: All idle states reached, stopping early
[INFO] CPU 6: SUCCESS - All states reached: cpuoff_b, clusteroff_b, WFI
[INFO] Testing CPU 7 (8/8)
[INFO] CPU 7: State 1 (cpuoff_b) was used
[INFO] CPU 7: State 2 (clusteroff_b) was used
[INFO] CPU 7: State 0 (WFI) was used
[INFO] CPU 7: All idle states reached, stopping early
[INFO] CPU 7: SUCCESS - All states reached: cpuoff_b, clusteroff_b, WFI
[INFO] 
Test completed: 8/8 CPUs passed
[INFO] SUCCESS: All CPUs reached all their idle states
root@mtk-genio:/home/ubuntu/CPU# echo $?
0

@seankingyang seankingyang changed the title Add the test script to trigger and capture cpuidle state(New) Add the test script to trigger and capture cpuidle state (New) Jul 23, 2025
@codecov
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

❌ Patch coverage is 90.16393% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.37%. Comparing base (dfbf93e) to head (1f030f3).
⚠️ Report is 94 commits behind head on main.

Files with missing lines Patch % Lines
providers/base/bin/cpu_idle_state.py 90.16% 20 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2039      +/-   ##
==========================================
+ Coverage   51.13%   52.37%   +1.24%     
==========================================
  Files         386      392       +6     
  Lines       41603    42210     +607     
  Branches     7730     7826      +96     
==========================================
+ Hits        21272    22108     +836     
+ Misses      19569    19324     -245     
- Partials      762      778      +16     
Flag Coverage Δ
provider-base 30.23% <90.16%> (+4.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@seankingyang seankingyang force-pushed the cpuidle_script branch 2 times, most recently from 342b28c to 4e8943d Compare July 24, 2025 02:02
Copy link
Contributor

@rickwu666666 rickwu666666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried the script on two of ARM devices. And seems it catch one of device didn't support cpuidle.

[INFO] Starting CPU idle state test
[INFO] This test checks if all processors have the same number of idle states and if idle state transitions happen during alternating load patterns
[INFO] Found 2 CPUs in system
[ERROR] ERROR: No CPUs with cpuidle support found

I think this test is valuable. But what the reason not implement the test job for it?

…ity and seperate the get affinity from the set function
stanley31huang
stanley31huang previously approved these changes Sep 1, 2025
Copy link
Collaborator

@stanley31huang stanley31huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants